该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar0 z' o* F1 g+ }1 A& \1 K
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
" o1 @0 V }1 |6 y String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb"; 4 Z$ _4 l- h/ o1 B- Y, Y
2连接SqlServer2005 sqljdbc.jar
* T9 a; Q) j z1 z/ o Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); - z' k$ @0 K: M
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
0 }7 t7 e4 m$ f# B0 [7 {6 _( }% ~" Y) B0 ^' }
3. MySQL mysql-connector-java-5.0.7-bin.jar5 e# ]& a; h: y( C5 j
Class.forName( "com.mysql.jdbc.Driver" );- J$ G1 I% d/ F# x9 G
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );
8 l' O: D$ L& q 8 L6 S g+ s7 J) ~0 ~3 J1 U+ E1 c
4. Oracle(# B6 B7 F# ~: Q. F& U* h6 `
//注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
0 t8 \! G. Z' T; Z Class.forName("oracle.jdbc.driver.OracleDriver");
- q& e' `% ?* _3 Y0 W3 C+ X. |: z Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password);
/ s- V, S" ~3 y2 H% Q: P $ j, J; B1 T& {# Q
5. 使用jtds连接SQLServer2000 jtds-1.2.jar6 j- Y2 A: v5 l4 Z0 l
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );- m0 V; q" c% t1 H
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );
6 g% ]* q4 E0 l0 g; U1 [/ o
6 P6 L6 }4 m+ _. Z- w( _
t! c4 z# D: L! }0 d: y3 T 6. ODBC
* P n! l7 \# }, j Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
7 l0 x9 O+ D' F- n* H Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );
' F" z8 m+ J; Z4 l* u$ J
8 {& [: F' I$ |0 n 7.DB2
' h9 A0 v0 n9 f1 x) K Class.forName("Com.ibm.db2.jdbc.app.DB2Driver");
/ g0 j; G3 }7 R, l* \ String url="jdbc:db2://192.9.200.108:6789/数据库名"9 O' I4 y; k9 k- t& x6 e
cn = DriverManager.getConnection( url, sUsr, sPwd );: f3 e9 |3 a# k" T
# C2 N( n* H; J& k4 Z) J" h
8. PostgreSQL- ~4 ~* \# ^+ ]$ {
Class.forName( "org.postgresql.Driver" );# C/ L3 @- s9 ^ g f" F
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
3 c- D- c. S2 q/ P) r! h$ F + ~4 Q6 l4 j" t( j
9. Sybase
4 n7 t* c/ f( H! W& W; d Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );; {# k) F |9 c2 Q
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );! v0 \, A; B* d+ @% V! E
//(Default-Username/Password: "dba"/"sql")# |2 k7 v0 ~* ^6 a" _5 y7 o5 f6 T
% O7 k0 B5 B5 j1 x# x8 D
' d4 f& B3 C, x* Y
|
|