常用数据库的JDBC连接代码
时间:2010-08-30 来源:月亮的影子
//常用数据库的JDBC连接代码。
//oracle数据库
class.forName("oracle.jdbc.driver.OracleDrive").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:libSystem";
String user="scott";
String password="tiger";
Connection conn=DriverManager.getConnection(url,user,password);
//DB2数据库
class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
String url="jdbc:db2://localhost:5000/libSystem";
String user="db2admin";
String password="db2admin";
Connection conn=DriverManager.getConnection(url,user,password);
//Sybase数据库
class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url="jdbc:sybase:Tds:localhost:5007/libSystem";
Properties sysProps=System.getProperties();
sysProps.put("user","sa");
sysProps.put("password","");
Connection conn=DriverManager.getConnection(url,sysProps);
//Informix数据库
class.forName("com.infoxmix.jdbc.IfxDriver").newInstance();
String url="jdbc:infoxmix-sqli://localhost:1533/libSystem:
INFORMIXSERVER=myserver;
user=Informix;password=Informix";
Connection conn=DriverManager.getConnection(url);
//MySQL数据库
class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/libSystem?user=root&password=root &useUnicode=true &characterEncoding=GB2312";
String user="db2admin";
String password="db2admin";
Connection conn=DriverManager.getConnection(url);
//PostgreSQL数据库
class.forName("org.postgresql.Driver").newInstance();
String url="jdbc:postgresql://localhost/libSystem";
String user="postgreSQL";
String password="postgreSQL";
Connection conn=DriverManager.getConnection(url,user,password);
//SQL Server数据库
String DBDRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String DBURL="jdbc:sqlserver://localhost:1433;DatabaseName=YL;SelectMethod=Cursor";
String DBUSER="sa";
String DBPASSWORD="123";
Class.forName(DBDRIVER);
Connection conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-