java如何连接oracle7.3数据库,
发布网友
发布时间:2022-04-08 04:10
我来回答
共4个回答
热心网友
时间:2022-04-08 05:39
import java.sql.Connection;
import java.sql.DriverManager;
public class JDBCDemo {
private static JDBCDemo JDBCDemo = new JDBCDemo();
private static Connection conn = null;
private String userName = "xxxx";
private String passwd ="xxx";
private JDBCDemo(){
this.createConnection();
}
private synchronized JDBCDemo getInstance(){
if (JDBCDemo == null ){
JDBCDemo = new JDBCDemo();
}
return JDBCDemo;
}
protected void createConnection(){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");//加载驱动
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:bms"/**/,/**/userName,/**/passwd);
}catch(Exception e) {
e.printStackTrace();
}
}
public Connection getConnection(){
return conn;
}
}
jdbc连接fangshi
热心网友
时间:2022-04-08 06:57
第一步:加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
第二步:构造连接
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521/db","user","password");
这样就连上了
热心网友
时间:2022-04-08 08:32
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521/db","user","password");
热心网友
时间:2022-04-08 10:23
去哪找那么古老的版本
应该是相似的
试试
http://zhidao.baidu.com/question/161407728.html
或
http://zhidao.baidu.com/question/262698371.html