MySQL
String Driver=commysqljdbcDriver; //驅動程序
String URL=jdbc:mysql://localhost:/db_name; //連接的URLdb_name為數據庫名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)new Instance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
Microsoft SQL Server 驅動(個jar的那個):
String Driver=commicrosoftjdbcsqlserverSQLServerDriver; //連接SQL數據庫的方法
String URL=jdbc:microsoft:sqlserver://localhost:;DatabaseName=db_name; //db_name為數據庫名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)new Instance(); //加載數據可驅動
Connection con=DriverManagergetConnection(URLUserNamePassword); //
Microsoft SQL Server 驅動(個jar的那個): // 老紫竹完善
String Driver=commicrosoftsqlserverjdbcSQLServerDriver; //連接SQL數據庫的方法
String URL=jdbc:microsoft:sqlserver://localhost:;DatabaseName=db_name; //db_name為數據庫名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)new Instance(); //加載數據可驅動
Connection con=DriverManagergetConnection(URLUserNamePassword); //
Sysbase:
String Driver=comsybasejdbcSybDriver; //驅動程序
String URL=jdbc:Sysbase://localhost:/db_name; //db_name為數據可名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
Oracle(用thin模式):
String Driver=oraclejdbcdriverOracleDriver; //連接數據庫的方法
String URL=jdbc:oracle:thin:@loaclhost::orcl; //orcl為數據庫的SID
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance(); //加載數據庫驅動
Connection con=DriverManagergetConnection(URLUsernamePassword);
PostgreSQL:
String Driver=orgpostgresqlDriver; //連接數據庫的方法
String URL=jdbc:postgresql://localhost/db_name; //db_name為數據可名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
DB
String Driver=comibmdbjdbcappDBDriver; //連接具有DB客戶端的Provider實例
//String Driver=DBDriver; //連接不具有DB客戶端的Provider實例
String URL=jdbc:db://localhost:/db_name; //db_name為數據可名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
Informix:
String Driver=rmixjdbcIfxDriver;
String URL=jdbc:Informixsqli://localhost:/db_name:INFORMIXSER=myserver; //db_name為數據可名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
JDBCODBC:
String Driver=sunjdbcodbcJdbcOdbcDriver;
String URL=jdbc:odbc:dbsource; //dbsource為數據源名
String Username=username; //用戶名
String Password=password; //密碼
ClassforName(Driver)newInstance();
Connection con=DriverManagergetConnection(URLUsernamePassword);
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26062.html