Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Anzahl der Datensätze auslesen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich hab mal wieder ein Problem.

Ich versuch ohne stored procedures die Anzahl der Datensätze einer Datenbank- Tabelle auf einer JTextArea auszugeben.

couSQLA = "SELECT COUNT(*) FROM scott.language1";

rs4=stmt.executeQuery(couSQLA);

rs4.first();

couSQLB = "SELECT COUNT(*) FROM scott.language2";

rs5=stmt.executeQuery(couSQLB);

rs5.first();

jTextArea1.append("\n"+???????);

jTextArea1.append("\n"+???????);

Setz ich jetzt statt ??????? +rs4.getInt(0 oder 1 oder etc.) bekomm ich ne Fehler meldung.

Ich hab auch schon SELECT COUNT(*) AS anzahl FROM scott.language1 probiert und dann +anzahl geschrieben --> NullPointerException.

In dem ResultSet steht ja nur ein Integer Wert wie bekomm ich den da raus?

Sicher ganz einfach, aber als Newbie...

Danke im voraus.

Hi,

bist du sicher, das da ein Integer drin ist?

bekommst du mit:

Object getObject(int columnIndex)

Gets the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language

ein Object zurück? Lass dir das Object dann mal ausgeben.

Gruß Jaraz

Ich habs im SQL Worksheet probiert, der Wert ist ein Integer.

Ich hab mittlerweile die Lösung gefunden:

ResultSet rs4=null;

ResultSet rs5=null;

stmtA.execute("SELECT COUNT(*) FROM tab1");

rs4=stmtA.getResultSet();

rs4.next();

stmt.execute("SELECT COUNT(*) FROM tab2");

rs5=stmt.getResultSet();

rs5.next();

int countA = rs4.getInt("COUNT(*)");

int countB = rs5.getInt("COUNT(*)");

jTextArea1.append("\n--> Anzahl der Datensätze: "+countA+"\n");

jTextArea1.append("\n--> Anzahl der Datensätze: "+countB+"\n");

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.