JDBC常用连接URL

1、Oracle8/8i/9i数据库(thin模式)<wbr><br> Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();<wbr><br> String url="jdbc:oracle:thin:@localhost:1521:orcl";<wbr><br> //orcl为数据库的SID<wbr><br> String user="test";<wbr><br> String password="test";<wbr><br> Connection conn= DriverManager.getConnection(url,user,password);</wbr></wbr></wbr></wbr></wbr></wbr>

2、DB2数据库<wbr><br> Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();<wbr><br> String url="jdbc:db2://localhost:5000/sample";<wbr><br> //sample为你的数据库名<wbr><br> String user="admin";<wbr><br> String password="";<wbr><br> Connection conn= DriverManager.getConnection(url,user,password);</wbr></wbr></wbr></wbr></wbr></wbr>

3、Sql Server7.0/2000数据库<wbr><br> Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();<wbr><br> String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";<wbr><br> //mydb为数据库<wbr><br> String user="sa";<wbr><br> String password="";<wbr><br> Connection conn= DriverManager.getConnection(url,user,password);</wbr></wbr></wbr></wbr></wbr></wbr>

4、Sybase数据库<wbr><br> Class.forName("com.sybase.jdbc.SybDriver").newInstance();<wbr><br> String url =" jdbc:sybase:Tds:localhost:5007/myDB";<wbr><br> //myDB为你的数据库名<wbr><br> Properties sysProps = System.getProperties();<wbr><br> SysProps.put("user","userid");<wbr><br> SysProps.put("password","user_password");<wbr><br> Connection conn= DriverManager.getConnection(url, SysProps);</wbr></wbr></wbr></wbr></wbr></wbr></wbr>

5、Informix数据库<wbr><br> Class.forName("com.informix.jdbc.IfxDriver").newInstance();<wbr><br> String url =<wbr><br> "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;<wbr><br> user=testuser;password=testpassword";<wbr><br> //myDB为数据库名<wbr><br> Connection conn= DriverManager.getConnection(url);</wbr></wbr></wbr></wbr></wbr></wbr>

6、MySQL数据库<wbr><br> Class.forName("org.gjt.mm.mysql.Driver").newInstance();<wbr><br> String url ="jdbc:mysql://localhost/myDB?user=soft&amp;password=soft1234&amp;useUnicode=true&amp;characterEncoding=8859_1"<wbr><br> //myDB为数据库名<wbr><br> Connection conn= DriverManager.getConnection(url);</wbr></wbr></wbr></wbr>

7、PostgreSQL数据库<wbr><br> Class.forName("org.postgresql.Driver").newInstance();<wbr><br> String url ="jdbc:postgresql://localhost/myDB"<wbr><br> //myDB为数据库名<wbr><br> String user="myuser";<wbr><br> String password="mypassword";<wbr><br> Connection conn= DriverManager.getConnection(url,user,password);</wbr></wbr></wbr></wbr></wbr></wbr>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值