该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar1 O- x3 K. b" ^& r( y
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 5 z4 A* M; g1 p c4 U5 g; H D
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb"; 6 |9 [) s+ g* W C
2连接SqlServer2005 sqljdbc.jar
4 R6 d J1 |) X! m3 f Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); : W) |( b: }/ \ X" ~9 D; b
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
' [* K; U+ z# f
n( Z5 J7 |! v2 V$ ^! l' K. q 3. MySQL mysql-connector-java-5.0.7-bin.jar) M: {' C& R4 j: m" e( v
Class.forName( "com.mysql.jdbc.Driver" );
; J+ G4 H3 F+ ~: D4 v( R2 k+ f4 i cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );
$ W1 Y4 |- O: J( x) ]+ ]" Z
& b( v- P% x8 ~7 c* X1 y 4. Oracle(: w' J2 @/ p" n/ Y4 c$ N1 i
//注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
! Y& l& B; w0 S Class.forName("oracle.jdbc.driver.OracleDriver");
2 H! c! H9 Q8 E1 X7 s5 h Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password);
* v$ [! n* ` V# U
+ A8 S5 R; l6 f 5. 使用jtds连接SQLServer2000 jtds-1.2.jar
]( ]1 w# M/ a/ ?8 K Class.forName( "net.sourceforge.jtds.jdbc.Driver" );1 l" t5 B6 }$ u* G4 v/ ]" l" e& |
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );7 I. J! S) ~8 [9 s) B
- j9 d: m4 C+ E8 _& {% }
% d, Y4 [3 j* u5 h; j2 H
6. ODBC
% j. z) }( P8 ^# G; {/ X0 D Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
0 n: s; U, t [& I Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );( g5 t! b0 c2 P( S
' X$ |4 K. o+ n1 X1 L9 g% H, O
7.DB2
2 Q5 B2 q# w/ t, A, m Class.forName("Com.ibm.db2.jdbc.app.DB2Driver"); ' y! K9 l! D% N: M
String url="jdbc:db2://192.9.200.108:6789/数据库名"4 Q% l4 z6 C7 J. o( Z
cn = DriverManager.getConnection( url, sUsr, sPwd );3 W L8 T5 Y4 O1 v3 H- g% T
% k& ~, I* i# H" p t1 G1 C0 P 8. PostgreSQL
/ Q7 b( a$ q) O& n4 G Class.forName( "org.postgresql.Driver" );4 ], A1 z5 { A, l, n9 r2 M
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );- H ]( W' \. S1 y
. [: q8 O, |# a$ o ?" ] 9. Sybase6 x% e0 h$ \- Y' x8 N
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );3 U+ G' O- H, M, d' m( s; e. T
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
- U) ~2 f) k# F //(Default-Username/Password: "dba"/"sql")
4 u! j: p) \% X8 M Y
1 G/ Z$ \' S) `' h7 s
: h& ?3 n6 s& v# i- ~( e, m |
|