Re: JDBC Driver -- getImportedKeys

From: Kris Jurka <books(at)ejurka(dot)com>
To: Candis Thomas <cthomas(at)nubridges(dot)com>
Cc: PostgreSQL JDBC List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC Driver -- getImportedKeys
Date: 2003-01-07 20:07:12
Message-ID: Pine.LNX.4.33.0301071506260.8135-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


Do you have a stack trace of the StringIndexOutOfBoundsException ?

Kris Jurka

On Tue, 7 Jan 2003, Candis Thomas wrote:

> Hello all!,
>
> I'm relatively new to the mailing list, but am indeed having a serious problem with a particular method when using the postgreSQL JDBC driver.
>
> I am attempting to obtain metadata about the columns within a table, more specifically the primary and foreign keys within a table. Though the DataBaseMetaData method getPrimaryKeys() executes splendidly, I am getting errors when using the getImportedKeys() method. The code below attempts to determine whether or not a particular column is a foreign key.
>
> The code that I am using is as follows:
> rs = getMetaData().getImportedKeys(null, null, getTableName());
> boolean keepLooking = false;
> if(rs != null){
> System.out.println("Resut not null, therefore there are imported keys");
> while(rs.next() && keepLooking){
> System.out.println("Inside 'rs.next()'");
> //Check to see if a particular column is a foreign key
> if(rs.getString("FKCOLUMN_NAME").equalsIgnoreCase(getColumnName())){
> setForeignKey(true);
> keepLooking = false;
> }
> }//end while
> }//if result set isn't null
>
>
> The errors that I receive are detailed below (note the listed drivers were added to my classpath):
> postgreSQL driver 7.3.1 - java.lang.StringIndexOutOfBoundsException: String index out of range: -3
> postgreSQL jdbc driver 7.3.0 (jdbc 3.0) - java.lang.StringIndexOutOfBoundsException: String index out of range: -3
>
> I am attempting to retrieve information on the following table with the following columns:
> APPLIANCE
> Keyname Unique Primary Field
> ======= ====== ======= =====
> app_mac_address Yes No app_mac_address_net
> app_mac_address_net_idx No No app_mac_address_net
> appliance_company_id_idx No No company_id
> appliance_pkey Yes Yes appliance_id
>
> Does anyone have any ideas about what the problem could be? Is this the most recent combination of postgreSQL driver/postgreSQL jdbc driver that I should use? I'm really stumped by this issue and welcome any feedback that anyone may have.
>
> Thanks!
>
> Candis
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Abel Muiño 2003-01-07 20:29:33 Re: Re: [JDBC] Problem: commit doesn´t work
Previous Message Candis Thomas 2003-01-07 19:16:20 JDBC Driver -- getImportedKeys