so i have 2 tables here

    CREATE TABLE tblAcctPrd (
    strAPCode VARCHAR(50) NOT NULL,
    datAPStartDate DATE NOT NULL,
    datAPEndDate DATE NOT NULL,
    PRIMARY KEY (strAPCode)
    )Engine=InnoDB;

which is the parent table and

    CREATE TABLE tblEntry ( <----the child table
    strEntCode VARCHAR(50) NOT NULL,
    datEntDate DATE NOT NULL,
    strEntType VARCHAR(50) NOT NULL,
    strEntDesc TEXT,
    dblEntAmount DOUBLE NOT NULL,
    strAPEntCode VARCHAR(50) NOT NULL,
    FOREIGN KEY (strAPEntCode) REFERENCES tblAcctPrd (strAPCode) ON DELETE RESTRICT ON UPDATE CASCADE,
    PRIMARY KEY(strEntCode)
    )Engine=InnoDB; 

the preparedstatements for these 2 are on a separate class, tblAcctPrd is for the first page of the gui in java and then when entering all the data at the 2nd page of gui will be recorded in the tblEntry, so the problem here is that it should have only one strAPCode for many strEntCode but I don't know how to do it, also after entering from the first page, all the data that i entered is not recorded on the tblentry

also an error like this show up : strEntCode doesn't have default value error mysql in java when i enter from the java gui page that records to tblAcctPrd

You just showed us the database schema, but you didn't show us how you enter it (i.e. SQL statement used in preparing). What is your code?

PS: The data entry is simple.
PSS: The error is straight forward. It meant you were trying to INSERT a record without specifying strEntCode value. The column in the table is set to NOT NULL which means you MUST provide a value of the column everytime you attempt to do an INSERT. If the error appears while you were entering data for another table, you need to look in your code.

Edited 1 Year Ago by Taywin

This article has been dead for over six months. Start a new discussion instead.