怎样利用JDBC连接并操作Oracle数据库
展开全部
public static Connection getConnection(){
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");//找到oracle驱动器所在的类
String url="jdbc:oracle:thin:@localhost:1521:bjpowernode"; //URL地址
String username="drp";
String password="drp";
conn=DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");//找到oracle驱动器所在的类
String url="jdbc:oracle:thin:@localhost:1521:bjpowernode"; //URL地址
String username="drp";
String password="drp";
conn=DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询