这个东西重来就不记的。
Oracle
Class.forName("oracle.jdbc.OracleDriver");
String url = "jdbc:oracle:thin:@localhost:1521:orcl";//orcl is database SID
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password);
-------------------------------------------------
DriverManager.getConnection("jdbc:oracle:thin:@localhost:orcl", "sys as sysdba","sys");
=================================================
DB2
Class.forName("com.ibm.db2.jdbc.app.DB2Driver");
String url = "jdbc:db2://localhost:5000/DatabaseName";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password);
=================================================
SQL Server 2000
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password);
-------------------------------------------------
SQL Server 2005/2008
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=dbName";
=================================================
MYSQL
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost:3306/DatabaseName?useUnicode=true&characterEncoding=UTF-8";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password);
-------------------------------------------------
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/dbName"
=================================================
Sybase
Class.forName("com.sybase.jdbc.SybDriver");
String url = "jdbc:sybase:Tds:localhost:5007/DatabaseName";
Properties sysProps = System.getProperties();
SysProps.put("user","admin"):
SysProps.put("password","123456"):
Connection dbconn = DriverManager.getConnection(url,user,password);
=================================================
Access
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection dbconn = DriverManager.getConnection("jdbc:odbc:DatabaseName");
=================================================