將oracle數據庫驅動jar包引入到工程裏面。數據庫
下面是JDBC鏈接ORACLE數據庫核心的代碼oracle
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:oradb", "ufshop", "1");
- psGoodList = con.prepareStatement("select sid,sname,sprice from good",
- ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_READ_ONLY);
- psGoodFromIdToPrice = con.prepareStatement("select sprice from good where sid=?");
- psGoodFromIdToPrice.setString(1, sid);
- ResultSet rs = psGoodFromIdToPrice.executeQuery();
- } catch (Exception e) {
- e.printStackTrace();
- // TODO: handle exception
- }