vendredi 26 février 2016

Simple Java SQLite Not Found

I'm attempting to insert data into a SQLite database previously created in Python. The database and table exists already but I continue to receive the error in Java that the table does not exist when it does. Any ideas would be appreciated. Perhaps I should abandon Python altogether and create the tables through Java? Please let me know if you need more information. Perhaps the foreign keys have something to do with this?

Java:

try
{
    Class.forName("org.sqlite.JDBC");
    connection = DriverManager.getConnection("jdbc:sqlite:ic_.db");
    PreparedStatement statement = connection.prepareStatement(
        "INSERT INTO I_Table (DateTime, Name, D_ID, H_ID, S_ID, E_ID, S_ID, M_ID) "
        + "VALUES(?,?,?,?,?,?,?,?)");
    statement.setString(1,"");
    statement.setString(2, "");
    statement.setInt(1, 1);
    statement.setInt(0, 0);
    statement.setInt(0, 0);
    statement.setInt(0, 0);
    statement.setInt(0, 0);
    statement.setInt(0, 0);
    statement.executeUpdate();

    connection.commit();
} 
catch (Exception e)
{
    System.out.println(e.toString());
}

Python:

create table I_Table (
    I_ID INTEGER PRIMARY KEY,
    DateTime INTEGER,
    Name TEXT,
    D_ID INTEGER,
    H_ID INTEGER,
    S_ID INTEGER,
    E_ID INTEGER,
    S_ID INTEGER,
    M_ID INTEGER,
    FOREIGN KEY(D_ID) REFERENCES D(D_ID),
    FOREIGN KEY(H_ID) REFERENCES H(H_ID),
    FOREIGN KEY(S_ID) REFERENCES S(S_ID),
    FOREIGN KEY(E_ID) REFERENCES E(E_ID),
    FOREIGN KEY(S_ID) REFERENCES SC(S_ID),
    FOREIGN KEY(M_ID) REFERENCES M(M_ID)
);

Aucun commentaire:

Enregistrer un commentaire