Link to home
Start Free TrialLog in
Avatar of JoshWegener
JoshWegener

asked on

Connection to MySQL using JDBC, get Constraints

Connection to MySQL using JDBC, get Constraints

How can I get the Constraints for each table? I am created a converter program that takes a mysql database and converts it into a FireBird database. The program connects to MySQL using JDBC, and creats the SQL query needed to create the same table in fireBird... I have got every thing but the Constraints.... How can I get them?

Thanks
Josh Wegener
Avatar of Acton Wang
Acton Wang
Flag of United States of America image

Strictly in JDBC, only thing you can get might be ResultSetMetaData.isNullable().
ASKER CERTIFIED SOLUTION
Avatar of Acton Wang
Acton Wang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JoshWegener
JoshWegener

ASKER

Any examples? I have tryed to get at the Information_Schema before with no luck...
BTW I am usting

MySQL 4.0.24-nt
Unforunately, information_schema table was introduced after mySql 5.0. Prior to it, you'd have to use Show only in mysql client.
hmm..

Do you still have script left or you can dump out all creat table statements. You can parse that script to find out all constraints.
Might be a way to go...

Acton
try

SHOW CREATE TABLE table_name;
It shall give the primary key constraints
As I said, you can not do it inside JDBC only in mysql client,  you might parse the script to get the informaiton.
try SHOW INNODB STATUS ;

It should show the constraints or the alter table scripts.

Let me know if it works
or the SHOW TABLE STATUS;

SHOW INNODB STATUS and the SHOW TABLE STATUS did not show me the constraints