小白--Java JDBC 连接mysql数据库

chicheese 2017-06-05 08:14:11
在连接mysql数据库时遇到这样的情况

主人信息列表
编号 姓名 元宝
[Master [id=0, loginid=0, pwd=666666, money=100, status=有效],
Master [id=1, loginid=0, pwd=123456, money=100, status=有效],
Master [id=2, loginid=0, pwd=123456, money=10000, status=有效]]

java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '',pwd='123456',money='100',m_status='鏈夋晥 where id=2' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1224)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2244)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2192)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1259)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1205)
at chapter1101.MasterManager.updateMaster(MasterManager.java:150)
at chapter1101.TestA.main(TestA.java:21)
...全文
482 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Amo_lt 2017-06-09
  • 打赏
  • 举报
回复
你插入的状态字符串或者数字乱码了。。应该是你数据库设计那里编码选错了。。
我爱娃哈哈 2017-06-07
  • 打赏
  • 举报
回复
数据都乱码了 先解决乱码问题吧
丄whistle 2017-06-07
  • 打赏
  • 举报
回复
引用 5 楼 qq_37848441 的回复:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '',pwd='123456',money='100',m_status='鏈夋晥 where id=2' at line 1"这里有问题,你把你的sql语句放到数据库试试,也报错,修改一下
对,应该是sql语句出了错误。
20170421w 2017-06-06
  • 打赏
  • 举报
回复
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '',pwd='123456',money='100',m_status='鏈夋晥 where id=2' at line 1"这里有问题,你把你的sql语句放到数据库试试,也报错,修改一下
110成成 2017-06-06
  • 打赏
  • 举报
回复
m_status='鏈夋晥 where id=2' 这里有问题吧
qq_23712055 2017-06-06
  • 打赏
  • 举报
回复
可能是SQL语句有问题吧
pingguojuzi123 2017-06-06
  • 打赏
  • 举报
回复
都乱码了,修改一下编码格式在提交给数据库,UTF-8
podd 2017-06-06
  • 打赏
  • 举报
回复
检查下SQL,编码有问题只是查不出来数据,并不会报SQL的错误
  • 打赏
  • 举报
回复
这一看就是编码没设置好,检查下编码问题吧骚年
墨笙弘一 2017-06-05
  • 打赏
  • 举报
回复
把你的SQL贴出来
chicheese 2017-06-05
  • 打赏
  • 举报
回复
求大神请教一下?

81,114

社区成员

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

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