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);

你可能感兴趣的:(You have an error in your SQL syntax; check the manual that corresponds to your)