|
<p ><p >常用JDBC连接数据库方法总结如下:<p >一、DB2 <p >Class.forName("Com.ibm.db2.jdbc.net.DB2Driver"); <p >String url="jdbc:db2://dburl:port/DBname" <p >cn = DriverManager.getConnection( url, userName, password );<p >二、Microsoft SQLServer(microsoft) <p >Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ); <p >cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://DBServerIP:1433;databaseName=master", userName, password ); <p >三、Sybase(jconn2.jar)<p >Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" ); <p >cn = DriverManager.getConnection( "jdbc:sybase:Tds BServerIP:2638", userName, password); <p >四、MySQL(mm.mysql-3.0.2-bin.jar)<p >Class.forName( "org.gjt.mm.mysql.Driver" ); <p >cn = DriverManager.getConnection( "jdbc:mysql://DBServerIP:3306/myDatabaseName", userName, password ); <p >五、PostgreSQL(pgjdbc2.jar)<p >Class.forName( "org.postgresql.Driver" ); <p >cn = DriverManager.getConnection( "jdbc:postgresql://DBServerIP/myDatabaseName", userName, password ); <p >六、Oracle(classes12.jar) <p >Class.forName( "oracle.jdbc.driver.OracleDriver" ); <p >cn = DriverManager.getConnection( "jdbc racle:thin MyDbComputerNameOrIP:1521:ORCL", userName, password ); <p >七、ODBC <p >Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); <p >Connection cn = DriverManager.getConnection( "jdbc dbc:" + sDsn, userName, password );<p >< align=right></P><p align="center"></p></p> |
|