[Microsoft][ODBC Microsoft Access 驱动程序] 字符串的语法错误 在查询表达式
org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/select1.jspatl...
org.apache.jasper.JasperException: An exception occurred processing JSP page /select1.jsp at line 20
20: ResultSet rs = stat.executeQuery(sql);
具体代码如下:
<%
String account = request.getParameter("xuehao");
account=new String(account.getBytes("ISO-8859-1"),"gb2312");
String name = request.getParameter("xingming");
name=new String(name.getBytes("ISO-8859-1"),"gb2312");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:School");
Statement stat = conn.createStatement();
String sql = "SELECT STUNO,STUNAME,STUSEX FROM T_STUDENT where STUNO is ' " +account +
" ' and STUNAME is ' " + name + " " ;
//String sql = "SELECT STUNO,STUNAME,STUSEX FROM T_STUDENT";
ResultSet rs = stat.executeQuery(sql);
System.out.println(sql);
System.out.println(rs);
%> 展开
20: ResultSet rs = stat.executeQuery(sql);
具体代码如下:
<%
String account = request.getParameter("xuehao");
account=new String(account.getBytes("ISO-8859-1"),"gb2312");
String name = request.getParameter("xingming");
name=new String(name.getBytes("ISO-8859-1"),"gb2312");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:School");
Statement stat = conn.createStatement();
String sql = "SELECT STUNO,STUNAME,STUSEX FROM T_STUDENT where STUNO is ' " +account +
" ' and STUNAME is ' " + name + " " ;
//String sql = "SELECT STUNO,STUNAME,STUSEX FROM T_STUDENT";
ResultSet rs = stat.executeQuery(sql);
System.out.println(sql);
System.out.println(rs);
%> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询