﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-创造希望-文章分类-oracle</title><link>http://www.blogjava.net/yuhuaan/category/27768.html</link><description>做一個精通技術的高級管理人員，做一個善於管理的高級技術人員！在學習中實踐，在實踐中學習！明日網豪之星</description><language>zh-cn</language><lastBuildDate>Tue, 04 Dec 2007 09:18:46 GMT</lastBuildDate><pubDate>Tue, 04 Dec 2007 09:18:46 GMT</pubDate><ttl>60</ttl><item><title>JDBC连接各种数据库方法</title><link>http://www.blogjava.net/yuhuaan/articles/164875.html</link><dc:creator>网豪</dc:creator><author>网豪</author><pubDate>Mon, 03 Dec 2007 06:48:00 GMT</pubDate><guid>http://www.blogjava.net/yuhuaan/articles/164875.html</guid><wfw:comment>http://www.blogjava.net/yuhuaan/comments/164875.html</wfw:comment><comments>http://www.blogjava.net/yuhuaan/articles/164875.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yuhuaan/comments/commentRss/164875.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yuhuaan/services/trackbacks/164875.html</trackback:ping><description><![CDATA[<blockquote dir="ltr" style="margin-right: 0px">
<p><strong>1、Oracle8/8i/9i数据库（thin模式）</strong> <br />
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); <br />
String url="jdbc:oracle:thin:@localhost:1521:orcl"; <br />
//orcl为数据库的SID <br />
String user="test"; <br />
String password="test"; <br />
Connection conn= DriverManager.getConnection(url,user,password); <br />
<br />
<strong>2、DB2数据库 <br />
</strong>Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); <br />
String url="jdbc:db2://localhost:5000/sample"; <br />
//sample为你的数据库名 <br />
String user="admin"; <br />
String password=""; <br />
Connection conn= DriverManager.getConnection(url,user,password); <br />
<br />
<strong>3、Sql Server7.0/2000数据库</strong> <br />
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); <br />
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb"; <br />
//mydb为数据库 <br />
String user="sa"; <br />
String password=""; <br />
Connection conn= DriverManager.getConnection(url,user,password); <br />
<br />
<strong>4、Sybase数据库 <br />
</strong>Class.forName("com.sybase.jdbc.SybDriver").newInstance(); <br />
String url =" jdbc:sybase:Tds:localhost:5007/myDB"; <br />
//myDB为你的数据库名 <br />
Properties sysProps = System.getProperties(); <br />
SysProps.put("user","userid"); <br />
SysProps.put("password","user_password"); <br />
Connection conn= DriverManager.getConnection(url, SysProps); <br />
<br />
<strong>5、Informix数据库 <br />
</strong>Class.forName("com.informix.jdbc.IfxDriver").newInstance(); <br />
String url = <br />
"jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver; <br />
user=testuser;password=testpassword"; <br />
//myDB为数据库名 <br />
Connection conn= DriverManager.getConnection(url); <br />
<br />
<strong>6、MySQL数据库 <br />
</strong>Class.forName("org.gjt.mm.mysql.Driver").newInstance(); <br />
String url ="jdbc:mysql://localhost/myDB?user=soft&amp;password=soft1234&amp;useUnicod <br />
e=true&amp;characterEncoding=8859_1" <br />
//myDB为数据库名 <br />
Connection conn= DriverManager.getConnection(url); <br />
<br />
<strong>7、PostgreSQL数据库 <br />
</strong>Class.forName("org.postgresql.Driver").newInstance(); <br />
String url ="jdbc:postgresql://localhost/myDB" <br />
//myDB为数据库名 <br />
String user="myuser"; <br />
String password="mypassword"; <br />
Connection conn= DriverManager.getConnection(url,user,password); </p>
</blockquote>
 <img src ="http://www.blogjava.net/yuhuaan/aggbug/164875.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yuhuaan/" target="_blank">网豪</a> 2007-12-03 14:48 <a href="http://www.blogjava.net/yuhuaan/articles/164875.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>