We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Connection to MySQL using JDBC, get Constraints

JoshWegener
JoshWegener asked
on
Medium Priority
502 Views
Last Modified: 2010-08-05
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
Comment
Watch Question

Strictly in JDBC, only thing you can get might be ResultSetMetaData.isNullable().
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Any examples? I have tryed to get at the Information_Schema before with no luck...

Author

Commented:
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

Commented:
try

SHOW CREATE TABLE table_name;

Commented:
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.

Commented:
try SHOW INNODB STATUS ;

It should show the constraints or the alter table scripts.

Let me know if it works

Commented:
or the SHOW TABLE STATUS;

Author

Commented:
SHOW INNODB STATUS and the SHOW TABLE STATUS did not show me the constraints
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.