最后25分了,求一句简单的代码,在JSP中嵌一句SQL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"SELECT * FROM wang.linchangfenbu WHERE ???????? " where后面的判定条件不会写了. 想将下面程序中comments作为判定条件.试试挺多方法都得到无效的运算符的结果.应该不难,只是我太笨了.呵呵,那么前辈帮写出来吧.谢谢啦.
<%@ page contentType= "text/html; charset=GB2312 " language= "java " import= "java.io.*, java.sql.*, javax.sql.* "%>
<%@ page import= "oracle.jdbc.*, oracle.sql.* "%>
<html>
<body>
<%
request.setCharacterEncoding( "GBK ");
String comments=request.getParameter( "comments ");
// Connect to the database
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
String url= "jdbc:oracle:thin:@localhost:1521:myoracle ";
String user= "wang ";
String password= "yan0625 ";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement ();
ResultSet rs =
stmt.executeQuery( "SELECT * FROM shen01.linchangfenbu WHERE ???????? " );
out.println( " <table border= '1 ' align= 'center ' > ");
out.println( " <tr align= 'center '> ");
out.println( " <th> ttt1 </th> <th> ttt2 </th> <th> ttt3 </th> ");
out.println( " </tr> ");
while(rs.next()) {
out.println( " <tr align= 'center '> ");
out.println ( " <td> "+rs.getString( "ttt1 ")+ " </td> ");
out.println( " <td> "+rs.getString( "ttt2 ")+ " </td> ");
out.println( " <td> "+rs.getString( "ttt3 ")+ " </td> ");
out.println( " </tr> ");
}
out.println( " </table> ");
// Close input and output streams
rs.close();
conn.close