eclipse报错MySQL server version for the right syntax to use near
报错信息为:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverver...
报错信息为:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select user_id2 as user_id from friend where user_id1 = '111')OR user_id IN (sel' at line 1
sql语句为:String sql = "select user_id, user_pwd, user_name, user_icon FROM user WHERE user_id"
+ "IN (select user_id2 as user_id from friend where user_id1 = ?)"
+ "OR user_id IN (select user_id1 as user_id from friend where user_id2 = ?)";
求解是哪里出了问题 展开
sql语句为:String sql = "select user_id, user_pwd, user_name, user_icon FROM user WHERE user_id"
+ "IN (select user_id2 as user_id from friend where user_id1 = ?)"
+ "OR user_id IN (select user_id1 as user_id from friend where user_id2 = ?)";
求解是哪里出了问题 展开
2个回答
展开全部
最好是能够有代码行的错误信息,就是说明你哪行代码对应的SQL语句出的问题,这样更好分析。
根据代码,目测可能有以下问题:
1
pstmt=conn.prepareStatement("select username from user where username=?");
pstmt.setString(1,shopname);
这段中如果shopname是null的话执行结果可能有问题,所以最好先判断以下shopname是否非null。
2
String sql ="insert into shop(shopname,price,number,brand,date) values ('"+shopname+"','"+price+"','"+number+"','"+brand+",'"+date+"');";
这个段中是否都是字符型?,还有就是'"+brand+",少了一个引号
根据代码,目测可能有以下问题:
1
pstmt=conn.prepareStatement("select username from user where username=?");
pstmt.setString(1,shopname);
这段中如果shopname是null的话执行结果可能有问题,所以最好先判断以下shopname是否非null。
2
String sql ="insert into shop(shopname,price,number,brand,date) values ('"+shopname+"','"+price+"','"+number+"','"+brand+",'"+date+"');";
这个段中是否都是字符型?,还有就是'"+brand+",少了一个引号
启帆信息
2024-11-19 广告
2024-11-19 广告
启帆信息是英伟达中国区代理商,原厂授权代理,提供全面的软件技术解决方案以及NVIDIA以太网产品、交换机等产品,欢迎前来咨询!...
点击进入详情页
本回答由启帆信息提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |