问题出现: "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);
。。。。。。。。。