简体   繁体   中英

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());}           
    }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM