各种数据库连接
2014-01-28 13:23
344 查看
各种数据库连接:
public void Dbcon() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { //JDBC-ODBC String Driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String URL = "jdbc:odbc:dbsource"; //dbsource为数据源名 //Oracle(thin模式): String Driver1 = "oracle.jdbc.driver.OracleDriver"; //连接数据库的方法 String URL1 = "jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl为数据库的SID //MySQL: String Driver2 = "com.mysql.jdbc.Driver"; //驱动程序 String URL2 = "jdbc:mysql://localhost:3306/db_name"; //连接的URL,db_name为数据库名 //DB2: String Drive3r = "com.ibm.db2.jdbc.app.DB2.Driver"; //连接具有DB2客户端的Provider实例 //String Driver="com.ibm.db2.jdbc.net.DB2.Driver"; //连接不具有DB2客户端的Provider实例 String URL3 = "jdbc:db2://localhost:5000/db_name"; //db_name为数据库名 //Microsoft SQL Server: String Driver4 = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //连接SQL数据库的方法 String URL4 = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"; //Sysbase: String Driver5 = "com.sybase.jdbc.SybDriver"; //驱动程序 String URL5 = "jdbc:Sysbase://localhost:5007/db_name"; //PostgreSQL: String Driver6 = "org.postgresql.Driver"; //连接数据库的方法 String URL6 = "jdbc:postgresql://localhost/db_name"; //Informix: String Driver7 = "com.informix.jdbc.IfxDriver"; String URL7 = "jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver"; String Username = "username"; //用户名 String Password = "password"; //密码 Class.forName(Driver).newInstance(); Connection con = DriverManager.getConnection(URL, Username, Password); }
相关文章推荐
- Hibernate与各种数据库连接的配置
- 各种数据库连接代码(转)
- .NET中各种数据库连接大全
- JDBC 基础知识(一) + 各种数据库连接
- Java连接各种数据库
- Oracle SQL Developer连接各种数据库工具的安装及使用
- .NET中各种数据库连接大全收藏
- C#连接各种数据库
- Java连接各种数据库的实例 选择自 lm20224 的 Blog
- 各种数据库的jdbc驱动下载及连接方式
- java各种数据库连接
- C#连接各种数据库语句(实例)
- webconfig中配置各种数据库的连接字符串
- Hibernate与各种数据库连接 配置
- Java连接各种数据库的实例
- Hibernate连接各种数据库的配置
- java连接各种数据库
- [转] 通过ADO连接各种数据库的字符串翠集
- ASP中各种数据库连接代码
- C#连接各种数据库语句