Java数据库驱动链接大全
2012-07-18 17:27
246 查看
Java数据库驱动链接大全
MySQL:
String Driver="com.mysql.jdbc.Driver"; //驱动程序
String URL="jdbc:mysql://localhost:3306/db_name"?useUnicode=true&characterEncoding=UTF-8; //连接的URL,db_name为数据库名,注意修改编码类型
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Microsoft SQL Server 2000以下 驱动(3个jar的那个):
String Driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"; //连接SQL数据库的方法
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Microsoft SQL Server 2005以下 驱动(1个jar的那个):
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; //连接SQL数据库的方法
String URL="jdbc:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Sysbase:
String Driver="com.sybase.jdbc.SybDriver"; //驱动程序
String URL="jdbc:Sysbase://localhost:5007/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Oracle(用thin模式):
String Driver="oracle.jdbc.driver.OracleDriver"; //连接数据库的方法
String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl为数据库的SID
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
PostgreSQL:
String Driver="org.postgresql.Driver"; //连接数据库的方法
String URL="jdbc:postgresql://localhost/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
DB2:
String Driver="com.ibm.db2.jdbc.app.DB2.Driver"; //连接具有DB2客户端的Provider实例
//String Driver="com.ibm.db2.jdbc.net.DB2.Driver"; //连接不具有DB2客户端的Provider实例
String URL="jdbc:db2://localhost:5000/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Informix:
String Driver="com.informix.jdbc.IfxDriver";
String URL="jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
JDBC-ODBC:
String Driver="sun.jdbc.odbc.JdbcOdbcDriver";
String URL="jdbc:odbc:dbsource"; //dbsource为数据源名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
PostgreSQL数据库
String Driver = "org.postgresql.Driver";
String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Access数据库直连用ODBC的
String Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
Class.forName(Driver);
Connection conn = DriverManager.getConnection(url,"","");
本文出自 “艾客” 博客,请务必保留此出处http://jrunner.blog.51cto.com/1015356/934626
MySQL:
String Driver="com.mysql.jdbc.Driver"; //驱动程序
String URL="jdbc:mysql://localhost:3306/db_name"?useUnicode=true&characterEncoding=UTF-8; //连接的URL,db_name为数据库名,注意修改编码类型
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Microsoft SQL Server 2000以下 驱动(3个jar的那个):
String Driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"; //连接SQL数据库的方法
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Microsoft SQL Server 2005以下 驱动(1个jar的那个):
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; //连接SQL数据库的方法
String URL="jdbc:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Sysbase:
String Driver="com.sybase.jdbc.SybDriver"; //驱动程序
String URL="jdbc:Sysbase://localhost:5007/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Oracle(用thin模式):
String Driver="oracle.jdbc.driver.OracleDriver"; //连接数据库的方法
String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl为数据库的SID
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
PostgreSQL:
String Driver="org.postgresql.Driver"; //连接数据库的方法
String URL="jdbc:postgresql://localhost/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
DB2:
String Driver="com.ibm.db2.jdbc.app.DB2.Driver"; //连接具有DB2客户端的Provider实例
//String Driver="com.ibm.db2.jdbc.net.DB2.Driver"; //连接不具有DB2客户端的Provider实例
String URL="jdbc:db2://localhost:5000/db_name"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Informix:
String Driver="com.informix.jdbc.IfxDriver";
String URL="jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver"; //db_name为数据可名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
JDBC-ODBC:
String Driver="sun.jdbc.odbc.JdbcOdbcDriver";
String URL="jdbc:odbc:dbsource"; //dbsource为数据源名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
PostgreSQL数据库
String Driver = "org.postgresql.Driver";
String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名
String username="username"; //用户名
String password="password"; //密码
Class.forName(Driver);
Connection con = DriverManager.getConnection(URL,username,password);
Access数据库直连用ODBC的
String Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
Class.forName(Driver);
Connection conn = DriverManager.getConnection(url,"","");
本文出自 “艾客” 博客,请务必保留此出处http://jrunner.blog.51cto.com/1015356/934626
相关文章推荐
- Java数据库驱动链接大全
- jsp连接数据库大全(各类数据库驱动的连接)Java连接各种数据库的实例
- java连接各个数据库驱动名大全
- java的JDBC驱动使用链接数据库
- java连接各个数据库驱动名大全 (2012-08-01 11:10:47)
- java中jdbc链接数据库大全
- java连接各个数据库驱动名大全
- jsp连接数据库大全(各类数据库驱动的连接)Java连接各种数据库的实例
- JAVA JDBC链接查询oracle 数据库的小例程
- Java连接数据库方法大全
- java_JDBC连接数据库代码大全
- java基础巩固---jdbc连接各大数据库的驱动+url
- Java基础:常用的JDBC连接数据库方法大全
- java各种数据库对应的jar包、驱动类名和URL格式
- JAVA各数据库连接驱动
- java.jee--jsp--jdbc链接数据库,展示数据
- Java Web开发使用配置文件链接数据库
- java 链接mysql 链接数据库的步骤
- JAVA JDBC 读取配置文件链接数据库(oracle)
- JSP连接各类数据库大全SQLServer2000 JDBC驱动的完整安装及测试?