常用JDBC连接字符串

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 );
上一篇:Word 查找替换高级玩法系列之 -- 把论文中的缩写词快速变成目录下边的注释表


下一篇:WPF调用图片路径,或资源图片