首先在web-inf/lib下添加oracle数据库驱动class12.jar
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url = "jdbc:oracle:thin:@172.16.218.20:1521:hzdb";
String user = "sunzags";
String password = "sunzags";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt = null;
ResultSet rs = null;
List<String> appList = new ArrayList();
String app = "";
try{
stmt = conn.createStatement();
String sql = "select FEATURECODE from TBDICGISFEATURE where FEATUREID in (select FEATUREID from TBRELAPPFEATURE where APPID=8)";
rs = stmt.executeQuery(sql);
while(rs.next()) {
app = rs.getString("FEATURECODE");
appList.add(app);
System.out.println(app);
}
}catch(Exception e){
System.out.print(e);
}finally{
rs.close();
stmt.close();
conn.close();
}
%>