executeBatch result immet mit Statement.SUCCESS_NO_INFO

Status
Nicht offen für weitere Antworten.

scabies

Mitglied
Hallo,

Ich versuche für mehrere Insert and Update Anweisung als Prepared Statement and als Batch Operation auszuführen. Ich habe executeBatch results immer den Werd -2. Ich habe mein sql Anweisung und connection kontrolliert aber es gab kein Fehler. Was kann das Problem sein?

MfG
 
M

maki

Gast
Wieso Problem?
-2 ist der int Wert der Konstante SUCCESS_NO_INFO, die dafür sorgt das es eben keine echten Rückgabewerte gibt wenn alles glatt läuft.
 

scabies

Mitglied
nach der Api für Statement Interface SUCCESS_NO_INFO constant ist;"indicating that a batch statement executed successfully but that no count of the number of rows it affected is available."
Aber für mein update and insert Anweisung wird nicht solche results erwartet.
 

scabies

Mitglied
Java:
#public void commit(OracleDataSource ds, List list) {
        if (list.isEmpty())
            return;
        Connection conn = null;
        try {
            conn = ds.getConnection();
            conn.setAutoCommit(false);
            String sql = ((Object[]) list.get(0))[0].toString();
            PreparedStatement p = null;

/**a ist a Object Array. Enthaelt das Statement and Parameter Objects. Bsp: new Object[]{
                        "update TABLE_X set DTDATE=?, SNAME=?, " +
                                "SINFO=? where SCODE=?",
                        new java.sql.Date(date.getTime()), name, info, code});
**/
            for (Object a : list) {
                Object[] args = (Object[]) a;  
                if (p == null || !sql.equals(args[0])) {
                    sql = args[0].toString();
                    if (p != null) {
                        p.executeBatch();
                        p.close();
                    }
                    p = conn.prepareStatement(sql);
                }
                for (int i = 1; i < args.length; i++)
                    p.setObject(i, args[i]);
                p.addBatch();
            }
            int[] ints = p.executeBatch();
//            for (int anInt : ints) {
//                System.out.println(anInt);
//            }
            conn.commit();
            conn.setAutoCommit(true);
            p.close();
            conn.close();
        }
        catch (Exception e) {
            logger.error(e);
        }
        finally {
            try {
                conn.close();
            } catch (Exception e) {
               logger.error(e);
            }
        }
    }
 
Zuletzt bearbeitet von einem Moderator:
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
S CSV Datein in DB übernehmen:PreparedStatement bzw executeBatch() zu langsam Datenbankprogrammierung 11
P MySQL PreparedStatement vs. StoredProcedure vs. executeBatch Datenbankprogrammierung 1
M werden executeBatch()-commandos automatisch commitet ? Datenbankprogrammierung 8
M executeBatch() - Inserts trotz Fehler weitermachen Datenbankprogrammierung 5
Thallius MySQL Warum gibt result verschiedene Datumsformate? Datenbankprogrammierung 1
D Datenbank result als Auswahliste im GUI anzeigen lassen Datenbankprogrammierung 0
C Derby/JavaDB result set closed Datenbankprogrammierung 3
D Hibernate CreateQuery ohne Result Datenbankprogrammierung 7
M Logikfrage: Auf zweites Result warten Datenbankprogrammierung 2
M MySQL JDBC Result abfangen Datenbankprogrammierung 7
J illegal operation on empty result set Datenbankprogrammierung 21
H com.mysql.jdbc.NotUpdatable: Result Set not updatable Datenbankprogrammierung 2
S Result Set in Charts ausgeben! Datenbankprogrammierung 7
P Problem mit Result-set Datenbankprogrammierung 13
zilti java.sql.SQLException: Before start of result set Datenbankprogrammierung 2
P Fehler: result-set zeigt auf null, aber warum Datenbankprogrammierung 4
P Operation not allowed after Result Set closed Datenbankprogrammierung 7
megachucky Problem mit: SQL Exception Before start of result set Datenbankprogrammierung 2
G How to put SQL query result into a file Datenbankprogrammierung 3
D result ausgabe in Html Tabelle Datenbankprogrammierung 10
K java.sql.SQLException: Before start of result set Datenbankprogrammierung 2

Ähnliche Java Themen

Neue Themen


Oben