-
So ein abgeschlossenes reines Beispielprogramm leider nicht. Hier ein vereinfachtes Beispiel zum Export von AS/400 Daten, das echt im Einsatz war. Basiert auf dem Open Source Projekt Cameleon OSP. Dort sind dann die JDBC-Zugriffe in einer Klasse DataObject gekapselt.
Aber vielleicht hat ja noch jemand ein elementareres Beispiel...
/*
* Copyright (c) 2001 Christoph Mueller. All rights reserved.
* Public Domain sample code
*/
package various;
import de.must.wuic.*;
import de.must.dataobj.*;
import de.must.io.*;
import de.must.util.*;
import java.awt.*;
import java.sql.*;
public class PrExport extends ProgressFrame {
public PrExport() {
this.setTitle("AS/400-Daten exportieren");
setProgressMaximum(1000);
startThread();
}
protected void act() {
try {
Global.getInstance().createOrCheckConnections();
TextFile fileNames = new TextFile("fileNames.txt");
String fileName;
while (!isCanceled() && (fileName = fileNames.readLine()) != null) {
export(fileName);
}
}
catch(Exception e) {
e.printStackTrace();
}
finally {
Global.getInstance().closeMainConnection();
System.exit(0);
}
}
private void export(String tableName) {
System.out.println("Exporting " + tableName);
DirectDataObject bisDataObject = new DirectDataObject(Global.getInstance().getMainConne ction(), tableName);
Protocol output = new Protocol("outfiles\\" + tableName + ".txt");
bisDataObject.select("*");
int nbrOfColumns = bisDataObject.getColumnCount();
int limiter = 0;
int counter = 0;
while (!isCanceled() && bisDataObject.nextRow() /* & ++limiter <= 1000*/) {
setProgressValue(++counter);
setMessage("Exporting record " + counter + " of " + tableName);
// while (!isCanceled() && bisDataObject.nextRow()) {
String line = "";
for (int i = 0; i < nbrOfColumns; i++) {
if (i > 0) line += "|";
line += bisDataObject.getText(bisDataObject.getColumnName( i));
}
output.addEntry(line);
// System.out.println(line);
}
output.close();
bisDataObject.closeQuery();
}
}
/*
* Klasse Global
* Copyright (c) 2001 Christoph Mueller.
* Public Domain sample code
*/
package various;
import de.must.io.TextFile;
import de.must.middle.GlobalStd;
import de.must.dataobj.ConnectionHolder;
import de.must.dataobj.ConnectionSpecification;
public class Global extends GlobalStd {
private static Global instance;
public final static Global getInstance() {
if (instance == null) {
instance = new Global();
}
return instance;
}
protected ConnectionSpecification getActualConnectionSpecification() {
return new ConnectionSpecification("DBNAME", "DBUSER", "USERPWD");
}
}
Chr****** Müller
Similar Threads
-
By Christian.Hesse in forum NEWSboard Programmierung
Antworten: 3
Letzter Beitrag: 04-08-06, 10:04
-
By WPF in forum NEWSboard Java
Antworten: 1
Letzter Beitrag: 13-01-06, 17:32
-
By bode in forum NEWSboard Java
Antworten: 7
Letzter Beitrag: 02-09-05, 15:09
-
By burton007 in forum NEWSboard Java
Antworten: 8
Letzter Beitrag: 02-09-05, 15:08
-
By TARASIK in forum IBM i Hauptforum
Antworten: 6
Letzter Beitrag: 02-08-04, 08:27
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks