I want to get the actual created Primary Key. I need it instantly for another Method but it returns an error. But it returns a SQLE. Ive no idea wheres my Mistake. I hope i gave you enaugh information. (The System.out.println(id) is just for me to check if it returns the right PrimaryKey)
CreateTable:
CREATE TABLE "MitarbeiterInfo" ("Vorname" TEXT, "Nachname" TEXT, "Geburtsdatum" CHAR, "Wohnadresse" TEXT, "Postleitzahl" TEXT, "Eintrittsdatum" CHAR, "Handynummer" TEXT, "Email" TEXT, "ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL )
GuiClass:
public void actionPerformed(ActionEvent e) {
new Datenbank().mitarbeiterHinzufügen(
textField.getText(),textField_1.getText(),textField_2.getText(),textField_3.getText(),
textField_4.getText(),textField_5.getText(),textField_6.getText(),textField_7.getText());
refreshTable();
}
DatabaseClass:
public void mitarbeiterHinzufügen(String v, String n, String g, String w, String p, String e, String h, String email){
conn=Datenbank.dbConnector();
try {
String query="insert into MitarbeiterInfo (Vorname,Nachname,Geburtsdatum,Wohnadresse,Postleitzahl,Eintrittsdatum,Handynummer,Email,ID) values (?,?,?,?,?,?,?,?,?)";
PreparedStatement pst=conn.prepareStatement(query);
pst.setString(1, v);
pst.setString(2, n);
pst.setString(3, g);
pst.setString(4, w);
pst.setString(5, p);
pst.setString(6, e);
pst.setString(7, h);
pst.setString(8, email);
pst.execute();
String identitiy = "SELECT IDENTITY_VAL_LOCAL() FROM MitarbeiterInfo";
ResultSet rs = pst.executeQuery(identitiy);
rs.next();
int id = rs.getInt("1");
System.out.println(id);
JOptionPane.showMessageDialog(null, "Mitarbeiter hinzugefügt");
pst.close();
} catch (Exception b) {
b.printStackTrace();
}
}
That error ocurs:
java.sql.SQLException: not implemented by SQLite JDBC driver
at org.sqlite.Unused.unused(Unused.java:31)
at org.sqlite.PrepStmt.executeQuery(PrepStmt.java:596)
***at Datenbank.mitarbeiterHinzufügen(Datenbank.java:69)***
at GUI$3.actionPerformed(GUI.java:138)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)