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.

Zugriff auf dbf (dBase)

Empfohlene Antworten

Veröffentlicht

Hallo,

ich möchte gerne über eine Java-Anwendung Daten in eine DBF-Datei schreiben.

Dazu nutze ich eine ODBC-Verbindung, da ich leider keinen kostenlosen JDBC-Treiber gefunden habe.

Wenn ich jetzt ca. 100 Zeilen mit einem INSERT INTO einfüge braucht er dafür 1-2 Minuten! Da ich aber bis zu 40.000 Zeilen einfügen muss ist dies nicht akzeptabel. Hab ihr vielleicht einen Tip für mich was ich falsch mache bzw. wie es schneller geht?



Connection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;DriverID=277;Exclusive=Yes;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;DefaultDir=c:\\Test");


PreparedStatement psArticle = connection.prepareStatement(" INSERT INTO artikel.dbf (LIDLNR,BEZ,PREIS,USTCODE,WARENGR,PFANDKZ,STATUSKZ,WAAGEKZ,TARAKZ,KARTONPLU,MENGE,KETTPLU,MODIFIED,GELOESCHT,KOLLIINHAL,SWWNR,REFUNDKZ,GLOBRABKZ,MINUSCODE,ABSCHRKZ,ALTERSKZ,STATUS,GEWICHTSKZ,VERKAUFSKZ,R_FILL) "

									+ " VALUES(?,?,?,?,?,?,0,?,?,'0000',1,?," + currentDate + ",false,1,'','1','1',?,'1','0',10,?,0,'') ");

HashSet<String> hsDoubleData = new HashSet<String>(1000);

for (Article article : ((ArticleTableModel) tblArticleExport.getModel()).getArticles()) {


	if (hsDoubleData.add(article.getNo())) {

		psArticle.setString(1, article.getNo());

		psArticle.setString(2, article.getDesc());

		psArticle.setFloat(3, new Float(article.getPrice()));

		psArticle.setString(4, article.getTax());

		psArticle.setString(5, article.getWareGroup());

		psArticle.setString(6, article.getDeposit());

		psArticle.setString(7, article.getScaleCode());

		psArticle.setString(8, article.getTaraCode());

		psArticle.setString(9, article.getKettPLU());

		psArticle.setString(10, article.getDeposit());

		psArticle.setByte(11, (byte) ((article.getWeightCode() == null || article.getWeightCode().equals("0")) ? 0 : 1));


		psArticle.addBatch();

	}				

}


psArticle.executeBatch();


Für jeden Tip wäre ich sehr dankbar.

Vielen Dank im Voraus!

ich würde executeBatch versuchsweise nicht nach 40.000 zeilen aufrufen, sondern nach z.b. 100, und dann ein clearBatch und 100 neue addBatch machen.

weiters würde ich nach jedem 100. INSERT eine feedbackzeile (oder einen simplem punkt) ausgeben lassen und allenfalls auch eine zeitmessung auf applikationsebene einbauen.

s'Amstel

Hi Amstelchen,

danke für deine schnelle Antwort! Bisher habe ich noch nicht versucht die 40.000 Datensätze einzufügen sondern ca. 100. Selbst ein einfacher delete auf alle Zeilen Dauert gut 1 Minute!

Und diese Zeiten sind doch nicht normal oder?

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.