public int getCount() {
int count = 0;
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select count(*) from table_name";
try {
con=this.getConnection();
if (con!=null) {
ps=con.prepareStatement(sql);
rs=ps.executeQuery();
if(rs.next()) {
count=rs.getInt(1);
System.out.println("count:"+count);
}
}
} catch (Exception e) {
// TODO: handle exception
}
return count;
}
int count = 0;
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select count(*) from table_name";
try {
con=this.getConnection();
if (con!=null) {
ps=con.prepareStatement(sql);
rs=ps.executeQuery();
if(rs.next()) {
count=rs.getInt(1);
System.out.println("count:"+count);
}
}
} catch (Exception e) {
// TODO: handle exception
}
return count;
}