//// Anything else defaults to trust authentication
//STARTUP_CODE=STARTUP_USER;
//}
// Now make the initial connection
// Now make the initial connection
try
try
{
{
pg_stream=newPG_Stream(host,port);
pg_stream=newPG_Stream(host,port);
}catch(ConnectExceptioncex){
// Added by Peter Mount <peter@retep.org.uk>
// ConnectException is thrown when the connection cannot be made.
// we trap this an return a more meaningful message for the end user
thrownewSQLException("Connection refused. Check that the hostname and port is correct, and that the postmaster is running with the -i flag, which enables TCP/IP networking.");
thrownewSQLException("Authentication type "+areq+" not supported");
thrownewSQLException("Authentication type "+areq+" not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and is using a supported authentication scheme.");
}
}
break;
break;
...
@@ -511,7 +473,9 @@ public class Connection implements java.sql.Connection
...
@@ -511,7 +473,9 @@ public class Connection implements java.sql.Connection
// Added by Stefan Andreasen <stefan@linux.kapow.dk>
// If the pattern are null then set them to %
if(tableNamePattern==null)tableNamePattern="%";
if(columnNamePattern==null)columnNamePattern="%";
// Now form the query
// Now form the query
r=connection.ExecSQL("select a.oid,c.relname,a.attname,a.atttypid,a.attnum,a.attnotnull,a.attlen,a.atttypmod from pg_class c, pg_attribute a where a.attrelid=c.oid and c.relname like '"+tableNamePattern+"' and a.attname like '"+columnNamePattern+"' and a.attnum>0 order by c.relname,a.attnum");
// Modified by Stefan Andreasen <stefan@linux.kapow.dk>
r=connection.ExecSQL("select a.oid,c.relname,a.attname,a.atttypid,a.attnum,a.attnotnull,a.attlen,a.atttypmod from pg_class c, pg_attribute a where a.attrelid=c.oid and c.relname like '"+tableNamePattern.toLowerCase()+"' and a.attname like '"+columnNamePattern.toLowerCase()+"' and a.attnum>0 order by c.relname,a.attnum");
byteremarks[];
while(r.next()){
while(r.next()){
byte[][]tuple=newbyte[18][0];
byte[][]tuple=newbyte[18][0];
Stringname=r.getString(1);
Stringremarks=newString("no remarks");
StringcolumnSize;
// Fetch the description for the table (if any)
// Fetch the description for the table (if any)
ResultSetdr=connection.ExecSQL("select description from pg_description where objoid="+r.getInt(1));
ResultSetdr=connection.ExecSQL("select description from pg_description where objoid="+r.getInt(1));
if(dr.getTupleCount()==1){
if(dr.getTupleCount()==1){
dr.next();
dr.next();
remarks=dr.getString(1);
tuple[11]=dr.getBytes(1);
}
}else
tuple[11]=defaultRemarks;
dr.close();
dr.close();
tuple[0]="".getBytes();// Catalog name
tuple[0]="".getBytes();// Catalog name
tuple[1]="".getBytes();// Schema name
tuple[1]="".getBytes();// Schema name
tuple[2]=r.getString(2).getBytes();// Table name
tuple[2]=r.getBytes(2);// Table name
tuple[3]=r.getString(3).getBytes();// Column name
tuple[3]=r.getBytes(3);// Column name
dr=connection.ExecSQL("select typname from pg_type where oid = "+r.getString(4));
dr=connection.ExecSQL("select typname from pg_type where oid = "+r.getString(4));
dr.next();
dr.next();
...
@@ -1877,16 +1898,16 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
...
@@ -1877,16 +1898,16 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
dr.close();
dr.close();
tuple[4]=Integer.toString(Field.getSQLType(typname)).getBytes();// Data type
tuple[4]=Integer.toString(Field.getSQLType(typname)).getBytes();// Data type
tuple[5]=typname.getBytes();// Type name
tuple[5]=typname.getBytes();// Type name
// Column size
// Looking at the psql source,
// Looking at the psql source,
// I think the length of a varchar as specified when the table was created
// I think the length of a varchar as specified when the table was created
// should be extracted from atttypmod which contains this length + sizeof(int32)
// should be extracted from atttypmod which contains this length + sizeof(int32)
ResultSetr=connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner ORDER BY relname");
ResultSetr=connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '"+table.toLowerCase()+"' ORDER BY relname");