This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to create a java component. I want to get all the constraints set for a database table. I am able to get the primary key constraint,but how to get the check constraints? Does java hae any api to get all the check constraints available on a table?
In any case, as Sripathi mentioned, there is nothing in the javadocs (that I could find) that returns the check constraints for database table columns. Perhaps you could provide some code that demonstrates how to do this?
Presuming your database supports this you can query its meta data to get constraints. For example in SQL Server you might write:
As I think you've also noticed, you can get Primary Key (and Foreign Key) constraints in a database independent way using DatabaseMetaData's methods. [ July 13, 2005: Message edited by: Paul Sturrock ]
yes,there is nothing in the Java api that can give the constraints set on a table. I have already used the DatabasemetaData and am able to get the primary keys, foriegn keys. But what I need is the unique keys and constraints in the table. The only way I see now is to query the system catalog tables and get the information needed. But that would make the component database dependent which is not what I need.
I was looking at the eclipse api. There is something called as rdb component in eclipse where they have all the methods that I need.