提交 df08f5c0 编写于 作者: D Dave Cramer

patches by Kim Ho to fix

getByte, getSort if input has decimal or whitespace
setObject if object is a BIT
boolean not on list of SQLKeywords
上级 ede1734c
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.20 2003/05/29 21:44:47 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.21 2003/06/30 21:10:55 davec Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1740,6 +1740,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection ...@@ -1740,6 +1740,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
"varchar", "text", "name", "filename", "varchar", "text", "name", "filename",
"bytea", "bytea",
"bool", "bool",
"bit",
"date", "date",
"time", "time",
"abstime", "timestamp", "timestamptz" "abstime", "timestamp", "timestamptz"
...@@ -1764,6 +1765,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection ...@@ -1764,6 +1765,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.BINARY, Types.BINARY,
Types.BIT, Types.BIT,
Types.BIT,
Types.DATE, Types.DATE,
Types.TIME, Types.TIME,
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP
......
...@@ -12,7 +12,7 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -12,7 +12,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
{ {
private static final String keywords = "abort,acl,add,aggregate,append,archive," + private static final String keywords = "abort,acl,add,aggregate,append,archive," +
"arch_store,backward,binary,change,cluster," + "arch_store,backward,binary,boolean,change,cluster," +
"copy,database,delimiter,delimiters,do,extend," + "copy,database,delimiter,delimiters,do,extend," +
"explain,forward,heavy,index,inherits,isnull," + "explain,forward,heavy,index,inherits,isnull," +
"light,listen,load,merge,nothing,notify," + "light,listen,load,merge,nothing,notify," +
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.12 2003/05/03 20:40:45 barry Exp $ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.13 2003/06/30 21:10:55 davec Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -189,6 +189,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -189,6 +189,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
switch(fields[columnIndex-1].getSQLType())
{
case Types.NUMERIC:
case Types.REAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.DECIMAL:
s = (s.indexOf(".")==-1) ? s : s.substring(0,s.indexOf("."));
break;
case Types.CHAR:
s = s.trim();
break;
}
return Byte.parseByte(s); return Byte.parseByte(s);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -207,6 +220,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -207,6 +220,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
switch(fields[columnIndex-1].getSQLType())
{
case Types.NUMERIC:
case Types.REAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.DECIMAL:
s = (s.indexOf(".")==-1) ? s : s.substring(0,s.indexOf("."));
break;
case Types.CHAR:
s = s.trim();
break;
}
return Short.parseShort(s); return Short.parseShort(s);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -778,6 +804,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -778,6 +804,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
s = s.trim();
return Integer.parseInt(s); return Integer.parseInt(s);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -794,6 +821,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -794,6 +821,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
s = s.trim();
return Long.parseLong(s); return Long.parseLong(s);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -811,6 +839,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -811,6 +839,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
s = s.trim();
val = new BigDecimal(s); val = new BigDecimal(s);
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -837,6 +866,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -837,6 +866,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
s = s.trim();
return Float.valueOf(s).floatValue(); return Float.valueOf(s).floatValue();
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -853,6 +883,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -853,6 +883,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{ {
try try
{ {
s = s.trim();
return Double.valueOf(s).doubleValue(); return Double.valueOf(s).doubleValue();
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -871,6 +902,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -871,6 +902,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO // length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
try try
{ {
s = s.trim();
return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10)); return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
} }
catch (NumberFormatException e) catch (NumberFormatException e)
...@@ -885,6 +917,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -885,6 +917,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
return null; // SQL NULL return null; // SQL NULL
try try
{ {
s = s.trim();
if (s.length() == 8) if (s.length() == 8)
{ {
//value is a time value //value is a time value
...@@ -952,6 +985,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -952,6 +985,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
if (s == null) if (s == null)
return null; return null;
s = s.trim();
// We must be synchronized here incase more theads access the ResultSet // We must be synchronized here incase more theads access the ResultSet
// bad practice but possible. Anyhow this is to protect sbuf and // bad practice but possible. Anyhow this is to protect sbuf and
// SimpleDateFormat objects // SimpleDateFormat objects
......
...@@ -25,7 +25,7 @@ import java.sql.Timestamp; ...@@ -25,7 +25,7 @@ import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Vector; import java.util.Vector;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.25 2003/06/30 16:38:30 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.26 2003/06/30 21:10:55 davec Exp $
* This class defines methods of the jdbc1 specification. This class is * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...@@ -1464,7 +1464,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1464,7 +1464,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
switch (targetSqlType) switch (targetSqlType)
{ {
case Types.INTEGER: case Types.INTEGER:
bind(parameterIndex, x.toString(), PG_INTEGER); if (x instanceof Boolean)
bind(parameterIndex,((Boolean)x).booleanValue() ? "1" :"0", PG_BOOLEAN);
else
bind(parameterIndex, x.toString(), PG_INTEGER);
break; break;
case Types.TINYINT: case Types.TINYINT:
case Types.SMALLINT: case Types.SMALLINT:
...@@ -1498,6 +1501,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1498,6 +1501,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
{ {
bind(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE", PG_TEXT); bind(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE", PG_TEXT);
} }
else if (x instanceof Number)
{
bind(parameterIndex, ((Number)x).intValue()==1 ? "TRUE" : "FALSE", PG_TEXT);
}
else else
{ {
throw new PSQLException("postgresql.prep.type"); throw new PSQLException("postgresql.prep.type");
......
...@@ -7,7 +7,7 @@ import java.sql.SQLData; ...@@ -7,7 +7,7 @@ import java.sql.SQLData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.5 2003/05/29 04:39:48 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.6 2003/06/30 21:10:55 davec Exp $
* This class defines methods of the jdbc2 specification. This class extends * This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
* methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection * methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
...@@ -126,6 +126,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr ...@@ -126,6 +126,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
"varchar", "text", "name", "filename", "varchar", "text", "name", "filename",
"bytea", "bytea",
"bool", "bool",
"bit",
"date", "date",
"time", "time",
"abstime", "timestamp", "timestamptz", "abstime", "timestamp", "timestamptz",
...@@ -154,6 +155,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr ...@@ -154,6 +155,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.BINARY, Types.BINARY,
Types.BIT, Types.BIT,
Types.BIT,
Types.DATE, Types.DATE,
Types.TIME, Types.TIME,
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
......
...@@ -2,7 +2,7 @@ package org.postgresql.jdbc3; ...@@ -2,7 +2,7 @@ package org.postgresql.jdbc3;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.3 2003/05/07 03:03:30 barry Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.4 2003/06/30 21:10:55 davec Exp $
* This class defines methods of the jdbc3 specification. This class extends * This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2 * org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2
* methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection * methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
...@@ -415,6 +415,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -415,6 +415,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
"varchar", "text", "name", "filename", "varchar", "text", "name", "filename",
"bytea", "bytea",
"bool", "bool",
"bit",
"date", "date",
"time", "time",
"abstime", "timestamp", "timestamptz", "abstime", "timestamp", "timestamptz",
...@@ -443,6 +444,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr ...@@ -443,6 +444,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.BINARY, Types.BINARY,
Types.BIT, Types.BIT,
Types.BIT,
Types.DATE, Types.DATE,
Types.TIME, Types.TIME,
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册