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
LVL 1
JoshWegenerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

actonwangCommented:
Strictly in JDBC, only thing you can get might be ResultSetMetaData.isNullable().
0
actonwangCommented:
But in MySQL, you can use Information_Schema Table_Constraints Table to get all information through JDBC

refer to this:
http://dev.mysql.com/doc/refman/5.0/en/table-constraints-table.html

Enjoy :)
Acton
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoshWegenerAuthor Commented:
Any examples? I have tryed to get at the Information_Schema before with no luck...
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

JoshWegenerAuthor Commented:
BTW I am usting

MySQL 4.0.24-nt
0
actonwangCommented:
Unforunately, information_schema table was introduced after mySql 5.0. Prior to it, you'd have to use Show only in mysql client.
0
actonwangCommented:
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
0
mrigankCommented:
try

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

It should show the constraints or the alter table scripts.

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

0
JoshWegenerAuthor Commented:
SHOW INNODB STATUS and the SHOW TABLE STATUS did not show me the constraints
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.