問題出現: "java.sql.SQLException:@P0" 附近有錯誤,原因sql 不支持“select top ? from [table_name]” 這種語法
解決之道:
sql=“select top %s from [table_name]”;
sql=String.format(sql,"20");
舉一反三:
如有預處理的時候:select top %s * from [table_name] where userId<? and userage>?;
解決之道:
sql = select top %s * from [table_name] where userId<? and userage>?; sql = String.format(sql,20); PrepareStatem pst = con.getPrepareStatement(); pst.setint(1,100); pst.setInt(2,20); 。。。。。。。。。