%@ page import="java.sql.*,javax.naming.*,javax.sql.*" %>
Spagetti JSP (pool)
Spagetti JSP (pool)
Show:
| F1 |
F2 |
<%
Context initctx = new InitialContext();
Context envctx = (Context)initctx.lookup("java:/comp/env");
DataSource ds = (DataSource)envctx.lookup("jdbc/TestDB");
Connection con = ds.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT f1,f2 FROM t1");
ResultSet rs = pstmt.executeQuery();
while(rs.next()) {
int f1 = rs.getInt(1);
String f2 = rs.getString(2);
%>
| <%=f1%> |
<%=f2%> |
Delete |
<%
}
rs.close();
pstmt.close();
con.close();
%>
Add: