Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 137b123

Browse files
author
Barry Lind
committed
Fixed bug with Warnings. Warnings are not added to the Statement instead of
the connection when appropriate. This checkin also adds the type map for jdbc3, however currently it is identical to the jdbc2 mapping. Modified Files: jdbc/org/postgresql/core/BaseStatement.java jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
1 parent d9fd7d1 commit 137b123

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

src/interfaces/jdbc/org/postgresql/core/BaseStatement.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.2 2003/05/03 20:40:45 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.3 2003/05/07 03:03:30 barry Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -28,6 +28,7 @@ public interface BaseStatement extends org.postgresql.PGStatement
2828
* any ResultSet can contain. If the limit is exceeded, the
2929
* excess rows are silently dropped.
3030
*/
31+
public void addWarning(String p_warning) throws SQLException;
3132
public int getFetchSize() throws SQLException;
3233
public int getMaxRows() throws SQLException;
3334
public int getResultSetConcurrency() throws SQLException;

src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.20 2003/03/07 18:39:42 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.21 2003/05/07 03:03:30 barry Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -148,7 +148,7 @@ private BaseResultSet execute() throws SQLException
148148
int t = pgStream.ReceiveChar();
149149
break;
150150
case 'N': // Error Notification
151-
connection.addWarning(pgStream.ReceiveString(connection.getEncoding()));
151+
statement.addWarning(pgStream.ReceiveString(connection.getEncoding()));
152152
break;
153153
case 'P': // Portal Name
154154
String pname = pgStream.ReceiveString(connection.getEncoding());

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

+77-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.sql.*;
44

5-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
5+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.3 2003/05/07 03:03:30 barry 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
@@ -375,6 +375,82 @@ public PreparedStatement prepareStatement(String sql, String columnNames[])
375375
throw org.postgresql.Driver.notImplemented();
376376
}
377377

378+
/*
379+
* This implemetation uses the jdbc3Types array to support the jdbc3
380+
* datatypes. Basically jdbc2 and jdbc3 are the same, except that
381+
* jdbc3 adds some
382+
*/
383+
public int getSQLType(String pgTypeName)
384+
{
385+
int sqlType = Types.OTHER; // default value
386+
for (int i = 0;i < jdbc3Types.length;i++)
387+
{
388+
if (pgTypeName.equals(jdbc3Types[i]))
389+
{
390+
sqlType = jdbc3Typei[i];
391+
break;
392+
}
393+
}
394+
return sqlType;
395+
}
396+
397+
/*
398+
* This table holds the org.postgresql names for the types supported.
399+
* Any types that map to Types.OTHER (eg POINT) don't go into this table.
400+
* They default automatically to Types.OTHER
401+
*
402+
* Note: This must be in the same order as below.
403+
*
404+
* Tip: keep these grouped together by the Types. value
405+
*/
406+
private static final String jdbc3Types[] = {
407+
"int2",
408+
"int4", "oid",
409+
"int8",
410+
"cash", "money",
411+
"numeric",
412+
"float4",
413+
"float8",
414+
"bpchar", "char", "char2", "char4", "char8", "char16",
415+
"varchar", "text", "name", "filename",
416+
"bytea",
417+
"bool",
418+
"date",
419+
"time",
420+
"abstime", "timestamp", "timestamptz",
421+
"_bool", "_char", "_int2", "_int4", "_text",
422+
"_oid", "_varchar", "_int8", "_float4", "_float8",
423+
"_abstime", "_date", "_time", "_timestamp", "_numeric",
424+
"_bytea"
425+
};
426+
427+
/*
428+
* This table holds the JDBC type for each entry above.
429+
*
430+
* Note: This must be in the same order as above
431+
*
432+
* Tip: keep these grouped together by the Types. value
433+
*/
434+
private static final int jdbc3Typei[] = {
435+
Types.SMALLINT,
436+
Types.INTEGER, Types.INTEGER,
437+
Types.BIGINT,
438+
Types.DOUBLE, Types.DOUBLE,
439+
Types.NUMERIC,
440+
Types.REAL,
441+
Types.DOUBLE,
442+
Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR,
443+
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
444+
Types.BINARY,
445+
Types.BIT,
446+
Types.DATE,
447+
Types.TIME,
448+
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
449+
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
450+
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
451+
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
452+
Types.ARRAY
453+
};
378454

379455
}
380456

0 commit comments

Comments
 (0)