当前位置:首页 » 数据仓库 » myeclipse中连接mysql数据库
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

myeclipse中连接mysql数据库

发布时间: 2022-08-24 02:11:24

㈠ myeclipse怎么连接mysql数据库

myeclipse连接mysql数据库的方法如下:

1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打开之后左侧会出现下图所示界面,在空白区域右击——New。

2、选中所建的DB,右击Open Connection,输入用户名和密码。

㈡ myeclipse怎么连数据库

myeclipse连接mysql数据库的方法如下:

1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打开之后左侧会出现下图所示界面,在空白区域右击——New。

2、选中所建的DB,右击Open Connection,输入用户名和密码。

㈢ MyEclipse如何连接MySQL数据库

写一个DBconnect类,里面写数据库引擎,数据库名称,密码,然后在导入mysql的jdbc的驱动包,就可以了

㈣ 用MYECLIPSE怎么连接MYSQL数据库

首先打开Myeclipse
在工具栏上选择
window->Show View->Other
选择Myeclipse database
双击DB Bowser
在控制台部分多出DB Bowser,右击空白处
选择new
在弹出的界面中
Driver template:MySQL Connector/]
Driver name:填写连接的名字(随意)
Connection url:jdbc:mysql://localhost:3306/数据库名
其中localhost表示本地数据库,如果是远程的则填写对方地址
数据库名表示你要连接的数据库的名称
User name:root
password:密码
然后添加jar包
这个时候你可以测试一下连接
单击Test Driver
如果连接成功则点击finsh
然后在控制台处
右击你的连接名
选择open connection
这样你就将Myeclipse与数据库连接了!

㈤ 在myeclipse中怎么连接mysql数据库

JDBC连接各种数据库的方法

1)连接Oracle 8/8i/9i/10g/11g(thin模式)

Class.forName("oracle.JDBC.driver.OracleDriver").newInstance();
Stringurl="JDBC:oracle:thin:@localhost:1521:orcl"//orcl为Oracle数据库的SID
Stringuser="test";
Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

2)连接DB2数据库

Class.forName("com.ibm.db2.jcc.DB2Driver");
Stringurl="JDBC:db2://localhost:5000/testDb";/**数据库连接串**/
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

3)连接MySQL数据库

Class.forName("com.mysql.jdbc.Driver");
Stringurl="JDBC:mysql://localhost:8080/testDB";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

4)连接SQL Server数据库

Class.forName("com.microsoft.JDBC.sqlserver.SQLServerDriver");
Stringurl="JDBC:microsoft:sqlserver://localhost:1433;DatabaseName=testDb";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

5)连接PostgreSQL数据库

Class.forName("org.postgresql.Driver");
Stringurl="JDBC:postgresql://localhost/testDb";
Stringuser="test";Stringpassword="test";
Connectioncon=DriverManager.getConnection(url,user,password);

6)连接Access数据库

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Stringurl="JDBC:odbc:Driver={MicrosoftAccessDriver(*.mdb)};DBQ="+application.getRealPath("/Data/testDb/mdb");
Connectionconn=DriverManager.getConnection(url,"","");

7连接Sybase数据库

Class.forName("com.sybase.JDBC.SybDriver");
Stringurl="JDBC:sybase:Tds:localhost:5007/testDb";
Propertiespro=System.getProperties();
pro.put("user","userId");
pro.put("password","user_password");
Connectioncon=DriverManager.getConnection(url,pro);

8连接informix数据库

Class.forName("com.informix.JDBC.ifxDriver");
Stringurl="JDBC:informix-sqli:localhost:1533/testDb:INFORMIXSERVER=myserver"user=testUser;password=testpassword";Connectioncon=DriverManager.getConnection(url);

示例:我这里有个大牛聚集地,前面九七三中间打四五四后面两个零,组合起来就行了。连接SQL Server2008R2数据库
首先Build Path → 添加外部sqljdbc.jar驱动

import java.sql.*;

public class DB {

public static void main(String[] args) throws Exception {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=数据库名", "sa", "1234");

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from 表名");

while(rs.next()) {

System.out.println("id为:" + rs.getString("id") + "name为:" + rs.getString("name"));

}

System.out.println("数据库连接成功!");

rs.close();

stmt.close();

conn.close();

System.out.println("数据库成功关闭!");

}

}

㈥ 怎么用myeclipse连接mysql数据库

myeclipse连接mysql数据库的方法如下: 1、在myEclipse中,Window—>Open Perspective—>MyEclipse Database Explorer。打开之后左侧会出现下图所示界面,在空白区域右击——New。 2、选中所建的DB,右击Open Connection,输入用户名和密码。 3、就...

㈦ myeclipse怎么连接数据库mysql

Java连接mysql数据库,首先需要导入mysql的java驱动,然后在Java程序中写一个连接串,程序里面调mysql提供的一些函数来执行一些查询;