jdbc连接字符串


MySQL:
String Driver="com.mysql.jdbc.Driver"; //驱动程序
String URL="jdbc:mysql://localhost:3306/db_name"; //连接的URL,db_name为数据库名
String Username="username"; //用户名
String Password="password"; //密码
Class.forName(Driver);
Connection con=DriverManager.getConnection(URL,Username,Password);

Oracle:
String Driver="oracle.jdbc.driver.OracleDriver";  //连接数据库的方法
String URL="jdbc:oracle:thin:@localhost:1521:orcl";  //orcl为数据库的SID
String Username="username"; //用户名
String Password="password"; //密码
Class.forName(Driver) ; //加载数据库驱动
Connection con=DriverManager.getConnection(URL,Username,Password); //常用数据库链接方式

DB2:
String Driver="com.ibm.dbjdbc.app.DBDriver"; //连接具有DB2客户端的Provider实例
//String Driver="com.ibm.dbjdbc.net.DBDriver"; //连接不具有DB2客户端的Provider实例
String URL="jdbc:db2://localhost:5000/db_name"; //db_name为数据库名
String Username="username"; //用户名
String Password="password"; //密码
Class.forName(Driver) ;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM