Re: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)

Поиск
Список
Период
Сортировка
От snpe
Тема Re: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)
Дата
Msg-id 200209112252.55871.snpe@snpe.co.yu
обсуждение исходный текст
Ответ на Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)  (snpe <snpe@snpe.co.yu>)
Ответы Re: Patch for getBestRowIdentifier (for testing with Oracle
Список pgsql-jdbc
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);
+        }
     }

     /*


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

Предыдущее
От: snpe
Дата:
Сообщение: Patch for getBestRowIdentifier (for testing with Oracle JDeveloper)
Следующее
От: Vernon Wu
Дата:
Сообщение: Does the JDBC driver support XADataSource interface?