Abdelaziz Dabebi
Abdelaziz Dabebi

Reputation: 1638

inserting a row in a MS access database

Geeks I don't know why this code doesn't work, it doesn't throw an exception but my access database is still the same and this row isn't added there I would be happy if you could help me, it only prints 1 as number f lines affected as I know but the data base is still the same.

    public void connect()
{
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String xx="jdbc:odbc:aaaaa";
        con = DriverManager.getConnection(xx);  
        st=con.createStatement();
        int i=st.executeUpdate("INSERT INTO Table1 VALUES ('aaaa','bbbbb',2014)"); 
        System.out.println(i);          
        st.close();

    } catch(Exception e)

        {System.out.print(e.toString());}           
    }

Upvotes: 1

Views: 56

Answers (1)

Leo
Leo

Reputation: 6570

just in case, try adding con.setAutoCommit(true); before the executeUpdate() and close the connection in the end

Upvotes: 1

Related Questions