Originariamente inviato da Hermiod
idAccount è di tipo INT(10) sul db e per l'inserzione uso questa funzione che ho testato e che riporta correttamente un valore intero
codice:
    int getAccountId(String username) {
        int id = -1;
        String query = "SELECT id FROM srt_accounts WHERE username='" + codificaApici(username) + "'";
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection(strConn, dbuser, dbpassword);
            stmt = conn.createStatement();
            rs = stmt.executeQuery(query);
            if (rs.next()) {
                id = rs.getInt(1);
            }
        } catch (SQLException e) {
            System.err.println(e.getLocalizedMessage());
        } finally {
            if (rs != null) { try { rs.close(); } catch (SQLException ignore) { System.err.println(ignore.getLocalizedMessage()); }}
            if (stmt != null) { try { stmt.close(); } catch (SQLException ignore) { System.err.println(ignore.getLocalizedMessage()); }}
            if (conn != null) { try { conn.close(); } catch (SQLException ignore) { System.err.println(ignore.getLocalizedMessage()); }}
        }
        return id;
    }
anche a me suona strano, ma se metto le commit e tutte e due le insert vanno a buon fine non mi compare l'errore se le metto ecco che risalta fuori
prova a stamparti a video l'id che provi ad inserire vedi cosa ottieni