1,
MySQL:
String Driver="com.mysql.jdbc.Driver"; //驱动地址名称
String URL="jdbc:mysql://localhost:3306/db_name";
String Username="username"; //用户名
String Password="password"; //密码
Class.forName(Driver).new Instance();
Connection con=DriverManager.getConnection(URL,Username,Password);
2,
Microsoft
SQL Server 2.0驱动(3个jar):
String Driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name";
String Username="username";
String Password="password";
Class.forName(Driver).new Instance();
Connection con=DriverManager.getConnection(URL,UserName,Password);
3,
Microsoft SQL Server 3.0驱动(1个jar):
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name";
String Username="username";
String Password="password";
Class.forName(Driver).new Instance();
Connection con=DriverManager.getConnection(URL,UserName,Password);
4,
Sysbase:
String Driver="com.sybase.jdbc.SybDriver";
String URL="jdbc:Sysbase://localhost:5007/db_name";
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);
5,
Oracle(用thin模式):
String Driver="oracle.jdbc.driver.OracleDriver";
String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl为数据库实例名
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);
6,
PostgreSQL:
String Driver="org.postgresql.Driver";
String URL="jdbc:postgresql://localhost/db_name";
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);
7,
DB2:
//具有客户端的实例
String Driver="com.ibm.db2.jdbc.app.DB2.Driver";
//不具有DB2客户端的实例
//String Driver="com.ibm.db2.jdbc.net.DB2.Driver";
String URL="jdbc:db2://localhost:5000/db_name";
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);
8,
Informix:
String Driver="com.informix.jdbc.IfxDriver";
String URL="jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver";
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);
9,
JDBC-ODBC:
String Driver="sun.jdbc.odbc.JdbcOdbcDriver";
String URL="jdbc:odbc:dbsource"; //dbsource为数据源名
String Username="username";
String Password="password";
Class.forName(Driver).newInstance();
Connection con=DriverManager.getConnection(URL,Username,Password);