这段代码有什么问题呢,为什么不通过?
<%@ page contentType= "text/html;charset=gb2312 "%>
<%@ page language= "java " import= "java.sql.* "%>
<html>
<head>
</head>
<body>
<% String id=request.getParameter( "id ");id = new String(id.getBytes( "ISO8859_1 "), "gb2312 ");%>
<%=id%>
<%
Class.forName( "org.gjt.mm.mysql.Driver ").newInstance();
String url = "jdbc:mysql://localhost:3306/paper?useUnicode=true&characterEncoding=gbk ";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
String sql = "select * from student where sname= ' "+id+ " ' ";
ResultSet rs=stmt.executeQuery(sql);
String sql2= " ";
sql2 = rs.getString(4);%>
<input type = "text " name = "textname " value = " <%=sql2%> "> <br> <br>
<%rs.close();
stmt.close();
conn.close();
%> <input type = "text " name = "textname " value = " <%=sql2%> "> <br> <br>
</body>
</html>
------解决方案--------------------String sql2= " ";
sql2 = rs.getString(4);%>
==========
String sql2= " ";
if (rs.next()) {
sql2 = rs.getString(4);%>
}