JDBC连接数据库整理
来源:互联网 发布:java之父 求职 编辑:程序博客网 时间:2024/05/14 02:39
1.Sql Server7.0/2000数据库
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
----------Sql Server2005数据库-------------
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
-----------------------------------------------------------------------------------------------------
2.Oracle8/8i/9i数据库(thin模式)
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
-----------------------------------------------------------------------------------------------------
3.MySQL数据库
private static String driver="org.gjt.mm.mysql.Driver";
----------------------------------------------------------------------------------------------
4.DB2数据库
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
--------------------------------------------
5.Sybase数据库
Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5007/myDB";//myDB为你的数据库名
Properties sysProps = System.getProperties();
SysProps.put("user","userid");
SysProps.put("password","user_password");
Connection conn= DriverManager.getConnection(url, SysProps);
5.Informix数据库
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword"; //myDB为数据库名
Connection conn= DriverManager.getConnection(url);
--------------------------------------------------------------------------------------------------
6.PostgreSQL数据库
Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
-------------------------------------------------------------------------------------------------
7.access数据库直连用ODBC的
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
Connection conn = DriverManager.getConnection(url,"","");
Statement stmtNew=conn.createStatement() ;
- JDBC连接数据库整理
- JDBC连接各种数据库[整理]
- 常用数据库JDBC连接写法(整理)
- JDBC连接oracle数据库(资料整理)
- 常用数据库JDBC连接写法(整理)
- jdbc入门、jdbc连接数据库
- [整理] JDBC连接形式一览
- jdbc-odbc连接数据库
- JDBC连接MySQL数据库
- JDBC连接MySQL数据库
- JDBC之连接数据库
- [JDBC] 如何连接数据库
- JDBC连接数据库技巧
- jdbc连接数据库
- JDBC连接常用数据库
- jdbc连接数据库
- JDBC连接SqlServer2005数据库
- jdbc连接各种数据库
- 搭建Mantis 缺陷管理系统
- Mac上安装与更新Ruby,Rails运行环境
- java 图像特效之素描
- html基础-surround
- tiny210(s5pv210)移植u-boot(基于 2014.4 版本)——移植u-boot.bin(内存布局)
- JDBC连接数据库整理
- Base类sizeof大小 -- C++
- 拿起笔来做刀枪 · 之一 再造一个dom4j
- 谈谈如何设计秒杀服务
- tiny210(s5pv210)移植u-boot(基于 2014.4 版本)——移植u-boot-spl.bin(内存初始化)
- 大整数加法
- Oracle 获得以百分号结尾的脚本
- select常见事件
- 拿起笔来做刀枪 · 之二 再造一个spring