数据未插入Ms-Access

时间:2016-04-27 09:39:31

标签: java ms-access jdbc-odbc

我无法使用JDBC连接将JTextField的数据插入Ms-Access

private void addOperation()
{
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        System.out.println("\n Drivers are Properly Loaded");
        //String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "E:\\Employee\\Employee.mdb";
        String url="jdbc:odbc:ABC";
        con=DriverManager.getConnection(url);
        System.out.println("Connection Established");
        sql="insert into Emp(Reg_no, F_Name, M_Name, L_Name)values('"+r_no.getText()+"',"+t1.getText()+",'"+t2.getText()+"',"+t3.getText()+")";
        st=con.createStatement();
        st.executeUpdate(sql);

    }
}

0 个答案:

没有答案