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 zeilen im ResultSet ermitteln?

Empfohlene Antworten

Hallo Zusammen,

hab ich eine möglichkeit zu ermitteln wieviel Zeilen das ResultSet enthält,

noch bevor ich anfange es einzulesen?

ich würde gerne vor der while(rs.next()) schleife ein Array erzeugen, dass

in der Schleife gefüllt wird, aber dazu müsste ich halt die Anzahl der Zeilen wissen.

Schon mal vielen Dank im Voraus.

Gruß

LordK

AFAIK geht das nicht, weil das ResultSet u.U. nicht alle Datensätze auf einmal mitbringt.

Aber wegen dem Array. Werf halt alles in eine ArrayList und hol Dir das Array mit toArray() oder toArray(Object[] o).

Peter

Danke für die Antwort.

Habs jetzt über ein Vector gelöst, schien mir die bessere Lösung zu sein.

Gruß

LordK

Prima, dass du dein Problem gelöst hast. Bei der Verwendung von Collections lohnt es sich aber mal kurz nachzudenken, welche die richtige ist.

This class [ArrayList] is roughly equivalent to Vector, except that it is unsynchronized

aus: http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html

Wenn der Zugriff auf die Collection nicht "synchronized" sein muss, ist die ArrayList schneller.

Grüsse TrueSun

Hatte es schon vor dem Posting mit nem Vector gelöst, aber ich werd mir dir ArrayList nochmal angucken. Danke für den Tip :)

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.