yoyo23mir
发贴: 3
|
于 2005-05-11 04:34
我自己写了个JSP页面,只是查询child_info表中数据,没有用Beans,执行的时候也是出错。谁能帮我改改啊?
<%@ page contentType="text/html;charset=GB2312" language="java" %> <%@ page import="java.sql.*" %> <HTML> <BODY bgcolor=orange ><Font size=1> <form action="" Method=post> 请输入查询卡号: <Input type=text name=number> <Input type=submit name=g value=查询> </form> <%! Connection con=null;//声明一个共享的连接对象。 %> <% //获取卡号。 String cardid=request.getParameter("number"); if(cardid==null) {cardid="?"; } byte b[]=cardid.getBytes("ISO-8859-1"); cardid=new String(b); Statement sql=null; ResultSet rs=null; if(con==null) { try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e) {out.print(e); } try {con=DriverManager.getConnection("jdbc:odbc:Vaccard","",""); String condition="SELECT * form child_info WHERE 卡号 = "+"'"+ cardid+"'"; rs =sql.executeQuery(condition); } catch(SQLException e) {out.print(e); } } else { synchronized(con) { try {sql=con.createStatement(); String condition="SELECT * form child_info WHERE 卡号 = "+"'"+ cardid+"'"; rs =sql.executeQuery(condition); } catch(SQLException e) {out.print(e); } } } try { out.print("<Table Border>"); out.print("<TR>"); out.print("<TH width=100>"+"卡号"); out.print("<TH width=100>"+"儿童姓名"); out.print("</TR>"); while(rs.next()) { out.print("<TR>"); String number=rs.getString(1); out.print("<TD >"+number+"</TD>"); String childname=rs.getString("儿童姓名"); out.print("<TD >"+childname+"</TD>"); out.print("</TR>") ; } out.print("</Table>"); } catch(SQLException e1) {} %> </FONT> </BODY> </HTML>
why edited on 2005-05-11 10:42
|