Note that there are some explanatory texts on larger screens.

plurals
  1. PONetbeans 7.0, entering values with composite primary key
    text
    copied!<p>I am working on a project with MySQL database Java GUI.</p> <p>This is my SQL script CREATE TABLE takenservice ( <code>ResvID</code> INT UNSIGNED NOT NULL, <code>ServID</code> INT UNSIGNED DEFAULT 0 NOT NULL, <code>ServUsedDate</code> DATETIME NOT NULL , <code>PayStat</code> VARCHAR(6) DEFAULT Unpaid NOT NULL, <code>ServRecBy</code> VARCHAR(7) NOT NULL, <code>PayRecBy</code> VARCHAR(7), <code>Quantity</code> SMALLINT DEFAULT 1 NOT NULL, PRIMARY KEY (<code>ResvID</code>, <code>ServID</code>, <code>ServUsedDate</code>)); Alter table takenservice add constraint foreign key (ResvId) references reservation (ResvID); Alter table takenservice add constraint foreign key (ResvId) references reservation (ResvID);</p> <hr> <p>I created the entity classes with Netbeans 7.0 and created 4 classes:</p> <p>Service Reservation ServiceTaken ServiceTakenPK</p> <p>but I cant enter values to the table and it gives me an error that I am trying to enter null values in as primary keys. </p> <p>I have found the bug actually in Netbeans forum which is <a href="http://netbeans.org/bugzilla/show_bug.cgi?id=105084" rel="nofollow">http://netbeans.org/bugzilla/show_bug.cgi?id=105084</a>. </p> <p>and accordingly I have added the following methods to the class ServiceTaken</p> <pre><code>public int getResvID() { return takenservicePK.resvID; } public int getServID() { return takenservicePK.servID; } public Date getServUsedDate() { return takenservicePK.servUsedDate; </code></pre> <p>upon inserting a new entry in the table I get this error :</p> <p>Error Code: 1048 Call: INSERT INTO takenservice (PayRecBy, ServRecBy, Quantity, PayStat, ServUsedDate, ResvID, ServID) VALUES (?, ?, ?, ?, ?, ?, ?) bind => [ddd, ddd, 0, ddd, null, null, null]</p> <hr> <p>What I can do to fix this ? Please help me with this I am running out of time =/</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload