servlet跳转不成功显示错误[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]列名 'aaa' 无

qq_31642561 2015-10-28 11:18:18
servlet跳转后地址不对,op参数也没有传出去
错误信息
用户名:aaa
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]列名 'aaa' 无效。
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at com.wz.dao.UserinfoDao.huoqutishiwenti(UserinfoDao.java:72)
at com.wz.service.UserinfoService.huoqutishiwenti(UserinfoService.java:47)
at com.wz.servlet.UserinfoServlet.tishiwenti(UserinfoServlet.java:94)
at com.wz.servlet.UserinfoServlet.doPost(UserinfoServlet.java:73)
at com.wz.servlet.UserinfoServlet.doGet(UserinfoServlet.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)


sql代码
public String huoqutishiwenti(String username) throws SQLException {
System.out.println("用户名:"+username);
Connection con=DBUtil.getCon();
PreparedStatement pps;

ResultSet rs = null;
String sql=null;

sql="select tishiwenti from userinfo where username="+username+"";
pps = con.prepareStatement(sql);
rs=pps.executeQuery();
String wenti=null;
if(rs.next()){
wenti=rs.getString("tishiwenti");
}
DBUtil.putCon(con);

return wenti;
}

servlet代码
private void tishiwenti(HttpServletRequest request,
HttpServletResponse response) throws SQLException, IOException {
String username=request.getParameter("username");

this.setUis(new UserinfoService());
String tishiwenti=uis.huoqutishiwenti(username);
if(tishiwenti!=null){
response.sendRedirect("wangjimima2.jsp?op='"+tishiwenti+"'&username="+username);
}else{
System.out.println("dddddddddddddddddddddddfffffffffffffffffff");
}
}


数据库就一个表代码
CREATE TABLE [dbo].[userinfo] (
[userid] [int] IDENTITY (1, 1) NOT NULL ,
[username] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[password] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[zhenshiname] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[sex] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[jiguan] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[city] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[phone] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[email] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[tishiwenti] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[daan] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
...全文
189 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
从小就很呆 2015-11-02
  • 打赏
  • 举报
回复
看看sql什么问题
从小就很呆 2015-11-02
  • 打赏
  • 举报
回复
看看sql什么问题
从小就很呆 2015-11-02
  • 打赏
  • 举报
回复
看看sql什么问题
这个逗b 2015-11-02
  • 打赏
  • 举报
回复
sql?语句问题啊
这个逗b 2015-11-02
  • 打赏
  • 举报
回复
sql?语句问题啊
这个逗b 2015-11-02
  • 打赏
  • 举报
回复
sql?语句问题啊
yzsunlight 2015-11-01
  • 打赏
  • 举报
回复
把 sql="select tishiwenti from userinfo where username="+username+""; 写死 看下有没错
yzsunlight 2015-11-01
  • 打赏
  • 举报
回复
检查你的SQL语句,写死看下执行的什么SQL语句
apple__011 2015-10-30
  • 打赏
  • 举报
回复
sql="select tishiwenti from userinfo where username="+username+"";这句把单引号去掉试试 response.sendRedirect("wangjimima2.jsp?op='"+tishiwenti+"'&username="+username) 这句也把单引号去掉
iamguwei1983 2015-10-29
  • 打赏
  • 举报
回复
sql="select tishiwenti from userinfo where username="+username+""; ??? where username='"+username+"'" 少单引号???
dracularking 2015-10-29
  • 打赏
  • 举报
回复
pps = con.prepareStatement(sql); 把这里的运行时sql拷贝出来手动去sql server中执行一下就知道了,列名无效

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧