Zu dieser Karteikarte gibt es einen kompletten Satz an Karteikarten. Kostenlos!
37
Anzahl der Zeilen herausfinden
SQL
Statement s = cd.createStatement();
ResultSet r = s.executeQuery("SELECT COUNT(*) AS rowcount FROM TableName");
r.next(); //immer eins weiter, da sonst null
int count = r.getInt("rowcount");
r.close();
System.out.println("MyTable has " + count + " row(s).");
COUNTER
int counter =0;
while (rset.next())
{
counter ++
}
System.out.println("MyTable has " + counter + " row(s).");
Cursor
rs.last();
int rows = rs.getRow();
System.out.println("MyTable has " + rows+ " row(s).");
Statement s = cd.createStatement();
ResultSet r = s.executeQuery("SELECT COUNT(*) AS rowcount FROM TableName");
r.next(); //immer eins weiter, da sonst null
int count = r.getInt("rowcount");
r.close();
System.out.println("MyTable has " + count + " row(s).");
COUNTER
int counter =0;
while (rset.next())
{
counter ++
}
System.out.println("MyTable has " + counter + " row(s).");
Cursor
rs.last();
int rows = rs.getRow();
System.out.println("MyTable has " + rows+ " row(s).");