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(); }

 

posted @ 2019-01-19 12:43  我爱si搬砖  阅读(212)  评论(0编辑  收藏  举报