Re: Patch for getBestRowIdentifier (for testing with Oracle

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Patch for getBestRowIdentifier (for testing with Oracle
Дата
Msg-id Pine.LNX.4.33.0209121259320.6022-100000@leary.csoft.net
обсуждение исходный текст
Ответ на Re: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)  (snpe <snpe@snpe.co.yu>)
Список pgsql-jdbc
I will add a version of this patch to my work on making DatabaseMetaData
schema aware.

Kris Jurka


On Wed, 11 Sep 2002, snpe wrote:

> I'am sorry (reverse *java and *orig)
>
> correct patch
> --- AbstractJdbc1DatabaseMetaData.java.orig    Wed Sep 11 22:20:36 2002
> +++ AbstractJdbc1DatabaseMetaData.java    Wed Sep 11 22:50:37 2002
> @@ -2381,21 +2381,44 @@
>      // Implementation note: This is required for Borland's JBuilder to work
>      public java.sql.ResultSet getBestRowIdentifier(String catalog, String
> schema, String table, int scope, boolean nullable) throws SQLException
>      {
> -        // for now, this returns an empty result set.
> -        Field f[] = new Field[8];
> -        ResultSet r;    // ResultSet for the SQL query that we need to do
> -        Vector v = new Vector();        // The new ResultSet tuple stuff
> +        if (connection.haveMinimumServerVersion("7.3")) {
> +            StringBuffer sql = new StringBuffer(512);
> +            sql.append("SELECT " +
> +                scope + " as SCOPE," +
> +                "a.attname as COLUMN_NAME," +
> +                "a.atttypid as DATA_TYPE," +
> +                "t.typname as TYPE_NAME," +
> +                "t.typlen as COLUMN_SIZE," +
> +                "0::int4 as BUFFER_LENGTH," +
> +                "0::int4 as DECIMAL_DIGITS," +
> +                "0::int4 as PSEUDO_COLUMN " +
> +             "FROM pg_catalog.pg_type t,pg_catalog.pg_class bc," +
> +                "pg_catalog.pg_class ic, pg_catalog.pg_index i, pg_catalog.pg_attribute a
> " +
> +             "WHERE bc.relkind = 'r' " +
> +              "AND t.oid=a.atttypid " +
> +              "AND upper(bc.relname) = upper('" + table + "') " +
> +              "AND i.indrelid = bc.oid " +
> +              "AND i.indexrelid = ic.oid " +
> +              "AND ic.oid = a.attrelid " +
> +              "AND i.indisprimary='t' ");
> +            return connection.createStatement().executeQuery(sql.toString());
> +        } else {
> +            // for now, this returns an empty result set.
> +            Field f[] = new Field[8];
> +            ResultSet r;    // ResultSet for the SQL query that we need to do
> +            Vector v = new Vector();        // The new ResultSet tuple stuff
>
> -        f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
> -        f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, NAME_SIZE);
> -        f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
> -        f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, NAME_SIZE);
> -        f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
> -        f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
> -        f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
> -        f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
> +            f[0] = new Field(connection, "SCOPE", iInt2Oid, 2);
> +            f[1] = new Field(connection, "COLUMN_NAME", iVarcharOid, NAME_SIZE);
> +            f[2] = new Field(connection, "DATA_TYPE", iInt2Oid, 2);
> +            f[3] = new Field(connection, "TYPE_NAME", iVarcharOid, NAME_SIZE);
> +            f[4] = new Field(connection, "COLUMN_SIZE", iInt4Oid, 4);
> +            f[5] = new Field(connection, "BUFFER_LENGTH", iInt4Oid, 4);
> +            f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
> +            f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
>
> -        return connection.getResultSet(null, f, v, "OK", 1);
> +            return connection.getResultSet(null, f, v, "OK", 1);
> +        }
>      }
>
>      /*
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: Is getProcedureColumns working for pgjdbc2.jar?
Следующее
От: Stephen Bacon
Дата:
Сообщение: Connection reset errors