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
...全文
148 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
从小就很呆 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+"'" 少单引号???
回复
科學信仰 2015-10-29
pps = con.prepareStatement(sql); 把这里的运行时sql拷贝出来手动去sql server中执行一下就知道了,列名无效
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-10-28 11:18
社区公告
暂无公告