`
shukuiyan
  • 浏览: 413271 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

You have an error in your SQL syntax; check the manual that corresponds to your

阅读更多

 

the below code runs error:"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 '?'"

 

String sql="select * from lc_serverinfo where server_ID=?";

PreparedStatement ps=con.prepareStatement(sql);

ps.setInt(1,serverinfoid);

ResultSet rs=ps.executeQuery(sql);//ps.executeQuery(sql)......it is a boring error.....

 

 

it should be:

 

 

String sql="select * from lc_serverinfo where server_ID=?";

PreparedStatement ps=con.prepareStatement(sql);

ps.setInt(1,serverinfoid);

ResultSet rs=ps.executeQuery();

 

vs.

 

Statement sta=con.createStatement();

String sql="select * frome table1;

ResultSet rs=sta.executeQuery(sql);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics