当前位置: 技术问答>java相关
关于sql的问题,我刚学,不知道那里错了,帮忙看看,不胜感谢!
来源: 互联网 发布时间:2015-02-15
本文导语: 我的一个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+ "就不会报错,并且数据库的东西都显示!
请问这是为什么呀?谢谢。
我是初学者,不大会,请告诉我,谢谢!
|
你把unit_name="+a+"改为unit_name='"+a+"'试试!!
|
你试试:
if(unit_name==a){}
if(unit_name==a){}