Reputation: 243
SEVERE: null
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3109) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337) at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:287)
public Student_Registration() {
super("");
initComponents();
try {
//DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:student");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Check connectivity with database", "Error", 3);
}
}
//Insert data to Db
String insertinfo = "insert into student_info(name,dob,address,ten,twelve,sex,mail,mobile) values('" + txt_name.getText().toString() + "', '" + txt_dob.getText().toString() + "', '" + txt_add.getText().toString() + "', '" + txt_10.getText().toString() + "','" + txt_12.getText().toString() + "','" + cb_sex.getSelectedItem().toString() + "','" + txt_mail.getText().toString() + "','" + txt_mobile.getText().toString() + "')";
try {
Statement ist = con.createStatement();
ist.executeUpdate(insertinfo);
} catch (SQLException ex) {
Logger.getLogger(Student_Registration.class.getName()).log(Level.SEVERE, null, ex);
System.out.printf("" + insertinfo);
}
Upvotes: 0
Views: 2337
Reputation: 3679
Looks like this is just a file permission issue occuring with ODBC data sources.
MS says ;
This problem occurs if you try to edit a worksheet that is saved or opened as ReadOnly.
NOTE: ReadOnly is the default setting for an ODBC connection to Excel, with or without a data source name (DSN). Therefore, the user must always change that setting to edit data.
http://support.microsoft.com/kb/316475
You may check for read-only attribute in both db file and DSN settings.
To resolve this problem, use the following aproach:
If you are connecting through a DSN, follow these steps:
Upvotes: 1