How to get primay key constraint name from sql server using java -


suppose following table want primary key constraints name uapplication_pkey

create table application (   applicationid integer not null,   screatedby character varying(255),   screatedon timestamp without time zone,   sfwversion integer,   smodifiedby timestamp without time zone,   smodifiedon character varying(255),   stenantid character varying(255),   constraint uapplication_pkey primary key (applicationid) ) 

i have taken how exact "constraint name" sqlexception

but not able find solution.

you can use databasemetadata interface.

databasemetadata meta = connection.getmetadata(); 

example:

databasemetadata meta=conn.getmetadata(); rs= meta.gettables(null, null, tablename, new string[]{"table"}); rs=meta.getprimarykeys(null, null, tablename); while(rs.next()) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -