1Danke
ERLEDIGT
JA
JA
ANTWORTEN
2
2
ZUGRIFFE
306
306
EMPFEHLEN
-
Hi Leute,
unsere Aufgabe besteht darin, mehrere Tabellen mit Inhalt zu füllen. Ich kann allerdings nur bei der ersten Tabelle "branch" einen Erfolg verzeichnen. Die andere Tabelle wird einfach "übergangen". Bitte nicht über die Values wundern, das sind nur Platzhalter um die Länge der Variabeln auszufüllen !
Hier mal der Quellcode in Java :
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
import java.sql.*; import java.io.*; import java.util.Random; public class benchmark_functions { public static Connection verbindung(String user, String passwd) throws SQLException { String dburl = "jdbc:db2://localhost:50000/BENCH"; Connection conn = DriverManager.getConnection ( dburl , user, passwd); conn.setAutoCommit(false); return conn; } public static void fill_bench(Connection conn, int n, int i) { try { while(i<=n) { PreparedStatement stmt = conn.prepareStatement( "INSERT INTO BRANCHES (BRANCHID, BRANCHNAME, BALANCE, ADDRESS)" + "VALUES (" + i + ", 'aaaaaaaaaaaaaaaaaaaa' , 0, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"); stmt.executeUpdate(); i++; } conn.commit(); System.out.println("Daten erfolgreich eingetragen !"); } catch(SQLException e) { e.getMessage(); } } public static void fill_accounts(Connection conn, int n, int i) { try { while(i<=n) { PreparedStatement stmt = conn.prepareStatement( "INSERT INTO ACCOUNTS (ACCID, NAME, BALANCE, BRANCHID, ADDRESS)" + "VALUES (" + i + ", 'aaaaaaaaaaaaaaaaaa', 0 , 1 , 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"); stmt.executeUpdate(); i++; } System.out.println("Daten erfolgreich eingefügt !"); }catch(SQLException e) { e.getMessage(); } } public static void fill_tellers(Connection conn) { System.out.println("Verbindung hergestellt !"); } public static void fill_history(Connection conn) { System.out.println("Verbindung hergestellt !"); } public static void main(String[] args) throws IOException { try { System.out.println("Bitte N eingeben : "); int n = io.read_int(); int i = 1; benchmark_functions.fill_bench(benchmark_functions.verbindung(args[0], args[1]), n, i); benchmark_functions.fill_accounts(benchmark_functions.verbindung(args[0], args[1]), n, i); /* benchmark_functions.fill_tellers(benchmark_functions.verbindung(args[0], args[1])); benchmark_functions.fill_history(benchmark_functions.verbindung(args[0], args[1])); */ } catch (SQLException e) { e.printStackTrace(); } } }
cash rules everything around me
-
Moin AvS,
steht doch oben - nach dem INSERTen in die ACCOUNTS-Tabelle fehlt das COMMIT.
oder das "conn.commit();" um es mit Java zu sagen.
Und AutoCommit hast Du ja (richtigerweise) vorher abgeschalten.
Kein Commit, nix auf Pladde.
Keine Arme, keine Kekse..
Grüße
Biber
-
Autschn.
Danke
cash rules everything around me
Ähnliche Themen
-
SqlException beim Insert in MySQL DB mittels JDBC
Von XesperantoX im Forum JavaAntworten: 2Letzter Beitrag: 04.05.08, 12:54 -
SQL - INSERT INTO - nur einmal eintragen
Von Hattrix im Forum Relationale DatenbanksystemeAntworten: 4Letzter Beitrag: 22.11.06, 16:59 -
Bei nebeneinanderliegenden divs einmal Pixel und einmal Prozent möglich?
Von mofl im Forum CSSAntworten: 2Letzter Beitrag: 10.05.06, 12:24 -
JDBC- mehrere INSERT auf einmal
Von JoeBloggs im Forum JavaAntworten: 2Letzter Beitrag: 20.10.05, 21:38 -
Insert Into - Null Wert JDBC-ODBC
Von BladeNeo im Forum JavaAntworten: 1Letzter Beitrag: 28.04.05, 16:07





Zitieren
Login





