JDBC 7.0 driver: Metadata support

Поиск
Список
Период
Сортировка
Искать

JDBC 7.0 driver: Metadata support

От:
"Christian Pröhl" <proehl@gmx.de>
Дата:
Hello,

I'm just exploring the metadata support of postgreSQL 7.0's JDBC-driver. So I 
found a bug concerning table meta datas:

In jdbcX\DatabaseMetadaData.java following methods should be fixed in the 
following way (tested on OS/2 with JDK 1.1.7 and PostgreSQL 7.0). Then you can 
query what a table has. Code changes are commented with [CP].

----------------------------)schnipp(-------------------------------------
 public java.sql.ResultSet getTableTypes() throws SQLException {   Field f[] = new Field[1];   Vector v = new Vector();   byte[][] tuple = new byte[1][0];   f[0] = new Field(connection,new String("TABLE_TYPE"),iVarcharOid,32);   for(int i=0;i   // Now take the pattern into account   sql.append(") and relname like '");   sql.append(tableNamePattern.toLowerCase());   sql.append("'");
   // Now run the query   r = connection.ExecSQL(sql.toString());      byte remarks[];      while (r.next())     {byte[][] tuple = new byte[5][0];// Fetch the description for the table (if any)java.sql.ResultSet dr = connection.ExecSQL(         "select description from pg_description where objoid="+r.getInt(2));if(((org.postgresql.ResultSet)dr).getTupleCount()==1) {  dr.next();  remarks = dr.getBytes(1);} else  remarks = defaultRemarks;dr.close();tuple[0] = null;		// Catalog nametuple[1] = null;		// Schema nametuple[2] = r.getBytes(1);	// Table nametuple[3] = null;		// Table type       tuple[3] = r.getBytes(3);       /* [CP] return table type as string */       tuple[3] = queryTableType(r.getInt(2),types);tuple[4] = remarks;		// Remarksv.addElement(tuple);     }   r.close();   return new ResultSet(connection, f, v, "OK", 1); }
 // Additional method to query table type for given // PostgreSQL object. Used by getTables(...) for // TABLE_TYPE // Method added by Christian Pr\u00F6hl  private byte[] queryTableType(int oid, String[] types) throws SQLException {  if ((types==null)||(types.length==0)) return null;  String[][] tableTypes = (getTableTypes);  for (int i=0; i
FAQ