我用的是sqlserver 现在就是不能显示数据。郁闷的很 可否给与指教。 String sql = "SELECT TOP ? * FROM (SELECT TOP ? * FROM booktab) DERIVEDTBL ORDER BY bookid"; 我这样填充参数: psta.setInt(2, startIndex); psta.setInt(1, count); res = psta.executeQuery();是不是没有问题啊。
写个Main函数,查一下,不就知道了
operator.java import java.util.Map; import java.util.List; import dzpmis.util.*;public class Operator { private static int recordPerPage = ApplicationUtil.recordPerPage; //动态SQL private static String sqlNumber = ""; //留出接口设置每页显示多少条记录 public static void setRecordPerPage(int number) { recordPerPage = number; } public Operator() { } //获得所有记录集(只查询一页记录) public static List getRecords(int startIndex) { String sql = "SELECT TOP ? * FROM (SELECT TOP 5 * FROM booktab) DERIVEDTBL ORDER BY bookid"; sqlNumber = "select count(*) from booktab"; return DBUtil.executeQuery(sql, startIndex, recordPerPage); } //DBUtil.executeQuery中进行填充参数。 //获得表中所有记录的条数 public static int getRecordsNumber() { return DBUtil.executeQuery(sqlNumber); } public static void main(String[] args) { Operator operator = new Operator(); ..... 我改怎么写呢。
}
}
此句刚才写错了。 String sql = "SELECT TOP ? * FROM (SELECT TOP ? * FROM booktab) DERIVEDTBL ORDER BY bookid";
现在就是不能显示数据。郁闷的很
可否给与指教。
String sql = "SELECT TOP ? * FROM (SELECT TOP ? * FROM booktab) DERIVEDTBL ORDER BY bookid";
我这样填充参数:
psta.setInt(2, startIndex);
psta.setInt(1, count);
res = psta.executeQuery();是不是没有问题啊。
import java.util.Map;
import java.util.List;
import dzpmis.util.*;public class Operator { private static int recordPerPage = ApplicationUtil.recordPerPage;
//动态SQL
private static String sqlNumber = ""; //留出接口设置每页显示多少条记录
public static void setRecordPerPage(int number) {
recordPerPage = number;
} public Operator() {
} //获得所有记录集(只查询一页记录)
public static List getRecords(int startIndex) {
String sql = "SELECT TOP ? * FROM (SELECT TOP 5 * FROM booktab) DERIVEDTBL ORDER BY bookid";
sqlNumber = "select count(*) from booktab";
return DBUtil.executeQuery(sql, startIndex, recordPerPage);
}
//DBUtil.executeQuery中进行填充参数。 //获得表中所有记录的条数
public static int getRecordsNumber() {
return DBUtil.executeQuery(sqlNumber);
}
public static void main(String[] args) {
Operator operator = new Operator();
.....
我改怎么写呢。
}
}
String sql = "SELECT TOP ? * FROM (SELECT TOP ? * FROM booktab) DERIVEDTBL ORDER BY bookid";