Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf08f5c

Browse files
author
Dave Cramer
committed
patches by Kim Ho to fix
getByte, getSort if input has decimal or whitespacesetObject if object is a BITboolean not on list of SQLKeywords
1 parentede1734 commitdf08f5c

File tree

6 files changed

+54
-7
lines changed

6 files changed

+54
-7
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.20 2003/05/29 21:44:47 barry Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.21 2003/06/30 21:10:55 davec Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1740,6 +1740,7 @@ public int getSQLType(String pgTypeName)
17401740
"varchar","text","name","filename",
17411741
"bytea",
17421742
"bool",
1743+
"bit",
17431744
"date",
17441745
"time",
17451746
"abstime","timestamp","timestamptz"
@@ -1764,6 +1765,7 @@ public int getSQLType(String pgTypeName)
17641765
Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
17651766
Types.BINARY,
17661767
Types.BIT,
1768+
Types.BIT,
17671769
Types.DATE,
17681770
Types.TIME,
17691771
Types.TIMESTAMP,Types.TIMESTAMP,Types.TIMESTAMP

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
1212
{
1313

1414
privatestaticfinalStringkeywords ="abort,acl,add,aggregate,append,archive," +
15-
"arch_store,backward,binary,change,cluster," +
15+
"arch_store,backward,binary,boolean,change,cluster," +
1616
"copy,database,delimiter,delimiters,do,extend," +
1717
"explain,forward,heavy,index,inherits,isnull," +
1818
"light,listen,load,merge,nothing,notify," +

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.12 2003/05/03 20:40:45 barry Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.13 2003/06/30 21:10:55 davec Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -189,6 +189,19 @@ public byte getByte(int columnIndex) throws SQLException
189189
{
190190
try
191191
{
192+
switch(fields[columnIndex-1].getSQLType())
193+
{
194+
caseTypes.NUMERIC:
195+
caseTypes.REAL:
196+
caseTypes.DOUBLE:
197+
caseTypes.FLOAT:
198+
caseTypes.DECIMAL:
199+
s = (s.indexOf(".")==-1) ?s :s.substring(0,s.indexOf("."));
200+
break;
201+
caseTypes.CHAR:
202+
s =s.trim();
203+
break;
204+
}
192205
returnByte.parseByte(s);
193206
}
194207
catch (NumberFormatExceptione)
@@ -207,6 +220,19 @@ public short getShort(int columnIndex) throws SQLException
207220
{
208221
try
209222
{
223+
switch(fields[columnIndex-1].getSQLType())
224+
{
225+
caseTypes.NUMERIC:
226+
caseTypes.REAL:
227+
caseTypes.DOUBLE:
228+
caseTypes.FLOAT:
229+
caseTypes.DECIMAL:
230+
s = (s.indexOf(".")==-1) ?s :s.substring(0,s.indexOf("."));
231+
break;
232+
caseTypes.CHAR:
233+
s =s.trim();
234+
break;
235+
}
210236
returnShort.parseShort(s);
211237
}
212238
catch (NumberFormatExceptione)
@@ -778,6 +804,7 @@ public static int toInt(String s) throws SQLException
778804
{
779805
try
780806
{
807+
s =s.trim();
781808
returnInteger.parseInt(s);
782809
}
783810
catch (NumberFormatExceptione)
@@ -794,6 +821,7 @@ public static long toLong(String s) throws SQLException
794821
{
795822
try
796823
{
824+
s =s.trim();
797825
returnLong.parseLong(s);
798826
}
799827
catch (NumberFormatExceptione)
@@ -811,6 +839,7 @@ public static BigDecimal toBigDecimal(String s, int scale) throws SQLException
811839
{
812840
try
813841
{
842+
s =s.trim();
814843
val =newBigDecimal(s);
815844
}
816845
catch (NumberFormatExceptione)
@@ -837,6 +866,7 @@ public static float toFloat(String s) throws SQLException
837866
{
838867
try
839868
{
869+
s =s.trim();
840870
returnFloat.valueOf(s).floatValue();
841871
}
842872
catch (NumberFormatExceptione)
@@ -853,6 +883,7 @@ public static double toDouble(String s) throws SQLException
853883
{
854884
try
855885
{
886+
s =s.trim();
856887
returnDouble.valueOf(s).doubleValue();
857888
}
858889
catch (NumberFormatExceptione)
@@ -871,6 +902,7 @@ public static java.sql.Date toDate(String s) throws SQLException
871902
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
872903
try
873904
{
905+
s =s.trim();
874906
returnjava.sql.Date.valueOf((s.length() ==10) ?s :s.substring(0,10));
875907
}
876908
catch (NumberFormatExceptione)
@@ -885,6 +917,7 @@ public static Time toTime(String s, BaseResultSet resultSet, String pgDataType)
885917
returnnull;// SQL NULL
886918
try
887919
{
920+
s =s.trim();
888921
if (s.length() ==8)
889922
{
890923
//value is a time value
@@ -952,6 +985,7 @@ public static Timestamp toTimestamp(String s, BaseResultSet resultSet, String pg
952985
if (s ==null)
953986
returnnull;
954987

988+
s =s.trim();
955989
// We must be synchronized here incase more theads access the ResultSet
956990
// bad practice but possible. Anyhow this is to protect sbuf and
957991
// SimpleDateFormat objects

‎src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
importjava.sql.Types;
2626
importjava.util.Vector;
2727

28-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.25 2003/06/3016:38:30 barry Exp $
28+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.26 2003/06/3021:10:55 davec Exp $
2929
* This class defines methods of the jdbc1 specification. This class is
3030
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
3131
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -1464,7 +1464,10 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale
14641464
switch (targetSqlType)
14651465
{
14661466
caseTypes.INTEGER:
1467-
bind(parameterIndex,x.toString(),PG_INTEGER);
1467+
if (xinstanceofBoolean)
1468+
bind(parameterIndex,((Boolean)x).booleanValue() ?"1" :"0",PG_BOOLEAN);
1469+
else
1470+
bind(parameterIndex,x.toString(),PG_INTEGER);
14681471
break;
14691472
caseTypes.TINYINT:
14701473
caseTypes.SMALLINT:
@@ -1498,6 +1501,10 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale
14981501
{
14991502
bind(parameterIndex, ((Boolean)x).booleanValue() ?"TRUE" :"FALSE",PG_TEXT);
15001503
}
1504+
elseif (xinstanceofNumber)
1505+
{
1506+
bind(parameterIndex, ((Number)x).intValue()==1 ?"TRUE" :"FALSE",PG_TEXT);
1507+
}
15011508
else
15021509
{
15031510
thrownewPSQLException("postgresql.prep.type");

‎src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
importjava.sql.SQLException;
88
importjava.sql.Types;
99

10-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.5 2003/05/29 04:39:48 barry Exp $
10+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.6 2003/06/30 21:10:55 davec Exp $
1111
* This class defines methods of the jdbc2 specification. This class extends
1212
* org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
1313
* methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
@@ -126,6 +126,7 @@ public int getSQLType(String pgTypeName)
126126
"varchar","text","name","filename",
127127
"bytea",
128128
"bool",
129+
"bit",
129130
"date",
130131
"time",
131132
"abstime","timestamp","timestamptz",
@@ -154,6 +155,7 @@ public int getSQLType(String pgTypeName)
154155
Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
155156
Types.BINARY,
156157
Types.BIT,
158+
Types.BIT,
157159
Types.DATE,
158160
Types.TIME,
159161
Types.TIMESTAMP,Types.TIMESTAMP,Types.TIMESTAMP,

‎src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
importjava.sql.*;
44

5-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.3 2003/05/07 03:03:30 barry Exp $
5+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.4 2003/06/30 21:10:55 davec Exp $
66
* This class defines methods of the jdbc3 specification. This class extends
77
* org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2
88
* methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
@@ -415,6 +415,7 @@ public int getSQLType(String pgTypeName)
415415
"varchar","text","name","filename",
416416
"bytea",
417417
"bool",
418+
"bit",
418419
"date",
419420
"time",
420421
"abstime","timestamp","timestamptz",
@@ -443,6 +444,7 @@ public int getSQLType(String pgTypeName)
443444
Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
444445
Types.BINARY,
445446
Types.BIT,
447+
Types.BIT,
446448
Types.DATE,
447449
Types.TIME,
448450
Types.TIMESTAMP,Types.TIMESTAMP,Types.TIMESTAMP,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp