MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » February 2013

Re: Determining a file's primary key via JDBC?



fixed

On 08 Feb 2013 15:36, James H. H. Lampert wrote:
Two things, really.

First of all, can anybody direct me to any examples or tutorials on
how to find out what a file's primary key is, via JDBC?

http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/DatabaseMetaData.html

A ResultSet from the method getPrimaryKeys(String catalog, String schema, String table) which "Retrieves a description of the given table's primary key columns." As defined by interface DatabaseMetaData.

http://www.java2s.com/Code/Java/Database-SQL-JDBC/GetPrimaryKeyColumnFromATable.htm
"... Connection conn = ...
ResultSet rs = null;
DatabaseMetaData meta = conn.getMetaData();
// ... if you pass a table name in lowercase characters, it will not work. ...
rs = meta.getPrimaryKeys(null, null, "survey");
..."

And second, my understanding is that the SQL spec states that if you
don't specify anything about record sequencing in an SQL SELECT,
there is no guarantee that the result set will have the records in a
predictable sequence: is that correct?

Correct. Without an ORDER BY clause the collation of rows in a set are undefined and thus the order is unpredictable.

An attribute of the connection should be available for Sort Sequence (SRTSEQ) so that the collation is defined as desired for when an ORDER BY is specified.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact