1 Java 连接 Oralce
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
Connection conn= DriverManager.getConnection(url,user,password);
2 Java 连接 MySQL
Class.forName("org.gjt.mm.mysql.Driver ").newInstance();
String URL = "jdbc:mysql://localhost/test";
Connection conn=DriverManager.getConnection(url,user,password);
3 Java 连接SQLServer
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String URL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
Connection conn= DriverManager.getConnection(url,user,password);
4 Java 连接DB2
Class.forName(“com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String URL =”jdbc:db2://localhost:5000/sample";
Connection conn= DriverManager.getConnection(url,user,password);
5 Java 连接 Infomix
Class.forName("com.informix.jdbc.IfxDriver ").newInstance();
String URL =jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
Connection conn= DriverManager.getConnection(url,user,password);
6 Java 连接 SyBase
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
Properties sysProps =System.getProperties();
SysProps.put("user","userid");
SysProps.put("password","user_password");
Connection conn= DriverManager.getConnection(url, SysProps);
7 Java连接 PostgreSQL
Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/soft";
Connection conn= DriverManager.getConnection(url,user,password);
8 access数据库使用ODBC直连
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver(*.mdb)};
DBQ="+application.getRealPath("/Data/ReportDemo