I'm trying to create a table and insert some data into it using Java 8, HSQLDB 2.4.0 working through Eclipse Neon.I keep getting the following error:
"integrity constraint violation: NOT NULL check constraint; SYS_PK_10091 table: TRANSACTIONS column: ID"
Here's my code:
CREATE TABLE IF NOT EXISTS TRANSACTIONS ( tabKey IDENTITY PRIMARY KEY, " + "transaction_location varchar(20) NOT NULL, " + "account_number varchar(40) NOT NULL, " + "transaction_type varchar(20) NOT NULL, " + "account_balance varchar(20) NOT NULL, " + "transaction_amount varchar(20) NOT NULL, " + "out_of_network_charge varchar(5) NOT NULL, " + "new_account_balance varchar(20) NOT NULL, " + "date_time_stamp varchar(40) NOT NULL, " + "ip_address varchar(20) NOT NULL, "
+ "port_number varchar(20) NOT NULL )"
Here's my insert code:
String insert_string = "INSERT INTO TRANSACTIONS (transaction_location, account_number, transaction_type, account_balance, transaction_amount, out_of_network_charge, new_account_balance, date_time_stamp, ip_address, port_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; psInsert = conn.prepareStatement(insert_string); psInsert.setString(1, transaction.getTransLocation()); psInsert.setString(2, transaction.getAccountNumber()); psInsert.setString(3, transaction.getTransType()); psInsert.setString(4, transaction.getAccountBalance()); psInsert.setString(5, transaction.getTransAmount()); psInsert.setString(6, transaction.getOutOfNetworkCharge()); psInsert.setString(7, transaction.getNewBalance()); psInsert.setString(8, transaction.getDateTime()); psInsert.setString(9, transaction.getNodeIpAddress()); psInsert.setString(10, transaction.getNodePortNumber()); psInsert.executeUpdate();
conn.commit();
Am I doing something wrong?
Customer support service by UserEcho
I'm trying to create a table and insert some data into it using Java 8, HSQLDB 2.4.0 working through Eclipse Neon.
I keep getting the following error:
"integrity constraint violation: NOT NULL check constraint; SYS_PK_10091 table: TRANSACTIONS column: ID"
Here's my code:
CREATE TABLE IF NOT EXISTS TRANSACTIONS ( tabKey IDENTITY PRIMARY KEY, "
+ "transaction_location varchar(20) NOT NULL, "
+ "account_number varchar(40) NOT NULL, "
+ "transaction_type varchar(20) NOT NULL, "
+ "account_balance varchar(20) NOT NULL, "
+ "transaction_amount varchar(20) NOT NULL, "
+ "out_of_network_charge varchar(5) NOT NULL, "
+ "new_account_balance varchar(20) NOT NULL, "
+ "date_time_stamp varchar(40) NOT NULL, "
+ "ip_address varchar(20) NOT NULL, "
+ "port_number varchar(20) NOT NULL )"
Here's my insert code:
String insert_string = "INSERT INTO TRANSACTIONS (transaction_location, account_number, transaction_type, account_balance, transaction_amount, out_of_network_charge, new_account_balance, date_time_stamp, ip_address, port_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
psInsert = conn.prepareStatement(insert_string);
psInsert.setString(1, transaction.getTransLocation());
psInsert.setString(2, transaction.getAccountNumber());
psInsert.setString(3, transaction.getTransType());
psInsert.setString(4, transaction.getAccountBalance());
psInsert.setString(5, transaction.getTransAmount());
psInsert.setString(6, transaction.getOutOfNetworkCharge());
psInsert.setString(7, transaction.getNewBalance());
psInsert.setString(8, transaction.getDateTime());
psInsert.setString(9, transaction.getNodeIpAddress());
psInsert.setString(10, transaction.getNodePortNumber());
psInsert.executeUpdate();
conn.commit();
Am I doing something wrong?