aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Cramer <davec@fastcrypt.com>2002-03-09 17:36:14 +0000
committerDave Cramer <davec@fastcrypt.com>2002-03-09 17:36:14 +0000
commitee2154829e3fe715f166646bdf9f43e9a102a694 (patch)
tree5a9e8cd0e787429e6d9817721755f4f9c02f19b2 /src
parentc422b5ca6b0dd9b8a2d1d7b8b437e14f3ca79052 (diff)
downloadpostgresql-ee2154829e3fe715f166646bdf9f43e9a102a694.tar.gz
postgresql-ee2154829e3fe715f166646bdf9f43e9a102a694.zip
Added a check for not calling next() before getting objects from the result set,
moved the check for columnIndex into same call check at the top of all getXXX added appropriate error
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/jdbc/org/postgresql/ResultSet.java5
-rw-r--r--src/interfaces/jdbc/org/postgresql/errors.properties1
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java11
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java15
4 files changed, 18 insertions, 14 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/ResultSet.java b/src/interfaces/jdbc/org/postgresql/ResultSet.java
index 768a489e6f3..6e533eed010 100644
--- a/src/interfaces/jdbc/org/postgresql/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/ResultSet.java
@@ -255,5 +255,10 @@ public abstract class ResultSet
else
this.warnings = warnings;
}
+ protected void checkResultSet( int column ) throws SQLException
+ {
+ if ( this_row == null ) throw new PSQLException("postgresql.res.nextrequired");
+ if ( column < 1 || column > fields.length ) throw new PSQLException("postgresql.res.colrange" );
+ }
}
diff --git a/src/interfaces/jdbc/org/postgresql/errors.properties b/src/interfaces/jdbc/org/postgresql/errors.properties
index f8054dd1fab..7c5b32eb3f1 100644
--- a/src/interfaces/jdbc/org/postgresql/errors.properties
+++ b/src/interfaces/jdbc/org/postgresql/errors.properties
@@ -58,6 +58,7 @@ postgresql.res.badtime:Bad Time {0}
postgresql.res.badtimestamp:Bad Timestamp Format at {0} in {1}
postgresql.res.colname:The column name {0} not found.
postgresql.res.colrange:The column index is out of range.
+postgresql.res.nextrequired:Result set not positioned properly, perhaps you need to call next().
postgresql.serial.interface:You cannot serialize an interface.
postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters.
postgresql.serial.noclass:No class found for {0}.
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
index 949b919541e..02a5195b954 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
@@ -155,9 +155,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public String getString(int columnIndex) throws SQLException
{
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
-
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -388,9 +386,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public byte[] getBytes(int columnIndex) throws SQLException
{
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
-
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (!wasNullFlag)
{
@@ -623,6 +619,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getAsciiStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -665,6 +662,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getUnicodeStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -707,6 +705,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getBinaryStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
index a983284e5cc..dd12cda7da7 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
@@ -162,9 +162,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public String getString(int columnIndex) throws SQLException
{
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
-
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -315,9 +313,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public byte[] getBytes(int columnIndex) throws SQLException
{
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
-
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (!wasNullFlag)
{
@@ -424,6 +420,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getAsciiStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -469,6 +466,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getUnicodeStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -511,6 +509,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
*/
public InputStream getBinaryStream(int columnIndex) throws SQLException
{
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
return null;
@@ -724,8 +723,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
{
Field field;
- if (columnIndex < 1 || columnIndex > fields.length)
- throw new PSQLException("postgresql.res.colrange");
+ checkResultSet( columnIndex );
wasNullFlag = (this_row[columnIndex - 1] == null);
if (wasNullFlag)
@@ -941,6 +939,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public java.io.Reader getCharacterStream(int i) throws SQLException
{
+ checkResultSet( i );
wasNullFlag = (this_row[i - 1] == null);
if (wasNullFlag)
return null;