myeclipse怎么连接数据库

myeclipse怎么连接数据库,第1张

myeclipse怎么连接sql server方法/步骤如下:

1、首先,配置环境变量。另外,如果你的机子上没有数据库驱动jar包的话,需要下载一个sqljdbc4.jar。下面,右击“我的电脑”》》选择“属性”》》再选择“高级”》》选中“环境变量”。

2、其次,对SqlServer配置管理器进行设置。首先打开SqlServer配置管理器。具体步骤。

3、进入SQL配置管理器后,选中左侧“SQL Server网络配置”》》再选中“MSSQLSERVER的协议”双击后,右侧窗口会有“TCP/IP”选项。双击进入。。

4、在TCP/IP属性中对IP地址进行设置,IP地址,即本地ip。端口值在后面会用到,先记住。注意,TCP/IP若不是处于启动状态,要右击后选择“启动”。

5、进行完上述设置后,打开MyEclipse进入数据库 *** 作界面。打开后,依次选择“window”》》“open perspective”>>"other..."进入对话框,选择“MyEclipse DataBase Explorer”后就进入了。

6、在右侧窗口空白区域右击鼠标,选择"New.....",打开数据库驱动对话框,

7、对DatabaseDriver进行设置,“Driver template”中选择Sqlserver;

8、点击“finish”完成设置。

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

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

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

3、就可以看到连接成功,可查看数据库。

连接字符串错误

格式如下:

1、Oracle8/8i/9i数据库(thin模式)

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance()

String url="jdbc:oracle:thin:@localhost:1521:orcl"//orcl为数据库的SID

String user="test"

String password="test"

Connection conn= DriverManager.getConnection(url,user,password)

2、DB2数据库

Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance()

String url="jdbc:db2://localhost:5000/sample"//sample为你的数据库名

String user="admin"

String password=""

Connection conn= DriverManager.getConnection(url,user,password)

3、Sql Server7.0/2000数据库

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

String url="jdbc:microsoft:sqlserver://localhost:1433DatabaseName=mydb"//mydb为数据库

String user="sa"

String password=""

Connection conn= DriverManager.getConnection(url,user,password)

4、Sybase数据库

Class.forName("com.sybase.jdbc.SybDriver").newInstance()

String url =" jdbc:sybase:Tds:localhost:5007/myDB"//myDB为你的数据库名

Properties sysProps = System.getProperties()

SysProps.put("user","userid")

SysProps.put("password","user_password")

Connection conn= DriverManager.getConnection(url, SysProps)

5、Informix数据库

Class.forName("com.informix.jdbc.IfxDriver").newInstance()

String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver user=testuserpassword=testpassword"//myDB为数据库名

Connection conn= DriverManager.getConnection(url)

6、MySQL数据库

Class.forName("org.gjt.mm.mysql.Driver").newInstance()//或者Class.forName("com.mysql.jdbc.Driver")

String url ="jdbc:mysql://localhost:3306/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" //myDB为数据库名

Connection conn= DriverManager.getConnection(url)

或者:String url ="jdbc:mysql://localhost:3306/myDB"//myDB为数据库名

DriverManager.getConnection(url,user,password)

7、PostgreSQL数据库

Class.forName("org.postgresql.Driver").newInstance()

String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名

String user="myuser"

String password="mypassword"

Connection conn= DriverManager.getConnection(url,user,password)

8、access数据库直连用ODBC的

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)}DBQ="+application.getRealPath("/Data/ReportDemo.mdb")

Connection conn = DriverManager.getConnection(url,"","")

Statement stmtNew=conn.createStatement()


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10051592.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存