您的位置:首页 > 数据库

jdbc链接各种数据库

2008-05-06 21:06 411 查看
1、链接Sqlserver2000

驱动类
com.microsoft.jdbc.sqlserver.SQLServerDriver

连接字符串
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
(pubs为数据库名,localhost为主机地址,若数据库在远程则为IP地址)

2、链接mysql

驱动类
com.mysql.jdbc.Driver

连接字符串
jdbc:mysql://localhost:3306/pubs
(pubs为数据库名,localhost为主机地址,若数据库在远程则为IP地址)

3、jdbc-odbc桥链接

驱动类
sun.jdbc.odbc.JdbcOdbcDriver

连接字符串
jdbc:odbc:dsnname

(dsnname为odbc数据源的名称)

4、链接Oracle

驱动类:

oracle.jdbc.driver.OracleDriver

链接字符串

jdbc:oracle:thin:@localhost:1521:ora9

(localhost为主机地址,若数据库,在远程则为IP地址其中“1521”为端口,“ora9”为sid )

====================================================================================

String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: