Re: JDBC Driver -- getImportedKeys

Поиск
Список
Период
Сортировка
От Candis Thomas
Тема Re: JDBC Driver -- getImportedKeys
Дата
Msg-id 3430B9A60E93564FAB3B5861335CBDCF6129D4@germanium.numethods.com
обсуждение исходный текст
Ответ на JDBC Driver -- getImportedKeys  ("Candis Thomas" <cthomas@nubridges.com>)
Список pgsql-jdbc
i managed to fix my problem.  thanks guys!

Candis L.

-----Original Message-----
From: Kris Jurka [mailto:books@ejurka.com]
Sent: Tuesday, January 07, 2003 5:01 PM
To: Candis Thomas
Cc: PostgreSQL JDBC List
Subject: RE: [JDBC] JDBC Driver -- getImportedKeys



I'm not clear on what results you're getting and what results you want
because you've really only shown what your application is doing.  What
would be interesting would be

1) the SQL used to create the various tables.
2) the results of

printResultSet(conn.getMetaData().getImportedKeys(null,null,"<table>");

where printResultSet is defined as below

3) what you'd like the results to be.

Kris Jurka

        public static void printResultSet(ResultSet rs) throws SQLException {
                ResultSetMetaData rsmd = rs.getMetaData();
                for (int i=1; i<=rsmd.getColumnCount(); i++) {
                        if (i != 1) {
                                System.out.print(", ");
                        }
                        System.out.print(rsmd.getColumnName(i));
                }
                System.out.println();
                while (rs.next()) {
                        for (int i=1; i<=rsmd.getColumnCount(); i++) {
                                if (i != 1) {
                                        System.out.print(", ");
                                }
                                System.out.print(rs.getString(i));
                        }
                        System.out.println();
                }
        }


On Tue, 7 Jan 2003, Candis Thomas wrote:

> I should note that I am no longer getting the exception, but I'm not
> getting the expected results.  These are the results:
>     Resut not null, therefore there are imported keys
>     The driver version is: PostgreSQL 7.3 JDBC3 jdbc driver build 106
>     Column name is appliance_id
>     Column type is 4
>
> Candis L.
>
> -----Original Message-----
> From: Kris Jurka [mailto:books@ejurka.com]
> Sent: Tuesday, January 07, 2003 4:18 PM
> To: Candis Thomas
> Cc: PostgreSQL JDBC List
> Subject: RE: [JDBC] JDBC Driver -- getImportedKeys
>
>
>
> This is not a stack trace from a 7.3 or 7.3.1 driver.  The
> org.postgresql.jdbc2.DatabaseMetaData class was removed between the 7.2
> and 7.3 series.  Even then I can't find reference to an importLoop method
> in older drivers (7.1.3 or 7.2.3).
>
> Please check your driver, classpath settings, or
> DatabaseMetaData.getDriverVersion().
>
> Kris Jurka
>
> On Tue, 7 Jan 2003, Candis Thomas wrote:
>
> > The stack trace is as follows:
> >
> > java.lang.StringIndexOutOfBoundsException: String index out of range: -3
> >         at java.lang.String.substring(String.java:1520)
> >         at java.lang.String.substring(String.java:1487)
> >         at org.postgresql.jdbc2.DatabaseMetaData.importLoop(DatabaseMetaData.java:2263)
> >         at org.postgresql.jdbc2.DatabaseMetaData.getImportedKeys(DatabaseMetaData.java:2408)
> >         at com.nubridges.shared.util.Column.setColumnInfo(Column.java:369)
> >         at com.nubridges.shared.util.Column.main(Column.java:426)
> >
> > Candis.
> >
> > -----Original Message-----
> > From: Kris Jurka [mailto:books@ejurka.com]
> > Sent: Tuesday, January 07, 2003 3:07 PM
> > To: Candis Thomas
> > Cc: PostgreSQL JDBC List
> > Subject: Re: [JDBC] JDBC Driver -- getImportedKeys
> >
> >
> >
> > 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
usingthe postgreSQL JDBC driver. 
> > >
> > > I am attempting to obtain metadata about the columns within a table, more specifically the primary and foreign
keyswithin a table.  Though the DataBaseMetaData method getPrimaryKeys() executes splendidly, I am getting errors when
usingthe getImportedKeys() method.  The code below attempts to determine whether or not a particular column is a
foreignkey. 
> > >
> > > 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/postgreSQLjdbc driver that I should use?  I'm really stumped by this issue and welcome any feedback that anyone
mayhave. 
> > >
> > > Thanks!
> > >
> > > Candis
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 2: you can get off all lists at once with the unregister command
> > >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> > >
> >
>


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Abel Muiño
Дата:
Сообщение: Deletion of Large Objects (was Re: [Re: JDBC compliance])
Следующее
От: Felipe Schnack
Дата:
Сообщение: server-side prepared