1、Oracle8/8i/9i数据库(thin模式) ' g8 S& P6 k t7 F* x& `9 c; ^
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); * @7 K& W8 F: t/ N& _
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID 3 Z" b8 o( D/ r8 D% }) @- V. Q
String user="test";
" |% L% c! d2 c( X# r/ RString password="test";
; f; R3 m/ G7 P' P9 _6 RConnection conn= DriverManager.getConnection(url,user,password); 4 @4 e5 d( _8 N0 o; p# C
2、DB2数据库 " I' {; k9 t: o9 e( R }9 r
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
" z- J. j1 [* z' u5 `# x0 QString url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名 1 M# |- K, c0 I8 E. [
String user="admin";
9 Q0 u5 G9 F0 b4 sString password=""; . l2 v* t$ S6 j! e- T
Connection conn= DriverManager.getConnection(url,user,password); 2 D( C3 [ x9 l3 e
3、SQL Server7.0/2000数据库
, a; c7 P: Z ]9 O1 L3 W- XClass.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 9 U7 e' r+ q5 B" E3 V9 I% _3 ~
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
* U6 i) `7 |: b7 r8 W* S//mydb为数据库
5 Y$ N$ F3 w% f3 h7 K3 ]1 dString user="sa"; * {, L C7 E: x3 j$ z
String password=""; 3 w. A+ j5 I- O7 l* ~
Connection conn= DriverManager.getConnection(url,user,password);
7 v9 L h- ^# \8 z1 E4、Sybase数据库
2 H2 t& `, E9 b9 TClass.forName("com.sybase.jdbc.SybDriver").newInstance();
* {& |1 D: _' h* g- X$ n. \. BString url =" jdbc:sybase:Tds:localhost:5007/myDB";//myDB为你的数据库名
' x$ z' o9 m2 t9 P1 p1 ]1 MProperties sysProps = System.getProperties(); & g! j% ?6 H4 v% k# j8 ?' {6 G
SysProps.put("user","userid");
; G8 _4 z: u, ?) q) x$ F# DSysProps.put("password","user_password");
) q! T5 O! }: P4 U* f2 M" N% A/ {6 U9 e( X
Connection conn= DriverManager.getConnection(url, SysProps); |