Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

multi column foreign keys

410964Dec 11 2003 — edited Dec 18 2003
Hello people,

I've just started playing with Oracle, and am having problems getting foreign keys, when they have multiple columns.

I've created a couple of tables like :
CREATE TABLE Address (
First_Name varchar(50),
Last_Name varchar(50),
Address varchar(50),
PRIMARY KEY (First_Name, Last_Name),
FOREIGN KEY (First_Name, Last_Name) REFERENCES Student (First_Name, Last_Name)
);

CREATE TABLE Student (
Student_ID INT PRIMARY KEY,
First_Name varchar(50),
Last_Name varchar(50),
UNIQUE (First_Name, Last_Name)
);

And with the following code :

DatabaseMetaData meta = con.getMetaData ();
ResultSet primRS = meta.getPrimaryKeys (null, null, "ADDRESS");
while (primRS.next ())
System.out.println("column key == " +
primRS.getString("COLUMN_NAME"));

This returns the right information.
BUT :

DatabaseMetaData meta = con.getMetaData ();
ResultSet metaRS = meta.getImportedKeys(null, null, "ADDRESS");

And when I try to loop through metaRS, it seems empty.
Have I done something wrong ?

Mof.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2004
Added on Dec 11 2003
4 comments
2,925 views