jdbc连接oracle数据库问题

   下面是JDBC连接oracle数据库流程:
String dbURL = "jdbc:oracle:thin:@url:1521:service_name";
String userName = "数据库名";
String userPwd = "密码";
Connection con = null;
Statement st = null;
ResultSet rs = null; try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("加载数据库驱动成功!");
System.out.println("数据库连接成功!");
st = con.createStatement(); String sql = "select * from ETL.BD_PSNDOC";//数据库表名前面尽量加上数据库名字 rs = st.executeQuery(sql);
while (rs.next()) {
.......................
}
}catch(Exception e){
e.printStackTrace();
}
try {
if(rs!=null){
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
上一篇:路由器刷机常见第三方固件及管理前端种类(OpenWrt、Tomato、DD-Wrt)


下一篇:Sublime Text 3插件安装方法