当前位置: 首页 > 图文教程 > 数据库 > MYSQL > Java连接各种数据库的实例

MYSQL
轻松解决Mysql“信息包过大”的处理方法
MySQL数据库实例管理器命令行选项详解
连接到MySQL实例管理器并创建用户账户
MySQL数据库中实例管理器识别的命令
教你快速了解应该如何升级MySQL系统表
轻轻松松正确掌握MySQL服务器关机进程
MySQL数据库搜索中大小写敏感性详细
如何正确认识Mysql通信错误与失效连接
MYSQL使用错误 MYSQL中ERROR 1005
MYSQL使用错误 MYSQL中ERROR 1006
MySQL手动安装方法与中文解决方案
MySQL事件调度器Event Scheduler详解
Mysql使用Describe命令判断字段是否存在
MySQL UPDATE时主键冲突引发的思考
怎样解决MySQL 5.0.16的乱码问题
详解如何用SQLyog来分析MySQL数据库
在MySQL数据库中如何为用户设置密码
MySQL多表操作和备份处理教程
在线设置MySql数据同步
tomcat+mysql数据库的连接池配置

MYSQL 中的 Java连接各种数据库的实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 89 ::
收藏到网摘: n/a

1、Oracle8/8i/9i数据库(thin模式)

2、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);

3、SQL Server7.0/2000数据库

以下为引用的内容:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydb为数据库
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);

4、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、MySQL数据库

以下为引用的内容:
Class.forName("org.gjt.mm.MySQL.Driver").newInstance();
String url ="jdbc:MySQL://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//myDB为数据库名
Connection conn= DriverManager.getConnection(url);

7、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);