一条select语句(包含like),直接在mysql里运行是好的,在jsp里运行出错?

zhouhouqu 2004-09-07 06:24:36
语句:
SELECT infoname,infovalues FROM truransysinfo WHERE infoname LIKE 'ANONYMITY_%'
错误提示(tomcat):
java.sql.SQLException: Illegal mix of collations (latin1_swedis
d (gb2312_chinese_ci,COERCIBLE) for operation 'like'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1518
at com.mysql.jdbc.ServerPreparedStatement.serverPrepare
atement.java:1439)
at com.mysql.jdbc.ServerPreparedStatement.<init>(Server
.java:150)
at com.mysql.jdbc.Connection.prepareStatement(Connectio
at com.mysql.jdbc.Connection.prepareStatement(Connectio
at bf_com.utils.DBConnect.common(DBConnect.java:63)
at org.apache.jsp.usrlogin_jsp._jspService(usrlogin_jsp
at org.apache.jasper.runtime.HttpJspBase.service(HttpJs
at javax.servlet.http.HttpServlet.service(HttpServlet.j
at org.apache.jasper.servlet.JspServletWrapper.service(
.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
95)
at org.apache.jasper.servlet.JspServlet.service(JspServ
at javax.servlet.http.HttpServlet.service(HttpServlet.j
at org.apache.catalina.core.ApplicationFilterChain.inte
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFi
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke
alve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(Sta
a:480)
at org.apache.catalina.core.ContainerBase.invoke(Contai

at org.apache.catalina.core.StandardContextValve.invoke
alve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(Sta
a:480)
at org.apache.catalina.core.ContainerBase.invoke(Contai

at org.apache.catalina.core.StandardContext.invoke(Stan
2422)
at org.apache.catalina.core.StandardHostValve.invoke(St
ava:180)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invo
rValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(E
ava:163)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(Sta
a:480)
at org.apache.catalina.core.ContainerBase.invoke(Contai

at org.apache.catalina.core.StandardEngineValve.invoke(
ve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPi
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(Sta
a:480)
at org.apache.catalina.core.ContainerBase.invoke(Contai

at org.apache.coyote.tomcat4.CoyoteAdapter.service(Coyo
9)
at org.apache.coyote.http11.Http11Processor.process(Htt
:828)
at org.apache.coyote.http11.Http11Protocol$Http11Connec
ssConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Poo
:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRun
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
...全文
164 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhouhouqu 2004-09-08
没错的
数据库里已经成功了
回复
GX198302 2004-09-08
数据类型看看
回复
zhouhouqu 2004-09-08
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gb2312_chinese_ci,COERCIBLE) for operation '='
回复
zhouhouqu 2004-09-08
private String sDBDriver = "org.gjt.mm.mysql.Driver";
private String sConnStr = "jdbc:mysql://localhost:3306/vod?useUnicode=true&characterEncoding=gb2312";
回复
zhouhouqu 2004-09-08
都没有,对了,我刚才又调试了另外一条语句
SELECT userid,truename,userstate,usermsg,prilevel,groupid,bandwidth FROM consumer WHERE username='user01' AND pwd='111111'
这个语句直接到数据库是可以的,但是放到jsp里就提示出错,说=号这里有问题,我把where条件都去掉就可以执行了
回复
xx_ch 2004-09-08
你先在LIKE 'ANONYMITY_%'这里做些改变测试测试吧,比如改成'ANONY%',唯一有可能出问题的就是这里了
回复
zhouhouqu 2004-09-08
高人呢,大家帮忙啊,现在还在试用期,不行的话就要挂了,帮忙啊
回复
zhouhouqu 2004-09-08
这个现象是不是连接应该已经建立好了,连接数据库应该没有问题吧,那为什么这个语句执行不了呢,我拿这个语句直接去mysql是可以执行的啊
回复
zhouhouqu 2004-09-08
strSql="SELECT userid,truename,userstate,usermsg,prilevel,groupid,bandwidth FROM consumer WHERE username='"+sUserName+"' AND pwd='"+sPassWord+"'";
conn=objDB.getConnection();
stmt=conn.createStatement();
System.out.println(conn+" "+stmt+" oooooooo");
System.out.println(strSql);
rst=stmt.executeQuery(strSql);
我输出看了一下
com.mysql.jdbc.Connection@9db992 com.mysql.jdbc.Statement@12f9bcd oooooooo
SELECT userid,truename,userstate,usermsg,prilevel,groupid,bandwidth FROM consume
r WHERE username='user01' AND pwd='111111'
在执行rst=stmt.executeQuery(strSql);语句时出现异常,郁闷中
回复
fightplane 2004-09-08
这种错误提示还是第一次看过
回复
wandou999 2004-09-08
1注意大小写
2.注意JSP中的写法
回复
zhouhouqu 2004-09-07
可是我没有中文啊,老是会有莫名其妙的问题出现
回复
bighappy 2004-09-07
字符集的问题,尝试这去设置mysql的encode字符集,是不是可以改成gb2312_chinese_ci
回复
zhouhouqu 2004-09-07
不会啊,而且这个别人在linux下用过的
我现在是windows2000
回复
Tasia 2004-09-07
可能是全角半角的问题?
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-07 06:24
社区公告
暂无公告