|
|
下面罗列了各种数据库使用JDBC连接的方式,可以作为一个手册使用。
1、Oracle8/8i/9i数据库(thin模式)
<div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; width: 98%; padding-top: 4px; background-color: #eeeeee; border: #cccccc 1px solid;">Class.forName('oracle.jdbc.driver.OracleDriver').newInstance();
String url='jdbc:oracle:thin:@localhost:1521:orcl'; //orcl为数据库的SID
String user='test';
String password='test';
Connection conn= DriverManager.getConnection(url,user,password); |
|