ResultSet rs;
PreparedStatement ps;
Connection con;
public Attribute() {
try{
con = DriverManager.getConnection("jdbc:ucanaccess://D:/programming/myassignment/Database1.accdb");
System.out.println("Java is now connected to database");
}catch(Exception ex){
System.out.println(ex);
}
JButton btnAdd = new JButton("Add");
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
PreparedStatement pstmt = (PreparedStatement) con.prepareStatement("insert into table1(Attributes) values(?)");
pstmt.setString(1, textField.getText());
pstmt.executeUpdate();
pstmt.close();
}catch (Exception ex){
System.out.println(ex);
}
}
});
btnAdd.setBounds(152, 203, 89, 23);
contentPane.add(btnAdd);
This code is connecting to database but whenever i insert an attribute, it gives the above mentioned error.
this database is being used by two classes. first class will insert the class name into the ClassName column, then i will click on Add attribute button to open the above mentioned class. when i insert attribute in this and press the "Add" button, it gives the following error:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.7 integrity constraint violation: NOT NULL check constraint; SYS_CT_10359 table: TABLE1 column: CLASSNAME