一些基础的关于java jdbc的程序代码
count = y / 5 + 1;
}
if (i < count) {
x = ((++i) - 1) * 5;
String sql = "select top "
+ x
+ " * from (select * from bbc where name not in(select top " + x + " name from bbc order by name)) as A ";
list = query(sql);
} else if (i >= count) {
list = null;
}
return list;
}
public static int queryCount() {
int count = 0;
Connection conn = DBConnection.getConnection();
String sql = "select count(*) from bbc";
Statement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
count = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return count;
}