当前位置: 技术问答>?:jsp的运行机制或运行原理是如何的,who能给我一个解释,谢谢!
iis7站长之家
jsp的sql问题,帮忙看看(jsp人少),谢谢!
来源: 互联网 发布时间:2015-02-14
本文导语: 我的一个jsp文件其中一段如下: 单元表 ... 运行提示:500 Servlet Exception java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server](s.W 'by' D?碚? at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031) at sun.jdbc.odbc.Jdbc...
我的一个jsp文件其中一段如下:
单元表
...
运行提示:500 Servlet Exception
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server](s.W
'by' D?碚?
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:314)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:229)
at _jsp._wangzhan._try__jsp._jspService(G:javaresinresin-2.0.2docjspwangzhantry.jsp:22)
at com.caucho.jsp.JavaPage.service(JavaPage.java:87)
at com.caucho.jsp.JavaPage.subservice(JavaPage.java:81)
at com.caucho.jsp.Page.service(Page.java:474)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:166)
at com.caucho.server.http.Invocation.service(Invocation.java:277)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.2 (built Mon Aug 27 16:52:49 PDT 2001)
好象是数据库这里有问题:Rst=Stmt.executeQuery("select unit_name from unit where unit_name=" +a+ "order by unit_id");
要是不加where unit_name=" +a+ "就不会报错,并且数据库的东西都显示!
请问这是为什么呀?谢谢。
我是初学者,不大会,请告诉我,谢谢!
单元表
...
运行提示:500 Servlet Exception
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server](s.W
'by' D?碚?
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:314)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:229)
at _jsp._wangzhan._try__jsp._jspService(G:javaresinresin-2.0.2docjspwangzhantry.jsp:22)
at com.caucho.jsp.JavaPage.service(JavaPage.java:87)
at com.caucho.jsp.JavaPage.subservice(JavaPage.java:81)
at com.caucho.jsp.Page.service(Page.java:474)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:166)
at com.caucho.server.http.Invocation.service(Invocation.java:277)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.2 (built Mon Aug 27 16:52:49 PDT 2001)
好象是数据库这里有问题:Rst=Stmt.executeQuery("select unit_name from unit where unit_name=" +a+ "order by unit_id");
要是不加where unit_name=" +a+ "就不会报错,并且数据库的东西都显示!
请问这是为什么呀?谢谢。
我是初学者,不大会,请告诉我,谢谢!
|
SQL语句出错,改那句为:
Rst=Stmt.executeQuery("select unit_name from unit where unit_name='" +a+ "' order by unit_id");
记住字符串的两边要加单引号
Rst=Stmt.executeQuery("select unit_name from unit where unit_name='" +a+ "' order by unit_id");
记住字符串的两边要加单引号
|
你的JDBC驱动加载了吗?建立数据库连接对象了吗?