jdbc 常用数据库连接字符串

这个东西重来就不记的。

 

Oracle
Class.forName("oracle.jdbc.OracleDriver");
String url = "jdbc:oracle:thin:@localhost:1521:orcl";//orcl is database SID
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password);  

-------------------------------------------------
DriverManager.getConnection("jdbc:oracle:thin:@localhost:orcl", "sys as sysdba","sys");
=================================================

DB2
Class.forName("com.ibm.db2.jdbc.app.DB2Driver");
String url = "jdbc:db2://localhost:5000/DatabaseName";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password); 

=================================================

SQL Server 2000
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password); 
-------------------------------------------------
SQL Server 2005/2008
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=dbName";

=================================================

MYSQL
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost:3306/DatabaseName?useUnicode=true&characterEncoding=UTF-8";
String user = "username";
String password = "password";
Connection dbconn = DriverManager.getConnection(url,user,password); 
-------------------------------------------------
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/dbName"

=================================================

Sybase
Class.forName("com.sybase.jdbc.SybDriver");
String url = "jdbc:sybase:Tds:localhost:5007/DatabaseName";
Properties sysProps = System.getProperties();
SysProps.put("user","admin"):
SysProps.put("password","123456"):
Connection dbconn = DriverManager.getConnection(url,user,password); 

=================================================

Access
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection dbconn = DriverManager.getConnection("jdbc:odbc:DatabaseName"); 

=================================================

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值