|
1.MySQL
复制内容到剪贴板
代码:
Class.forName( " org.gjt.mm.mysql.Driver " );
Connection conn = DriverManager.getConnection( " jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName " , sUsr, sPwd );
2.Microsoft SQLServer
复制内容到剪贴板
代码:
Class.forName( " com.microsoft.jdbc.sqlserver.SQLServerDriver " );
Connection conn = DriverManager.getConnection( " jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433;databaseName=master " , sUsr, sPwd );
3.Oracle
复制内容到剪贴板
代码:
Class.forName( " oracle.jdbc.driver.OracleDriver " );
Connection conn = DriverManager.getConnection ("jdbc: oracle:thin: @MyDbComputerNameOrIP:1521: ORCL " , sUsr, sPwd );
4.DB2
复制内容到剪贴板
代码:
Class.forName( " com.ibm.db2.jdbc.net.DB2Driver " );
String url = " jdbc:db2://192.9.200.108:6789/SAMPLE "
Connection conn = DriverManager.getConnection( url, sUsr, sPwd );
5.ODBC
复制内容到剪贴板
代码:
Class.forName( " sun.jdbc.odbc.JdbcOdbcDriver " );
Connection conn = DriverManager.getConnection("jdbc: odbc: " + sDsn, sUsr, sPwd );
6.PostgreSQL
复制内容到剪贴板
代码:
Class.forName( " org.postgresql.Driver " );
Connection conn = DriverManager.getConnection( " jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName " , sUsr, sPwd ); |
|