%@ page import="java.sql.*" %>
Spagetti JSP
Spagetti JSP
Show:
| F1 |
F2 |
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
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: