Results 1 to 2 of 2
  1. #1
    osval is offline Member
    Join Date
    Jul 2007
    Posts
    26
    Rep Power
    0

    Default how to determine the primary key

    can I determine the primary and the foreign key of my table in my Java Program. if it so How can I do that???

  2. #2
    boy22 is offline Member
    Join Date
    Jul 2007
    Posts
    36
    Rep Power
    0

    Default

    java.sql interface DatabaseMetaData

    ResultSet getPrimaryKeys (String catalog,String schema,String table)throws SQLException

    Retrieves a description of the given table's primary key columns. They are ordered by COLUMN_NAME.

    Each primary key column description has the following columns:

    TABLE_CAT String => table catalog (may be null)
    TABLE_SCHEM String => table schema (may be null)
    TABLE_NAME String => table name
    COLUMN_NAME String => column name
    KEY_SEQ short => sequence number within primary key
    PK_NAME String => primary key name (may be null)

    Parameters:
    catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
    schema - a schema name; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search
    table - a table name; must match the table name as it is stored in the database
    Returns:
    ResultSet - each row is a primary key column description
    Throws:
    SQLException - if a database access error occurs

Similar Threads

  1. How to determine CPU usage using Java?????
    By JavaEmpires in forum New To Java
    Replies: 5
    Last Post: 03-16-2011, 05:49 AM
  2. Replies: 1
    Last Post: 05-01-2008, 04:19 PM
  3. Replies: 3
    Last Post: 01-19-2008, 07:05 AM
  4. Replies: 1
    Last Post: 05-20-2007, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •