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);