JSP课件以及一个网上书店系统程序,带数据库
源代码在线查看: display.jsp
查询结果如下:
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:saloryDSN";
String user="admin";
String password="";
Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
stmt.setMaxRows(10);
String query=request.getParameter("query");
out.print(query);
ResultSet rs=stmt.executeQuery(query);
ResultSetMetaData rsmd=rs.getMetaData();
int cols=rsmd.getColumnCount();
out.println("");
out.println("");
for(int i=1;i {
out.print("");
out.print(rsmd.getColumnLabel(i));
out.println("");
}
out.print("");
while(rs.next()){
out.print("");
for(int i=1;i out.print("");
Object obj=rs.getObject(i);
if(obj!=null)
out.print(obj.toString());
else
out.print("");
out.println("");
}//end of for
out.print("");
}//end of while
out.print("");
rs.close();
stmt.close();
conn.close();
}
catch(ClassNotFoundException ex){
out.println(ex.getMessage());
}
catch(SQLException ex){
out.println(ex.getMessage());
}
%>
下一个查询