MySQL Forums
Forum List  »  Newbie

please check code... simple SQL
Posted by: BHAVIN RAGHA
Date: March 08, 2012 01:03PM

i am using Netbeans and i have created a .sql file which has all my SlQ statementes. basically i am trying to use rs.updateString(); in my code but when i run the code it says... Result Set not updatable (referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.

so what I am trying to say are my sql statements right... have I defined my primary keys properly.
her is my code
CREATE TABLE Student
(studentId CHAR(10), firstName CHAR(15), degreeScheme CHAR(30), PRIMARY KEY (studentId));
CREATE TABLE Staff
(staffId CHAR(10), staffName CHAR(15), staffGrade CHAR(25), PRIMARY KEY (staffId));
CREATE TABLE ModuleT
(moduleId CHAR(10), moduleName CHAR(50), credits CHAR(2), PRIMARY KEY (moduleId));
CREATE TABLE Registered
(studentId CHAR(10), moduleId CHAR(10), PRIMARY KEY (studentId, moduleId), FOREIGN KEY (studentId) REFERENCES Student(studentId), FOREIGN KEY (moduleId) REFERENCES Module(moduleId));
CREATE TABLE Teaches
(staffId CHAR(10), moduleId CHAR(10), PRIMARY KEY (staffId, moduleId), FOREIGN KEY (staffId) REFERENCES Staff(staffId), FOREIGN KEY (moduleId) REFERENCES Module(moduleId));
--
DELETE FROM Student;
DELETE FROM Staff;
DELETE FROM ModuleT;
DELETE FROM Registered;
DELETE FROM Teaches;
--
INSERT INTO Student VALUES ('S10345', 'John Smith', 'BSc Computer Science');
INSERT INTO Student VALUES ('S10346', 'Sian Evans', 'BSc Computer Science');
INSERT INTO Student VALUES ('S10347', 'Sean Crossan', 'BSc Elec Engineering');
INSERT INTO Student VALUES ('S10348', 'Siobhan McChristy', 'BSc Mathematics');
--
INSERT INTO Staff VALUES ('E10010', 'Jim O’Donovan', 'Senior Lecturer');
INSERT INTO Staff VALUES ('E10011', 'Neil Batchelor', 'Reader');
INSERT INTO Staff VALUES ('E10012', 'Steve Marriott', 'Lecturer');
--
INSERT INTO ModuleT VALUES ('CS101', 'introduction to Computing', '10');
INSERT INTO ModuleT VALUES ('CS203', 'Data Structures and Algorithms', '10');
INSERT INTO ModuleT VALUES ('CS104', 'Computer Architecture', '10');
INSERT INTO ModuleT VALUES ('M101', 'Matthematics I', '20');
--
INSERT INTO Registered VALUES ('S10345', 'CS101');
INSERT INTO Registered VALUES ('S10346', 'CS203');
INSERT INTO Registered VALUES ('S10346', 'CS204');
INSERT INTO Registered VALUES ('S10347', 'CS204');
INSERT INTO Registered VALUES ('S10348', 'M101');
INSERT INTO Registered VALUES ('S10348', 'C101');
--
INSERT INTO Teaches VALUES ('E10010', 'CS101');
INSERT INTO Teaches VALUES ('E10011', 'CS203');
INSERT INTO Teaches VALUES ('E10012', 'CS204');
INSERT INTO Teaches VALUES ('E10010', 'CS204');
INSERT INTO Teaches VALUES ('E10011', 'M101');
INSERT INTO Teaches VALUES ('E10011', 'C101');
--
SELECT * FROM Student;
SELECT * FROM Staff;
SELECT * FROM ModuleT;
SELECT * FROM Registered;
SELECT * FROM Teaches;

Options: ReplyQuote


Subject
Written By
Posted
please check code... simple SQL
March 08, 2012 01:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.