Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

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
0
JoshWegener
Asked:
JoshWegener
  • 5
  • 4
  • 3
1 Solution
 
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
 
JoshWegenerAuthor Commented:
Any examples? I have tryed to get at the Information_Schema before with no luck...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now