1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public static int Retourne_Nb_lig(){
int nbl=0;
String url = "jdbc:h2:pgs";
String sql = null;
Connection con = null;
try {Class.forName("org.h2.Driver");
con = DriverManager.getConnection(url,"root","pass");
sql = "SELECT * FROM TEST";
Statement statement = con.createStatement();
ResultSet resultat = statement.executeQuery(sql);
while (resultat.next()) {
nbl++;
}
}
catch(Exception e) { System.out.println("Exception19"); }
finally {
try {con.close();}
catch(SQLException e) {e.printStackTrace();}
}
return nbl;
} |