//oracle
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String pwd="tiger";
java.sql.Connection conn=DriverManager.getConnection(url,user,pwd);
//Sybase
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url="jdbc:sybase:Tds:localhost:5007/erp"
//erp为数据库名
PropertiessysProps=System.getProperties();
SysProps.put("user","sa");//用户名
SysProps.put("password","");//密码
java.sql.Connection conn=DriverManager.getConnection(url,SysProps);
//DB2
Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
String url="jdbc:db2://localhost:5000/sample";
//sample为DB2数据库的名称
String user="admin";
String pwd="";//密码
java.sql.Connection conn=DriverManager.getConnection(url,user,pwd);
//Informix
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url="jdbc:informix-sqli://localhost:1533/test:INFORMIXSERVER=infserver;
user=sa;//用户名
password=pwd";//密码
//test为数据库名
java.sql.Connection conn=DriverManager.getConnection(url);
//sqlSever
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatebaseNAme=pubs";
//pubs为数据库
String user="sa";
String pwd="";
java.sql.Connection conn=DriverManager.getConnection(url,user,pwd);
//PostgreSQL
Class.forName("org.postgresql.Driver").newInstance();
String url="jdbc:postgresql://localhost/netcity";
//netcity为数据库名
String user="root";//用户名
String pwd="123456";//密码
java.sql.Connection conn=DriverManager.getConnection(url,user,pwd);
12-06
06-18
541
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-25