× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Joe Sam Shirah wrote:

   Hi Franco,

   The short version is that with the Toolbox/JTOpen driver,
DatabaseMetaData.getPrimaryKeys() does not return key info for default DDS
created files.  It does work for a table created with SQL like:

CREATE TABLE JSTEMP/FTESTPK
(COL1 INT NOT NULL WITH DEFAULT,
COL2 INT NOT NULL WITH DEFAULT,
COL3 VARCHAR (30) NOT NULL WITH DEFAULT,
PRIMARY KEY (COL1, COL2))

   You can use getIndexInfo() and check for the table name with the
Toolbox/JTOpen driver.  Note that, just for fun, the Toolbox/JTOpen and
native drivers do different things.  For more information, see:

"Getting JDBC Metadata from legacy tables" at

http://dbforums.com/t661310.html

and

"Native JDBC Driver Does Not Return Primary Keys with getIndexInfo Method"
at

<
http://www-912.ibm.com/s_dir/slkbase.NSF/0/52fc5bbe726b0d3a86256f6b0058b955?OpenDocument




                                                        Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO       -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?            http://www.jguru.com/faq/Java400


----- Original Message ----- From: "Franco Biaggi" <fbiaggi@xxxxxxxxxx>
To: <JAVA400-L@xxxxxxxxxxxx>
Sent: Sunday, May 01, 2005 12:02 PM
Subject: JDBC DatabaseMetaData getPrimaryKeys





Hello,

is there any people that managed DatabaseMetaData getPrimaryKeys(...) to
work ?

I always receive an empty ResutSet.

Thanks for help.

--
--------------------------------------------------------------------------



Joe,
thanks for your answer,
already find a solution that returns only the unique keys (also in case of a logical file defining a unique key).
For info:


// Get the keys
System.out.println( "Catalog: " + getCatalog( ) + " Schema: " + getSchema( ) + " Table: " + getName( ) );
rs = dmd.getIndexInfo( getCatalog( ), getSchema( ), getName( ), true, true );
while ( rs.next( ) ) {
System.out.println(
" IndexName: " + rs.getString( "INDEX_NAME" ) + " Field: " + rs.getString( "COLUMN_NAME" ) +
" NonUnique: " + rs.getBoolean( "NON_UNIQUE" ) );
}





-- ----------------------------------------------------------------------------- *** This messages was scanned for malicious contents *** ----------------------------------------------------------------------------- Franco Biaggi CH-6807 Taverne


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.