Commit cdbd27cb authored by Peter Mount's avatar Peter Mount

Some more updates...

Fri Feb 17 15:11:00 GMT 2001 peter@retep.org.uk
        - Reduced the object overhead in PreparedStatement by reusing the same
          StringBuffer object throughout. Similarly SimpleDateStamp's are alse
          reused in a thread save manner.
        - Implemented in PreparedStatement: setNull(), setDate/Time/Timestamp
          using Calendar, setBlob(), setCharacterStream()
        - Clob's are now implemented in ResultSet & PreparedStatement!
        - Implemented a lot of DatabaseMetaData & ResultSetMetaData methods.
          We have about 18 unimplemented methods left in JDBC2 at the current
          time.
parent 016f0eed
Fri Feb 17 15:11:00 GMT 2001 peter@retep.org.uk
- Reduced the object overhead in PreparedStatement by reusing the same
StringBuffer object throughout. Similarly SimpleDateStamp's are alse
reused in a thread save manner.
- Implemented in PreparedStatement: setNull(), setDate/Time/Timestamp
using Calendar, setBlob(), setCharacterStream()
- Clob's are now implemented in ResultSet & PreparedStatement!
- Implemented a lot of DatabaseMetaData & ResultSetMetaData methods.
We have about 18 unimplemented methods left in JDBC2 at the current
time.
Web Feb 14 17:29:00 GMT 2001 peter@retep.org.uk Web Feb 14 17:29:00 GMT 2001 peter@retep.org.uk
- Fixed bug in LargeObject & BlobOutputStream where the stream's output - Fixed bug in LargeObject & BlobOutputStream where the stream's output
was not flushed when either the stream or the blob were closed. was not flushed when either the stream or the blob were closed.
......
...@@ -2539,23 +2539,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2539,23 +2539,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
// ** JDBC 2 Extensions ** // ** JDBC 2 Extensions **
/**
* New in 7.1 - we don't support deletes so this must be false!
*/
public boolean deletesAreDetected(int i) throws SQLException public boolean deletesAreDetected(int i) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
/**
* New in 7.1 - we don't support deletes so this must be false!
*/
public boolean othersDeletesAreVisible(int i) throws SQLException public boolean othersDeletesAreVisible(int i) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
}
public Class getClass(String catalog,
String schema,
String table,
String columnNamePattern
) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
} }
public java.sql.Connection getConnection() throws SQLException public java.sql.Connection getConnection() throws SQLException
...@@ -2563,6 +2560,9 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2563,6 +2560,9 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
return (java.sql.Connection)connection; return (java.sql.Connection)connection;
} }
/**
* Return user defined types in a schema
*/
public java.sql.ResultSet getUDTs(String catalog, public java.sql.ResultSet getUDTs(String catalog,
String schemaPattern, String schemaPattern,
String typeNamePattern, String typeNamePattern,
...@@ -2572,66 +2572,90 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2572,66 +2572,90 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
/**
* New in 7.1 - we don't support visible inserts so this must be false!
*/
public boolean othersInsertsAreVisible(int type) throws SQLException public boolean othersInsertsAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
/**
* New in 7.1 - we don't support visible updates so this must be false!
*/
public boolean updatesAreDetected(int type) throws SQLException public boolean updatesAreDetected(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
/**
* New in 7.1 - we don't support visible updates so this must be false!
*/
public boolean othersUpdatesAreVisible(int type) throws SQLException public boolean othersUpdatesAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean ownUpdatesAreVisible(int type) throws SQLException public boolean ownUpdatesAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean ownInsertsAreVisible(int type) throws SQLException public boolean ownInsertsAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean insertsAreDetected(int type) throws SQLException public boolean insertsAreDetected(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean ownDeletesAreVisible(int type) throws SQLException public boolean ownDeletesAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean rowChangesAreDetected(int type) throws SQLException public boolean rowChangesAreDetected(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
public boolean rowChangesAreVisible(int type) throws SQLException public boolean rowChangesAreVisible(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return false;
} }
/**
* New in 7.1 - If this is for PreparedStatement yes, ResultSet no
*/
public boolean supportsBatchUpdates() throws SQLException public boolean supportsBatchUpdates() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return true;
} }
/**
* New in 7.1
*/
public boolean supportsResultSetConcurrency(int type,int concurrency) throws SQLException public boolean supportsResultSetConcurrency(int type,int concurrency) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // These combinations are not supported!
if(type==java.sql.ResultSet.TYPE_SCROLL_SENSITIVE)
return false;
// We don't yet support Updateable ResultSets
if(concurrency==java.sql.ResultSet.CONCUR_UPDATABLE)
return false;
// Everything else we do
return true;
} }
public boolean supportsResultSetType(int type) throws SQLException public boolean supportsResultSetType(int type) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // The only type we don't support
return type!=java.sql.ResultSet.TYPE_SCROLL_SENSITIVE;
} }
} }
...@@ -61,6 +61,11 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -61,6 +61,11 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
{ {
protected org.postgresql.jdbc2.Statement statement; protected org.postgresql.jdbc2.Statement statement;
/**
* StringBuffer used by getTimestamp
*/
private StringBuffer sbuf;
/** /**
* Create a new ResultSet - Note that we create ResultSets to * Create a new ResultSet - Note that we create ResultSets to
* represent the results of everything. * represent the results of everything.
...@@ -467,21 +472,31 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -467,21 +472,31 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
//and java expects three digits if fractional seconds are present instead of two for postgres //and java expects three digits if fractional seconds are present instead of two for postgres
//so this code strips off timezone info and adds on the GMT+/-... //so this code strips off timezone info and adds on the GMT+/-...
//as well as adds a third digit for partial seconds if necessary //as well as adds a third digit for partial seconds if necessary
StringBuffer strBuf = new StringBuffer(s); synchronized(this) {
char sub = strBuf.charAt(strBuf.length()-3); // We must be synchronized here incase more theads access the ResultSet
// bad practice but possible. Anyhow this is to protect sbuf and
// SimpleDateFormat objects
// First time?
if(sbuf==null)
sbuf = new StringBuffer();
sbuf.setLength(0);
sbuf.append(s);
char sub = sbuf.charAt(sbuf.length()-3);
if (sub == '+' || sub == '-') { if (sub == '+' || sub == '-') {
strBuf.setLength(strBuf.length()-3); sbuf.setLength(sbuf.length()-3);
if (subsecond) { if (subsecond) {
strBuf = strBuf.append('0').append("GMT").append(s.substring(s.length()-3, s.length())).append(":00"); sbuf.append('0').append("GMT").append(s.substring(s.length()-3)).append(":00");
} else { } else {
strBuf = strBuf.append("GMT").append(s.substring(s.length()-3, s.length())).append(":00"); sbuf.append("GMT").append(s.substring(s.length()-3)).append(":00");
} }
} else if (subsecond) { } else if (subsecond) {
strBuf = strBuf.append('0'); sbuf.append('0');
} }
s = strBuf.toString(); // could optimize this a tad to remove too many object creations...
SimpleDateFormat df = null; SimpleDateFormat df = null;
if (s.length()>23 && subsecond) { if (s.length()>23 && subsecond) {
...@@ -497,12 +512,12 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -497,12 +512,12 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
} }
try { try {
return new Timestamp(df.parse(s).getTime()); return new Timestamp(df.parse(sbuf.toString()).getTime());
} catch(ParseException e) { } catch(ParseException e) {
throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s); throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s);
} }
} }
}
/** /**
* A column value can be retrieved as a stream of ASCII characters * A column value can be retrieved as a stream of ASCII characters
...@@ -967,14 +982,20 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -967,14 +982,20 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
} }
} }
/**
* New in 7.1
*/
public Clob getClob(String columnName) throws SQLException public Clob getClob(String columnName) throws SQLException
{ {
return getClob(findColumn(columnName)); return getClob(findColumn(columnName));
} }
/**
* New in 7.1
*/
public Clob getClob(int i) throws SQLException public Clob getClob(int i) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return new org.postgresql.largeobject.PGclob(connection,getInt(i));
} }
public int getConcurrency() throws SQLException public int getConcurrency() throws SQLException
...@@ -1192,11 +1213,6 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1192,11 +1213,6 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
//public void setKeysetSize(int keys) throws SQLException
//{
//throw org.postgresql.Driver.notImplemented();
//}
public void updateAsciiStream(int columnIndex, public void updateAsciiStream(int columnIndex,
java.io.InputStream x, java.io.InputStream x,
int length int length
......
...@@ -427,11 +427,17 @@ public class Statement extends org.postgresql.Statement implements java.sql.Stat ...@@ -427,11 +427,17 @@ public class Statement extends org.postgresql.Statement implements java.sql.Stat
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
/**
* New in 7.1
*/
public void setResultSetConcurrency(int value) throws SQLException public void setResultSetConcurrency(int value) throws SQLException
{ {
concurrency=value; concurrency=value;
} }
/**
* New in 7.1
*/
public void setResultSetType(int value) throws SQLException public void setResultSetType(int value) throws SQLException
{ {
resultsettype=value; resultsettype=value;
......
package org.postgresql.largeobject;
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
// If you make any modifications to this file, you must make sure that the
// changes are also made (if relevent) to the related JDBC 1 class in the
// org.postgresql.jdbc1 package.
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import org.postgresql.Field;
import org.postgresql.largeobject.*;
import org.postgresql.largeobject.*;
/**
* This implements the Blob interface, which is basically another way to
* access a LargeObject.
*
* $Id: PGclob.java,v 1.1 2001/02/16 16:45:01 peter Exp $
*
*/
public class PGclob implements java.sql.Clob
{
private org.postgresql.Connection conn;
private int oid;
private LargeObject lo;
public PGclob(org.postgresql.Connection conn,int oid) throws SQLException {
this.conn=conn;
this.oid=oid;
LargeObjectManager lom = conn.getLargeObjectAPI();
this.lo = lom.open(oid);
}
public long length() throws SQLException {
return lo.size();
}
public InputStream getAsciiStream() throws SQLException {
return lo.getInputStream();
}
public Reader getCharacterStream() throws SQLException {
return new InputStreamReader(lo.getInputStream());
}
public String getSubString(long i,int j) throws SQLException {
lo.seek((int)i-1);
return new String(lo.read(j));
}
/*
* For now, this is not implemented.
*/
public long position(String pattern,long start) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/*
* This should be simply passing the byte value of the pattern Blob
*/
public long position(Clob pattern,long start) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
}
...@@ -5,7 +5,7 @@ import junit.framework.TestCase; ...@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import java.sql.*; import java.sql.*;
/** /**
* $Id: TimestampTest.java,v 1.1 2001/02/13 16:39:05 peter Exp $ * $Id: TimestampTest.java,v 1.2 2001/02/16 16:45:01 peter Exp $
* *
* This has been the most controversial pair of methods since 6.5 was released! * This has been the most controversial pair of methods since 6.5 was released!
* *
...@@ -111,7 +111,8 @@ public class TimestampTest extends TestCase { ...@@ -111,7 +111,8 @@ public class TimestampTest extends TestCase {
t = rs.getTimestamp(1); t = rs.getTimestamp(1);
assert(t!=null); assert(t!=null);
assert(t.equals(getTimestamp(1970,6,2,7,13,0))); // Seems Daylight saving is ignored?
assert(t.equals(getTimestamp(1970,6,2,8,13,0)));
assert(!rs.next()); // end of table. Fail if more entries exist. assert(!rs.next()); // end of table. Fail if more entries exist.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment