ResultSet.java 42.3 KB
Newer Older
Peter Mount's avatar
Peter Mount committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package org.postgresql.jdbc2;

// 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.util.*;

/**
 * A ResultSet provides access to a table of data generated by executing a
 * Statement.  The table rows are retrieved in sequence.  Within a row its
 * column values can be accessed in any order.
 *
24
 * <P>A ResultSet maintains a cursor pointing to its current row of data.
Peter Mount's avatar
Peter Mount committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
 * Initially the cursor is positioned before the first row.  The 'next'
 * method moves the cursor to the next row.
 *
 * <P>The getXXX methods retrieve column values for the current row.  You can
 * retrieve values either using the index number of the column, or by using
 * the name of the column.  In general using the column index will be more
 * efficient.  Columns are numbered from 1.
 *
 * <P>For maximum portability, ResultSet columns within each row should be read
 * in left-to-right order and each column should be read only once.
 *
 *<P> For the getXXX methods, the JDBC driver attempts to convert the
 * underlying data to the specified Java type and returns a suitable Java
 * value.  See the JDBC specification for allowable mappings from SQL types
 * to Java types with the ResultSet getXXX methods.
 *
 * <P>Column names used as input to getXXX methods are case insenstive.  When
 * performing a getXXX using a column name, if several columns have the same
 * name, then the value of the first matching column will be returned.  The
 * column name option is designed to be used when column names are used in the
 * SQL Query.  For columns that are NOT explicitly named in the query, it is
 * best to use column numbers.  If column names were used there is no way for
 * the programmer to guarentee that they actually refer to the intended
 * columns.
 *
50 51
 * <P>A ResultSet is automatically closed by the Statement that generated it
 * when that Statement is closed, re-executed, or is used to retrieve the
Peter Mount's avatar
Peter Mount committed
52 53 54 55 56 57 58 59
 * next result from a sequence of multiple results.
 *
 * <P>The number, types and properties of a ResultSet's columns are provided by
 * the ResultSetMetaData object returned by the getMetaData method.
 *
 * @see ResultSetMetaData
 * @see java.sql.ResultSet
 */
60
public class ResultSet extends org.postgresql.ResultSet implements java.sql.ResultSet
Peter Mount's avatar
Peter Mount committed
61
{
62 63
  protected org.postgresql.jdbc2.Statement statement;

Peter Mount's avatar
Peter Mount committed
64 65 66 67 68
  /**
   * StringBuffer used by getTimestamp
   */
  private StringBuffer sbuf;

Peter Mount's avatar
Peter Mount committed
69 70 71 72 73 74 75 76 77 78 79
  /**
   * Create a new ResultSet - Note that we create ResultSets to
   * represent the results of everything.
   *
   * @param fields an array of Field objects (basically, the
   *	ResultSet MetaData)
   * @param tuples Vector of the actual data
   * @param status the status string returned from the back end
   * @param updateCount the number of rows affected by the operation
   * @param cursor the positioned update/delete cursor name
   */
80
  public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID)
Peter Mount's avatar
Peter Mount committed
81
  {
82
      super(conn,fields,tuples,status,updateCount,insertOID);
Peter Mount's avatar
Peter Mount committed
83
  }
84

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
  /**
   * Create a new ResultSet - Note that we create ResultSets to
   * represent the results of everything.
   *
   * @param fields an array of Field objects (basically, the
   *	ResultSet MetaData)
   * @param tuples Vector of the actual data
   * @param status the status string returned from the back end
   * @param updateCount the number of rows affected by the operation
   * @param cursor the positioned update/delete cursor name
   */
  public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
  {
      super(conn,fields,tuples,status,updateCount,0);
  }
100

Peter Mount's avatar
Peter Mount committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
  /**
   * A ResultSet is initially positioned before its first row,
   * the first call to next makes the first row the current row;
   * the second call makes the second row the current row, etc.
   *
   * <p>If an input stream from the previous row is open, it is
   * implicitly closed.  The ResultSet's warning chain is cleared
   * when a new row is read
   *
   * @return true if the new current is valid; false if there are no
   *	more rows
   * @exception SQLException if a database access error occurs
   */
  public boolean next() throws SQLException
  {
    if (++current_row >= rows.size())
      return false;
    this_row = (byte [][])rows.elementAt(current_row);
    return true;
  }
121

Peter Mount's avatar
Peter Mount committed
122 123 124 125 126 127 128 129 130
  /**
   * In some cases, it is desirable to immediately release a ResultSet
   * database and JDBC resources instead of waiting for this to happen
   * when it is automatically closed.  The close method provides this
   * immediate release.
   *
   * <p><B>Note:</B> A ResultSet is automatically closed by the Statement
   * the Statement that generated it when that Statement is closed,
   * re-executed, or is used to retrieve the next result from a sequence
131
   * of multiple results.  A ResultSet is also automatically closed
Peter Mount's avatar
Peter Mount committed
132 133 134 135 136 137
   * when it is garbage collected.
   *
   * @exception SQLException if a database access error occurs
   */
  public void close() throws SQLException
  {
138
    //release resources held (memory for tuples)
139 140 141 142
    if(rows!=null) {
      rows.setSize(0);
      rows=null;
    }
Peter Mount's avatar
Peter Mount committed
143
  }
144

Peter Mount's avatar
Peter Mount committed
145 146 147 148 149 150 151 152 153 154 155 156 157
  /**
   * A column may have the value of SQL NULL; wasNull() reports whether
   * the last column read had this special value.  Note that you must
   * first call getXXX on a column to try to read its value and then
   * call wasNull() to find if the value was SQL NULL
   *
   * @return true if the last column read was SQL NULL
   * @exception SQLException if a database access error occurred
   */
  public boolean wasNull() throws SQLException
  {
    return wasNullFlag;
  }
158

Peter Mount's avatar
Peter Mount committed
159 160 161 162 163 164 165 166 167 168 169
  /**
   * Get the value of a column in the current row as a Java String
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return the column value, null for SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public String getString(int columnIndex) throws SQLException
  {
    if (columnIndex < 1 || columnIndex > fields.length)
      throw new PSQLException("postgresql.res.colrange");
170

Peter Mount's avatar
Peter Mount committed
171 172 173
    wasNullFlag = (this_row[columnIndex - 1] == null);
    if(wasNullFlag)
      return null;
174

175 176 177 178 179 180 181 182 183 184
    String encoding = connection.getEncoding();
    if (encoding == null)
        return new String(this_row[columnIndex - 1]);
    else {
        try {
            return new String(this_row[columnIndex - 1], encoding);
        } catch (UnsupportedEncodingException unse) {
            throw new PSQLException("postgresql.res.encoding", unse);
        }
    }
Peter Mount's avatar
Peter Mount committed
185
  }
186

Peter Mount's avatar
Peter Mount committed
187 188 189 190 191 192 193 194 195 196
  /**
   * Get the value of a column in the current row as a Java boolean
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return the column value, false for SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public boolean getBoolean(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
197

Peter Mount's avatar
Peter Mount committed
198 199 200
    if (s != null)
      {
	int c = s.charAt(0);
Bruce Momjian's avatar
Bruce Momjian committed
201
	return ((c == 't') || (c == 'T') || (c == '1'));
Peter Mount's avatar
Peter Mount committed
202 203 204
      }
    return false;		// SQL NULL
  }
205

Peter Mount's avatar
Peter Mount committed
206 207 208 209 210 211 212 213 214 215
  /**
   * Get the value of a column in the current row as a Java byte.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public byte getByte(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
216

Peter Mount's avatar
Peter Mount committed
217 218 219 220 221 222 223 224 225 226 227
    if (s != null)
      {
	try
	  {
	    return Byte.parseByte(s);
	  } catch (NumberFormatException e) {
	    throw new PSQLException("postgresql.res.badbyte",s);
	  }
      }
    return 0;		// SQL NULL
  }
228

Peter Mount's avatar
Peter Mount committed
229 230 231 232 233 234 235 236 237
  /**
   * Get the value of a column in the current row as a Java short.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public short getShort(int columnIndex) throws SQLException
  {
238
    String s = getFixedString(columnIndex);
239

Peter Mount's avatar
Peter Mount committed
240 241 242 243 244 245 246 247 248 249 250
    if (s != null)
      {
	try
	  {
	    return Short.parseShort(s);
	  } catch (NumberFormatException e) {
	    throw new PSQLException("postgresql.res.badshort",s);
	  }
      }
    return 0;		// SQL NULL
  }
251

Peter Mount's avatar
Peter Mount committed
252 253 254 255 256 257 258 259 260
  /**
   * Get the value of a column in the current row as a Java int.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public int getInt(int columnIndex) throws SQLException
  {
261
    String s = getFixedString(columnIndex);
262

Peter Mount's avatar
Peter Mount committed
263 264 265 266 267 268 269 270 271 272 273
    if (s != null)
      {
	try
	  {
	    return Integer.parseInt(s);
	  } catch (NumberFormatException e) {
	    throw new PSQLException ("postgresql.res.badint",s);
	  }
      }
    return 0;		// SQL NULL
  }
274

Peter Mount's avatar
Peter Mount committed
275 276 277 278 279 280 281 282 283
  /**
   * Get the value of a column in the current row as a Java long.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public long getLong(int columnIndex) throws SQLException
  {
284
    String s = getFixedString(columnIndex);
285

Peter Mount's avatar
Peter Mount committed
286 287 288 289 290 291 292 293 294 295 296
    if (s != null)
      {
	try
	  {
	    return Long.parseLong(s);
	  } catch (NumberFormatException e) {
	    throw new PSQLException ("postgresql.res.badlong",s);
	  }
      }
    return 0;		// SQL NULL
  }
297

Peter Mount's avatar
Peter Mount committed
298 299 300 301 302 303 304 305 306
  /**
   * Get the value of a column in the current row as a Java float.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public float getFloat(int columnIndex) throws SQLException
  {
307
    String s = getFixedString(columnIndex);
308

Peter Mount's avatar
Peter Mount committed
309 310 311 312 313 314 315 316 317 318 319
    if (s != null)
      {
	try
	  {
	    return Float.valueOf(s).floatValue();
	  } catch (NumberFormatException e) {
	    throw new PSQLException ("postgresql.res.badfloat",s);
	  }
      }
    return 0;		// SQL NULL
  }
320

Peter Mount's avatar
Peter Mount committed
321 322 323 324 325 326 327 328 329
  /**
   * Get the value of a column in the current row as a Java double.
   *
   * @param columnIndex the first column is 1, the second is 2,...
   * @return the column value; 0 if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public double getDouble(int columnIndex) throws SQLException
  {
330
    String s = getFixedString(columnIndex);
331

Peter Mount's avatar
Peter Mount committed
332 333 334 335 336 337 338 339 340 341 342
    if (s != null)
      {
	try
	  {
	    return Double.valueOf(s).doubleValue();
	  } catch (NumberFormatException e) {
	    throw new PSQLException ("postgresql.res.baddouble",s);
	  }
      }
    return 0;		// SQL NULL
  }
343

Peter Mount's avatar
Peter Mount committed
344
  /**
345
   * Get the value of a column in the current row as a
Peter Mount's avatar
Peter Mount committed
346 347 348 349 350 351 352 353 354 355
   * java.math.BigDecimal object
   *
   * @param columnIndex  the first column is 1, the second is 2...
   * @param scale the number of digits to the right of the decimal
   * @return the column value; if the value is SQL NULL, null
   * @exception SQLException if a database access error occurs
   * @deprecated
   */
  public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
  {
356
    String s = getFixedString(columnIndex);
Peter Mount's avatar
Peter Mount committed
357
    BigDecimal val;
358

Peter Mount's avatar
Peter Mount committed
359 360
    if (s != null)
      {
361

362 363
        try
          {
Peter Mount's avatar
Peter Mount committed
364 365 366 367
	    val = new BigDecimal(s);
	  } catch (NumberFormatException e) {
	    throw new PSQLException ("postgresql.res.badbigdec",s);
	  }
368
	if (scale==-1) return val;
Peter Mount's avatar
Peter Mount committed
369 370 371 372 373 374 375 376 377
	  try
	    {
	      return val.setScale(scale);
	    } catch (ArithmeticException e) {
	      throw new PSQLException ("postgresql.res.badbigdec",s);
	    }
      }
    return null;		// SQL NULL
  }
378

Peter Mount's avatar
Peter Mount committed
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
  /**
   * Get the value of a column in the current row as a Java byte array.
   *
   * <p>In normal use, the bytes represent the raw values returned by the
   * backend. However, if the column is an OID, then it is assumed to
   * refer to a Large Object, and that object is returned as a byte array.
   *
   * <p><b>Be warned</b> If the large object is huge, then you may run out
   * of memory.
   *
   * @param columnIndex the first column is 1, the second is 2, ...
   * @return the column value; if the value is SQL NULL, the result
   *	is null
   * @exception SQLException if a database access error occurs
   */
  public byte[] getBytes(int columnIndex) throws SQLException
  {
    if (columnIndex < 1 || columnIndex > fields.length)
      throw new PSQLException("postgresql.res.colrange");
    wasNullFlag = (this_row[columnIndex - 1] == null);
399

Peter Mount's avatar
Peter Mount committed
400 401 402 403 404 405 406 407 408
    // Handle OID's as BLOBS
    if(!wasNullFlag)
      if( fields[columnIndex - 1].getOID() == 26) {
	LargeObjectManager lom = connection.getLargeObjectAPI();
	LargeObject lob = lom.open(getInt(columnIndex));
	byte buf[] = lob.read(lob.size());
	lob.close();
	return buf;
      }
409

Peter Mount's avatar
Peter Mount committed
410 411
    return this_row[columnIndex - 1];
  }
412

Peter Mount's avatar
Peter Mount committed
413 414 415 416 417 418 419 420 421 422 423 424 425
  /**
   * Get the value of a column in the current row as a java.sql.Date
   * object
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return the column value; null if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public java.sql.Date getDate(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
    if(s==null)
      return null;
426 427

    return java.sql.Date.valueOf(s);
Peter Mount's avatar
Peter Mount committed
428
  }
429

Peter Mount's avatar
Peter Mount committed
430 431 432 433 434 435 436 437 438 439 440
  /**
   * Get the value of a column in the current row as a java.sql.Time
   * object
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return the column value; null if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public Time getTime(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
441

442 443 444 445
    if(s==null)
      return null; // SQL NULL

    return java.sql.Time.valueOf(s);
Peter Mount's avatar
Peter Mount committed
446
  }
447

Peter Mount's avatar
Peter Mount committed
448
  /**
449
   * Get the value of a column in the current row as a
Peter Mount's avatar
Peter Mount committed
450 451 452 453 454 455 456 457 458 459 460
   * java.sql.Timestamp object
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return the column value; null if SQL NULL
   * @exception SQLException if a database access error occurs
   */
  public Timestamp getTimestamp(int columnIndex) throws SQLException
  {
    String s = getString(columnIndex);
    if(s==null)
	return null;
461

462 463 464 465 466 467 468 469 470 471 472 473 474
    boolean subsecond;
    //if string contains a '.' we have fractional seconds
    if (s.indexOf('.') == -1) {
      subsecond = false;
    } else {
      subsecond = true;
    }

    //here we are modifying the string from ISO format to a format java can understand
    //java expects timezone info as 'GMT-08:00' instead of '-08' in postgres ISO format
    //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+/-...
    //as well as adds a third digit for partial seconds if necessary
Peter Mount's avatar
Peter Mount committed
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
    synchronized(this) {
      // 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 == '-') {
        sbuf.setLength(sbuf.length()-3);
        if (subsecond)  {
          sbuf.append('0').append("GMT").append(s.substring(s.length()-3)).append(":00");
        } else {
          sbuf.append("GMT").append(s.substring(s.length()-3)).append(":00");
        }
      } else if (subsecond) {
        sbuf.append('0');
497 498
      }

Peter Mount's avatar
Peter Mount committed
499 500 501
      // could optimize this a tad to remove too many object creations...
      SimpleDateFormat df = null;

502
      if (sbuf.length()>23 && subsecond) {
Peter Mount's avatar
Peter Mount committed
503
        df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSzzzzzzzzz");
504
      } else if (sbuf.length()>23 && !subsecond) {
Peter Mount's avatar
Peter Mount committed
505
        df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
506
      } else if (sbuf.length()>10 && subsecond) {
Peter Mount's avatar
Peter Mount committed
507
        df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
508
      } else if (sbuf.length()>10 && !subsecond) {
Peter Mount's avatar
Peter Mount committed
509 510 511 512
        df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      } else {
        df = new SimpleDateFormat("yyyy-MM-dd");
      }
513

Peter Mount's avatar
Peter Mount committed
514 515 516 517 518
      try {
          return new Timestamp(df.parse(sbuf.toString()).getTime());
      } catch(ParseException e) {
          throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s);
      }
Peter Mount's avatar
Peter Mount committed
519 520
    }
  }
521

Peter Mount's avatar
Peter Mount committed
522 523
  /**
   * A column value can be retrieved as a stream of ASCII characters
524
   * and then read in chunks from the stream.  This method is
Peter Mount's avatar
Peter Mount committed
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
   * particular suitable for retrieving large LONGVARCHAR values.
   * The JDBC driver will do any necessary conversion from the
   * database format into ASCII.
   *
   * <p><B>Note:</B> All the data in the returned stream must be read
   * prior to getting the value of any other column.  The next call
   * to a get method implicitly closes the stream.  Also, a stream
   * may return 0 for available() whether there is data available
   * or not.
   *
   *<p> We implement an ASCII stream as a Binary stream - we should really
   * do the data conversion, but I cannot be bothered to implement this
   * right now.
   *
   * @param columnIndex the first column is 1, the second is 2, ...
   * @return a Java InputStream that delivers the database column
   * 	value as a stream of one byte ASCII characters.  If the
   *	value is SQL NULL then the result is null
   * @exception SQLException if a database access error occurs
   * @see getBinaryStream
   */
  public InputStream getAsciiStream(int columnIndex) throws SQLException
  {
    return getBinaryStream(columnIndex);
  }
550

Peter Mount's avatar
Peter Mount committed
551 552 553 554 555 556 557 558 559 560 561 562 563
  /**
   * A column value can also be retrieved as a stream of Unicode
   * characters. We implement this as a binary stream.
   *
   * ** DEPRECATED IN JDBC 2 **
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return a Java InputStream that delivers the database column value
   * 	as a stream of two byte Unicode characters.  If the value is
   *	SQL NULL, then the result is null
   * @exception SQLException if a database access error occurs
   * @see getAsciiStream
   * @see getBinaryStream
Peter Mount's avatar
Peter Mount committed
564
   * @deprecated in JDBC2.0
Peter Mount's avatar
Peter Mount committed
565 566 567 568 569
   */
  public InputStream getUnicodeStream(int columnIndex) throws SQLException
  {
    return getBinaryStream(columnIndex);
  }
570

Peter Mount's avatar
Peter Mount committed
571 572 573 574 575 576 577 578 579 580 581 582 583 584
  /**
   * A column value can also be retrieved as a binary strea.  This
   * method is suitable for retrieving LONGVARBINARY values.
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return a Java InputStream that delivers the database column value
   * as a stream of bytes.  If the value is SQL NULL, then the result
   * is null
   * @exception SQLException if a database access error occurs
   * @see getAsciiStream
   * @see getUnicodeStream
   */
  public InputStream getBinaryStream(int columnIndex) throws SQLException
  {
585 586 587 588 589 590 591 592 593
    // New in 7.1 Handle OID's as BLOBS so return the input stream
    if(!wasNullFlag)
      if( fields[columnIndex - 1].getOID() == 26) {
	LargeObjectManager lom = connection.getLargeObjectAPI();
	LargeObject lob = lom.open(getInt(columnIndex));
        return lob.getInputStream();
      }

    // Not an OID so fake the stream
Peter Mount's avatar
Peter Mount committed
594
    byte b[] = getBytes(columnIndex);
595

Peter Mount's avatar
Peter Mount committed
596 597 598 599
    if (b != null)
      return new ByteArrayInputStream(b);
    return null;		// SQL NULL
  }
600

Peter Mount's avatar
Peter Mount committed
601 602 603 604 605 606 607 608 609 610 611 612
  /**
   * The following routines simply convert the columnName into
   * a columnIndex and then call the appropriate routine above.
   *
   * @param columnName is the SQL name of the column
   * @return the column value
   * @exception SQLException if a database access error occurs
   */
  public String getString(String columnName) throws SQLException
  {
    return getString(findColumn(columnName));
  }
613

Peter Mount's avatar
Peter Mount committed
614 615 616 617
  public boolean getBoolean(String columnName) throws SQLException
  {
    return getBoolean(findColumn(columnName));
  }
618

Peter Mount's avatar
Peter Mount committed
619 620
  public byte getByte(String columnName) throws SQLException
  {
621

Peter Mount's avatar
Peter Mount committed
622 623
    return getByte(findColumn(columnName));
  }
624

Peter Mount's avatar
Peter Mount committed
625 626 627 628
  public short getShort(String columnName) throws SQLException
  {
    return getShort(findColumn(columnName));
  }
629

Peter Mount's avatar
Peter Mount committed
630 631 632 633
  public int getInt(String columnName) throws SQLException
  {
    return getInt(findColumn(columnName));
  }
634

Peter Mount's avatar
Peter Mount committed
635 636 637 638
  public long getLong(String columnName) throws SQLException
  {
    return getLong(findColumn(columnName));
  }
639

Peter Mount's avatar
Peter Mount committed
640 641 642 643
  public float getFloat(String columnName) throws SQLException
  {
    return getFloat(findColumn(columnName));
  }
644

Peter Mount's avatar
Peter Mount committed
645 646 647 648
  public double getDouble(String columnName) throws SQLException
  {
    return getDouble(findColumn(columnName));
  }
649

Peter Mount's avatar
Peter Mount committed
650 651 652 653 654 655 656
    /**
     * @deprecated
     */
  public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException
  {
    return getBigDecimal(findColumn(columnName), scale);
  }
657

Peter Mount's avatar
Peter Mount committed
658 659 660 661
  public byte[] getBytes(String columnName) throws SQLException
  {
    return getBytes(findColumn(columnName));
  }
662

Peter Mount's avatar
Peter Mount committed
663 664 665 666
  public java.sql.Date getDate(String columnName) throws SQLException
  {
    return getDate(findColumn(columnName));
  }
667

Peter Mount's avatar
Peter Mount committed
668 669 670 671
  public Time getTime(String columnName) throws SQLException
  {
    return getTime(findColumn(columnName));
  }
672

Peter Mount's avatar
Peter Mount committed
673 674 675 676
  public Timestamp getTimestamp(String columnName) throws SQLException
  {
    return getTimestamp(findColumn(columnName));
  }
677

Peter Mount's avatar
Peter Mount committed
678 679 680 681
  public InputStream getAsciiStream(String columnName) throws SQLException
  {
    return getAsciiStream(findColumn(columnName));
  }
682

Peter Mount's avatar
Peter Mount committed
683 684 685 686 687 688 689 690 691 692
    /**
     *
     * ** DEPRECATED IN JDBC 2 **
     *
     * @deprecated
     */
  public InputStream getUnicodeStream(String columnName) throws SQLException
  {
    return getUnicodeStream(findColumn(columnName));
  }
693

Peter Mount's avatar
Peter Mount committed
694 695 696 697
  public InputStream getBinaryStream(String columnName) throws SQLException
  {
    return getBinaryStream(findColumn(columnName));
  }
698

Peter Mount's avatar
Peter Mount committed
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
  /**
   * The first warning reported by calls on this ResultSet is
   * returned.  Subsequent ResultSet warnings will be chained
   * to this SQLWarning.
   *
   * <p>The warning chain is automatically cleared each time a new
   * row is read.
   *
   * <p><B>Note:</B> This warning chain only covers warnings caused by
   * ResultSet methods.  Any warnings caused by statement methods
   * (such as reading OUT parameters) will be chained on the
   * Statement object.
   *
   * @return the first SQLWarning or null;
   * @exception SQLException if a database access error occurs.
   */
  public SQLWarning getWarnings() throws SQLException
  {
    return warnings;
  }
719

Peter Mount's avatar
Peter Mount committed
720 721 722 723 724 725 726 727 728 729
  /**
   * After this call, getWarnings returns null until a new warning
   * is reported for this ResultSet
   *
   * @exception SQLException if a database access error occurs
   */
  public void clearWarnings() throws SQLException
  {
    warnings = null;
  }
730

Peter Mount's avatar
Peter Mount committed
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
  /**
   * Get the name of the SQL cursor used by this ResultSet
   *
   * <p>In SQL, a result table is retrieved though a cursor that is
   * named.  The current row of a result can be updated or deleted
   * using a positioned update/delete statement that references
   * the cursor name.
   *
   * <p>JDBC supports this SQL feature by providing the name of the
   * SQL cursor used by a ResultSet.  The current row of a ResulSet
   * is also the current row of this SQL cursor.
   *
   * <p><B>Note:</B> If positioned update is not supported, a SQLException
   * is thrown.
   *
   * @return the ResultSet's SQL cursor name.
   * @exception SQLException if a database access error occurs
   */
  public String getCursorName() throws SQLException
  {
    return connection.getCursorName();
  }
753

Peter Mount's avatar
Peter Mount committed
754 755 756 757 758 759 760 761 762 763 764
  /**
   * The numbers, types and properties of a ResultSet's columns are
   * provided by the getMetaData method
   *
   * @return a description of the ResultSet's columns
   * @exception SQLException if a database access error occurs
   */
  public java.sql.ResultSetMetaData getMetaData() throws SQLException
  {
    return new ResultSetMetaData(rows, fields);
  }
765

Peter Mount's avatar
Peter Mount committed
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
  /**
   * Get the value of a column in the current row as a Java object
   *
   * <p>This method will return the value of the given column as a
   * Java object.  The type of the Java object will be the default
   * Java Object type corresponding to the column's SQL type, following
   * the mapping specified in the JDBC specification.
   *
   * <p>This method may also be used to read database specific abstract
   * data types.
   *
   * @param columnIndex the first column is 1, the second is 2...
   * @return a Object holding the column value
   * @exception SQLException if a database access error occurs
   */
  public Object getObject(int columnIndex) throws SQLException
  {
    Field field;
784

Peter Mount's avatar
Peter Mount committed
785 786
    if (columnIndex < 1 || columnIndex > fields.length)
      throw new PSQLException("postgresql.res.colrange");
787

788 789 790
    wasNullFlag = (this_row[columnIndex - 1] == null);
    if(wasNullFlag)
      return null;
791

Peter Mount's avatar
Peter Mount committed
792
    field = fields[columnIndex - 1];
793

Peter Mount's avatar
Peter Mount committed
794 795 796 797 798
    // some fields can be null, mainly from those returned by MetaData methods
    if(field==null) {
      wasNullFlag=true;
      return null;
    }
799

Peter Mount's avatar
Peter Mount committed
800 801 802 803 804 805 806 807 808 809 810
    switch (field.getSQLType())
      {
      case Types.BIT:
	return new Boolean(getBoolean(columnIndex));
      case Types.SMALLINT:
	return new Integer(getInt(columnIndex));
      case Types.INTEGER:
	return new Integer(getInt(columnIndex));
      case Types.BIGINT:
	return new Long(getLong(columnIndex));
      case Types.NUMERIC:
811 812
	return getBigDecimal
	    (columnIndex, (field.mod==-1)?-1:((field.mod-4) & 0xffff));
Peter Mount's avatar
Peter Mount committed
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
      case Types.REAL:
	return new Float(getFloat(columnIndex));
      case Types.DOUBLE:
	return new Double(getDouble(columnIndex));
      case Types.CHAR:
      case Types.VARCHAR:
	return getString(columnIndex);
      case Types.DATE:
	return getDate(columnIndex);
      case Types.TIME:
	return getTime(columnIndex);
      case Types.TIMESTAMP:
	return getTimestamp(columnIndex);
      default:
	return connection.getObject(field.getTypeName(), getString(columnIndex));
      }
  }
830

Peter Mount's avatar
Peter Mount committed
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
  /**
   * Get the value of a column in the current row as a Java object
   *
   *<p> This method will return the value of the given column as a
   * Java object.  The type of the Java object will be the default
   * Java Object type corresponding to the column's SQL type, following
   * the mapping specified in the JDBC specification.
   *
   * <p>This method may also be used to read database specific abstract
   * data types.
   *
   * @param columnName is the SQL name of the column
   * @return a Object holding the column value
   * @exception SQLException if a database access error occurs
   */
  public Object getObject(String columnName) throws SQLException
  {
    return getObject(findColumn(columnName));
  }
850

Peter Mount's avatar
Peter Mount committed
851 852 853 854 855 856 857 858 859 860
  /**
   * Map a ResultSet column name to a ResultSet column index
   *
   * @param columnName the name of the column
   * @return the column index
   * @exception SQLException if a database access error occurs
   */
  public int findColumn(String columnName) throws SQLException
  {
    int i;
861

Peter Mount's avatar
Peter Mount committed
862 863 864 865 866
    for (i = 0 ; i < fields.length; ++i)
      if (fields[i].name.equalsIgnoreCase(columnName))
	return (i+1);
    throw new PSQLException ("postgresql.res.colname",columnName);
  }
867

Peter Mount's avatar
Peter Mount committed
868
    // ** JDBC 2 Extensions **
869

Peter Mount's avatar
Peter Mount committed
870 871
    public boolean absolute(int index) throws SQLException
    {
872 873 874 875
	// index is 1-based, but internally we use 0-based indices
	int internalIndex;

	if (index==0)
876
	    throw new SQLException("Cannot move to index of 0");
877 878 879

	//if index<0, count from the end of the result set, but check
	//to be sure that it is not beyond the first index
880
	if (index<0)
881 882 883 884 885 886
	    if (index>=-rows.size())
		internalIndex=rows.size()+index;
	    else {
		beforeFirst();
		return false;
	    }
887 888 889

	//must be the case that index>0,
	//find the correct place, assuming that
890 891 892 893 894
	//the index is not too large
	if (index<=rows.size())
	    internalIndex = index-1;
	else {
	    afterLast();
Peter Mount's avatar
Peter Mount committed
895
	    return false;
896 897 898 899
	}

	current_row=internalIndex;
	this_row = (byte [][])rows.elementAt(internalIndex);
Peter Mount's avatar
Peter Mount committed
900 901
	return true;
    }
902

Peter Mount's avatar
Peter Mount committed
903 904
    public void afterLast() throws SQLException
    {
905 906
	if (rows.size() > 0)
		current_row = rows.size();
Peter Mount's avatar
Peter Mount committed
907
    }
908

Peter Mount's avatar
Peter Mount committed
909 910
    public void beforeFirst() throws SQLException
    {
911 912
	if (rows.size() > 0)
		current_row = -1;
Peter Mount's avatar
Peter Mount committed
913
    }
914

Peter Mount's avatar
Peter Mount committed
915 916
    public void cancelRowUpdates() throws SQLException
    {
917 918
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
919
    }
920

Peter Mount's avatar
Peter Mount committed
921 922
    public void deleteRow() throws SQLException
    {
923 924
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
925
    }
926

Peter Mount's avatar
Peter Mount committed
927 928 929 930 931 932 933 934
    public boolean first() throws SQLException
    {
	if (rows.size() <= 0)
	    return false;
	current_row = 0;
	this_row = (byte [][])rows.elementAt(current_row);
	return true;
    }
935

Peter Mount's avatar
Peter Mount committed
936 937 938 939
    public Array getArray(String colName) throws SQLException
    {
	return getArray(findColumn(colName));
    }
940

Peter Mount's avatar
Peter Mount committed
941 942 943 944
    public Array getArray(int i) throws SQLException
    {
	throw org.postgresql.Driver.notImplemented();
    }
945

Peter Mount's avatar
Peter Mount committed
946 947
    public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
    {
948 949
      // Now must call BigDecimal with a scale otherwise JBuilder barfs
      return getBigDecimal(columnIndex,0);
Peter Mount's avatar
Peter Mount committed
950
    }
951

Peter Mount's avatar
Peter Mount committed
952 953 954 955
    public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
    {
	return getBigDecimal(findColumn(columnName));
    }
956

Peter Mount's avatar
Peter Mount committed
957 958 959 960
    public Blob getBlob(String columnName) throws SQLException
    {
	return getBlob(findColumn(columnName));
    }
961

Peter Mount's avatar
Peter Mount committed
962 963 964 965
    public Blob getBlob(int i) throws SQLException
    {
	return new org.postgresql.largeobject.PGblob(connection,getInt(i));
    }
966

Peter Mount's avatar
Peter Mount committed
967 968 969 970
    public java.io.Reader getCharacterStream(String columnName) throws SQLException
    {
	return getCharacterStream(findColumn(columnName));
    }
971

Peter Mount's avatar
Peter Mount committed
972 973
    public java.io.Reader getCharacterStream(int i) throws SQLException
    {
974 975 976 977 978 979 980 981 982
      // New in 7.1
      try {
        String encoding = connection.getEncoding();
        if(encoding==null)
          return new InputStreamReader(getBinaryStream(i));
        return new InputStreamReader(getBinaryStream(i),encoding);
      } catch (UnsupportedEncodingException unse) {
        throw new PSQLException("postgresql.res.encoding", unse);
      }
Peter Mount's avatar
Peter Mount committed
983
    }
984

Peter Mount's avatar
Peter Mount committed
985 986 987
    /**
     * New in 7.1
     */
Peter Mount's avatar
Peter Mount committed
988 989 990 991
    public Clob getClob(String columnName) throws SQLException
    {
	return getClob(findColumn(columnName));
    }
992

Peter Mount's avatar
Peter Mount committed
993 994 995
    /**
     * New in 7.1
     */
Peter Mount's avatar
Peter Mount committed
996 997
    public Clob getClob(int i) throws SQLException
    {
Peter Mount's avatar
Peter Mount committed
998
	return new org.postgresql.largeobject.PGclob(connection,getInt(i));
Peter Mount's avatar
Peter Mount committed
999
    }
1000

Peter Mount's avatar
Peter Mount committed
1001 1002
    public int getConcurrency() throws SQLException
    {
1003 1004 1005 1006
        // New in 7.1 - The standard ResultSet class will now return
        // CONCUR_READ_ONLY. A sub-class will overide this if the query was
        // updateable.
	return CONCUR_READ_ONLY;
Peter Mount's avatar
Peter Mount committed
1007
    }
1008

Peter Mount's avatar
Peter Mount committed
1009 1010
    public java.sql.Date getDate(int i,java.util.Calendar cal) throws SQLException
    {
1011 1012 1013 1014
      // new in 7.1: If I read the specs, this should use cal only if we don't
      // store the timezone, and if we do, then act just like getDate()?
      // for now...
      return getDate(i);
Peter Mount's avatar
Peter Mount committed
1015
    }
1016

Peter Mount's avatar
Peter Mount committed
1017 1018
    public Time getTime(int i,java.util.Calendar cal) throws SQLException
    {
1019 1020 1021 1022
      // new in 7.1: If I read the specs, this should use cal only if we don't
      // store the timezone, and if we do, then act just like getTime()?
      // for now...
      return getTime(i);
Peter Mount's avatar
Peter Mount committed
1023
    }
1024

Peter Mount's avatar
Peter Mount committed
1025 1026
    public Timestamp getTimestamp(int i,java.util.Calendar cal) throws SQLException
    {
1027 1028 1029 1030
      // new in 7.1: If I read the specs, this should use cal only if we don't
      // store the timezone, and if we do, then act just like getDate()?
      // for now...
      return getTimestamp(i);
Peter Mount's avatar
Peter Mount committed
1031
    }
1032

Peter Mount's avatar
Peter Mount committed
1033 1034 1035 1036
    public java.sql.Date getDate(String c,java.util.Calendar cal) throws SQLException
    {
	return getDate(findColumn(c),cal);
    }
1037

Peter Mount's avatar
Peter Mount committed
1038 1039 1040 1041
    public Time getTime(String c,java.util.Calendar cal) throws SQLException
    {
	return getTime(findColumn(c),cal);
    }
1042

Peter Mount's avatar
Peter Mount committed
1043 1044 1045 1046
    public Timestamp getTimestamp(String c,java.util.Calendar cal) throws SQLException
    {
	return getTimestamp(findColumn(c),cal);
    }
1047

Peter Mount's avatar
Peter Mount committed
1048 1049
    public int getFetchDirection() throws SQLException
    {
1050 1051
      // new in 7.1: PostgreSQL normally sends rows first->last
      return FETCH_FORWARD;
Peter Mount's avatar
Peter Mount committed
1052
    }
1053

Peter Mount's avatar
Peter Mount committed
1054 1055
    public int getFetchSize() throws SQLException
    {
1056 1057 1058 1059
      // new in 7.1: In this implementation we return the entire result set, so
      // here return the number of rows we have. Sub-classes can return a proper
      // value
      return rows.size();
Peter Mount's avatar
Peter Mount committed
1060
    }
1061

Peter Mount's avatar
Peter Mount committed
1062 1063 1064 1065
    public Object getObject(String columnName,java.util.Map map) throws SQLException
    {
	return getObject(findColumn(columnName),map);
    }
1066 1067 1068 1069 1070 1071

    /**
     * This checks against map for the type of column i, and if found returns
     * an object based on that mapping. The class must implement the SQLData
     * interface.
     */
Peter Mount's avatar
Peter Mount committed
1072 1073
    public Object getObject(int i,java.util.Map map) throws SQLException
    {
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
      /* In preparation
      SQLInput s = new PSQLInput(this,i);
      String t = getTypeName(i);
      SQLData o = (SQLData) map.get(t);
      // If the type is not in the map, then pass to the existing code
      if(o==null)
        return getObject(i);
      o.readSQL(s,t);
      return o;
      */throw org.postgresql.Driver.notImplemented();
Peter Mount's avatar
Peter Mount committed
1084
    }
1085

Peter Mount's avatar
Peter Mount committed
1086 1087 1088 1089
    public Ref getRef(String columnName) throws SQLException
    {
	return getRef(findColumn(columnName));
    }
1090

Peter Mount's avatar
Peter Mount committed
1091 1092
    public Ref getRef(int i) throws SQLException
    {
1093 1094
      // new in 7.1: The backend doesn't yet have SQL3 REF types
      throw new PSQLException("postgresql.psqlnotimp");
Peter Mount's avatar
Peter Mount committed
1095
    }
1096

Peter Mount's avatar
Peter Mount committed
1097 1098
    public int getRow() throws SQLException
    {
1099
	return current_row + 1;
Peter Mount's avatar
Peter Mount committed
1100
    }
1101

Peter Mount's avatar
Peter Mount committed
1102 1103 1104
    // This one needs some thought, as not all ResultSets come from a statement
    public java.sql.Statement getStatement() throws SQLException
    {
1105
      return statement;
Peter Mount's avatar
Peter Mount committed
1106
    }
1107

Peter Mount's avatar
Peter Mount committed
1108 1109
    public int getType() throws SQLException
    {
1110 1111 1112 1113
	// New in 7.1. This implementation allows scrolling but is not able to
        // see any changes. Sub-classes may overide this to return a more
        // meaningful result.
        return TYPE_SCROLL_INSENSITIVE;
Peter Mount's avatar
Peter Mount committed
1114
    }
1115

Peter Mount's avatar
Peter Mount committed
1116 1117
    public void insertRow() throws SQLException
    {
1118 1119
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1120
    }
1121

Peter Mount's avatar
Peter Mount committed
1122 1123
    public boolean isAfterLast() throws SQLException
    {
1124
	return (current_row >= rows.size()  && rows.size() > 0);
Peter Mount's avatar
Peter Mount committed
1125
    }
1126

Peter Mount's avatar
Peter Mount committed
1127 1128
    public boolean isBeforeFirst() throws SQLException
    {
1129
	return (current_row < 0 && rows.size() > 0);
Peter Mount's avatar
Peter Mount committed
1130
    }
1131

Peter Mount's avatar
Peter Mount committed
1132 1133
    public boolean isFirst() throws SQLException
    {
1134
	return (current_row == 0 && rows.size() >= 0);
Peter Mount's avatar
Peter Mount committed
1135
    }
1136

Peter Mount's avatar
Peter Mount committed
1137 1138
    public boolean isLast() throws SQLException
    {
1139
	return (current_row == rows.size() -1  && rows.size() > 0);
Peter Mount's avatar
Peter Mount committed
1140
    }
1141

Peter Mount's avatar
Peter Mount committed
1142 1143 1144 1145 1146 1147 1148 1149
    public boolean last() throws SQLException
    {
	if (rows.size() <= 0)
	    return false;
	current_row = rows.size() - 1;
	this_row = (byte [][])rows.elementAt(current_row);
	return true;
    }
1150

Peter Mount's avatar
Peter Mount committed
1151 1152
    public void moveToCurrentRow() throws SQLException
    {
1153 1154
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1155
    }
1156

Peter Mount's avatar
Peter Mount committed
1157 1158
    public void moveToInsertRow() throws SQLException
    {
1159 1160
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1161
    }
1162

Peter Mount's avatar
Peter Mount committed
1163 1164 1165 1166 1167 1168 1169
    public boolean previous() throws SQLException
    {
	if (--current_row < 0)
	    return false;
	this_row = (byte [][])rows.elementAt(current_row);
	return true;
    }
1170

Peter Mount's avatar
Peter Mount committed
1171 1172
    public void refreshRow() throws SQLException
    {
1173
      throw new PSQLException("postgresql.notsensitive");
Peter Mount's avatar
Peter Mount committed
1174
    }
1175

Peter Mount's avatar
Peter Mount committed
1176 1177 1178
    // Peter: Implemented in 7.0
    public boolean relative(int rows) throws SQLException
    {
1179 1180
	//have to add 1 since absolute expects a 1-based index
	return absolute(current_row+1+rows);
Peter Mount's avatar
Peter Mount committed
1181
    }
1182

Peter Mount's avatar
Peter Mount committed
1183 1184
    public boolean rowDeleted() throws SQLException
    {
1185 1186 1187
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
      return false; // javac complains about not returning a value!
Peter Mount's avatar
Peter Mount committed
1188
    }
1189

Peter Mount's avatar
Peter Mount committed
1190 1191
    public boolean rowInserted() throws SQLException
    {
1192 1193 1194
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
      return false; // javac complains about not returning a value!
Peter Mount's avatar
Peter Mount committed
1195
    }
1196

Peter Mount's avatar
Peter Mount committed
1197 1198
    public boolean rowUpdated() throws SQLException
    {
1199 1200 1201
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
      return false; // javac complains about not returning a value!
Peter Mount's avatar
Peter Mount committed
1202
    }
1203

Peter Mount's avatar
Peter Mount committed
1204 1205
    public void setFetchDirection(int direction) throws SQLException
    {
1206 1207
      // In 7.1, the backend doesn't yet support this
      throw new PSQLException("postgresql.psqlnotimp");
Peter Mount's avatar
Peter Mount committed
1208
    }
1209

Peter Mount's avatar
Peter Mount committed
1210 1211
    public void setFetchSize(int rows) throws SQLException
    {
1212 1213
      // Sub-classes should implement this as part of their cursor support
      throw org.postgresql.Driver.notImplemented();
Peter Mount's avatar
Peter Mount committed
1214
    }
1215

Peter Mount's avatar
Peter Mount committed
1216 1217 1218 1219 1220
    public void updateAsciiStream(int columnIndex,
				  java.io.InputStream x,
				  int length
				  ) throws SQLException
    {
1221 1222
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1223
    }
1224

Peter Mount's avatar
Peter Mount committed
1225 1226 1227 1228 1229
    public void updateAsciiStream(String columnName,
				  java.io.InputStream x,
				  int length
				  ) throws SQLException
    {
1230
      updateAsciiStream(findColumn(columnName),x,length);
Peter Mount's avatar
Peter Mount committed
1231
    }
1232

Peter Mount's avatar
Peter Mount committed
1233 1234 1235 1236
    public void updateBigDecimal(int columnIndex,
				  java.math.BigDecimal x
				  ) throws SQLException
    {
1237 1238
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1239
    }
1240

Peter Mount's avatar
Peter Mount committed
1241 1242 1243 1244
    public void updateBigDecimal(String columnName,
				  java.math.BigDecimal x
				  ) throws SQLException
    {
1245
      updateBigDecimal(findColumn(columnName),x);
Peter Mount's avatar
Peter Mount committed
1246
    }
1247

Peter Mount's avatar
Peter Mount committed
1248 1249 1250 1251 1252
    public void updateBinaryStream(int columnIndex,
				  java.io.InputStream x,
				  int length
				  ) throws SQLException
    {
1253 1254
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1255
    }
1256

Peter Mount's avatar
Peter Mount committed
1257 1258 1259 1260 1261 1262 1263
    public void updateBinaryStream(String columnName,
				  java.io.InputStream x,
				  int length
				  ) throws SQLException
    {
	updateBinaryStream(findColumn(columnName),x,length);
    }
1264

Peter Mount's avatar
Peter Mount committed
1265 1266
    public void updateBoolean(int columnIndex,boolean x) throws SQLException
    {
1267 1268
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1269
    }
1270

Peter Mount's avatar
Peter Mount committed
1271 1272 1273 1274
    public void updateBoolean(String columnName,boolean x) throws SQLException
    {
	updateBoolean(findColumn(columnName),x);
    }
1275

Peter Mount's avatar
Peter Mount committed
1276 1277
    public void updateByte(int columnIndex,byte x) throws SQLException
    {
1278 1279
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1280
    }
1281

Peter Mount's avatar
Peter Mount committed
1282 1283 1284 1285
    public void updateByte(String columnName,byte x) throws SQLException
    {
	updateByte(findColumn(columnName),x);
    }
1286

Peter Mount's avatar
Peter Mount committed
1287 1288 1289 1290
    public void updateBytes(String columnName,byte[] x) throws SQLException
    {
	updateBytes(findColumn(columnName),x);
    }
1291

Peter Mount's avatar
Peter Mount committed
1292 1293
    public void updateBytes(int columnIndex,byte[] x) throws SQLException
    {
1294 1295
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1296
    }
1297

Peter Mount's avatar
Peter Mount committed
1298 1299 1300 1301 1302
    public void updateCharacterStream(int columnIndex,
				      java.io.Reader x,
				      int length
				      ) throws SQLException
    {
1303 1304
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1305
    }
1306

Peter Mount's avatar
Peter Mount committed
1307 1308 1309 1310 1311 1312 1313
    public void updateCharacterStream(String columnName,
				      java.io.Reader x,
				      int length
				      ) throws SQLException
    {
	updateCharacterStream(findColumn(columnName),x,length);
    }
1314

Peter Mount's avatar
Peter Mount committed
1315 1316
    public void updateDate(int columnIndex,java.sql.Date x) throws SQLException
    {
1317 1318
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1319
    }
1320

Peter Mount's avatar
Peter Mount committed
1321 1322 1323 1324
    public void updateDate(String columnName,java.sql.Date x) throws SQLException
    {
	updateDate(findColumn(columnName),x);
    }
1325

Peter Mount's avatar
Peter Mount committed
1326 1327
    public void updateDouble(int columnIndex,double x) throws SQLException
    {
1328 1329
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1330
    }
1331

Peter Mount's avatar
Peter Mount committed
1332 1333 1334 1335
    public void updateDouble(String columnName,double x) throws SQLException
    {
	updateDouble(findColumn(columnName),x);
    }
1336

Peter Mount's avatar
Peter Mount committed
1337 1338
    public void updateFloat(int columnIndex,float x) throws SQLException
    {
1339 1340
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1341
    }
1342

Peter Mount's avatar
Peter Mount committed
1343 1344 1345 1346
    public void updateFloat(String columnName,float x) throws SQLException
    {
	updateFloat(findColumn(columnName),x);
    }
1347

Peter Mount's avatar
Peter Mount committed
1348 1349
    public void updateInt(int columnIndex,int x) throws SQLException
    {
1350 1351
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1352
    }
1353

Peter Mount's avatar
Peter Mount committed
1354 1355 1356 1357
    public void updateInt(String columnName,int x) throws SQLException
    {
	updateInt(findColumn(columnName),x);
    }
1358

Peter Mount's avatar
Peter Mount committed
1359 1360
    public void updateLong(int columnIndex,long x) throws SQLException
    {
1361 1362
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1363
    }
1364

Peter Mount's avatar
Peter Mount committed
1365 1366 1367 1368
    public void updateLong(String columnName,long x) throws SQLException
    {
	updateLong(findColumn(columnName),x);
    }
1369

Peter Mount's avatar
Peter Mount committed
1370 1371
    public void updateNull(int columnIndex) throws SQLException
    {
1372 1373
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1374
    }
1375

Peter Mount's avatar
Peter Mount committed
1376 1377 1378 1379
    public void updateNull(String columnName) throws SQLException
    {
	updateNull(findColumn(columnName));
    }
1380

Peter Mount's avatar
Peter Mount committed
1381 1382
    public void updateObject(int columnIndex,Object x) throws SQLException
    {
1383 1384
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1385
    }
1386

Peter Mount's avatar
Peter Mount committed
1387 1388 1389 1390
    public void updateObject(String columnName,Object x) throws SQLException
    {
	updateObject(findColumn(columnName),x);
    }
1391

Peter Mount's avatar
Peter Mount committed
1392 1393
    public void updateObject(int columnIndex,Object x,int scale) throws SQLException
    {
1394 1395
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1396
    }
1397

Peter Mount's avatar
Peter Mount committed
1398 1399 1400 1401
    public void updateObject(String columnName,Object x,int scale) throws SQLException
    {
	updateObject(findColumn(columnName),x,scale);
    }
1402

Peter Mount's avatar
Peter Mount committed
1403 1404
    public void updateRow() throws SQLException
    {
1405 1406
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1407
    }
1408

Peter Mount's avatar
Peter Mount committed
1409 1410
    public void updateShort(int columnIndex,short x) throws SQLException
    {
1411 1412
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1413
    }
1414

Peter Mount's avatar
Peter Mount committed
1415 1416 1417 1418
    public void updateShort(String columnName,short x) throws SQLException
    {
	updateShort(findColumn(columnName),x);
    }
1419

Peter Mount's avatar
Peter Mount committed
1420 1421
    public void updateString(int columnIndex,String x) throws SQLException
    {
1422 1423
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1424
    }
1425

Peter Mount's avatar
Peter Mount committed
1426 1427 1428 1429
    public void updateString(String columnName,String x) throws SQLException
    {
	updateString(findColumn(columnName),x);
    }
1430

Peter Mount's avatar
Peter Mount committed
1431 1432
    public void updateTime(int columnIndex,Time x) throws SQLException
    {
1433 1434
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1435
    }
1436

Peter Mount's avatar
Peter Mount committed
1437 1438 1439 1440
    public void updateTime(String columnName,Time x) throws SQLException
    {
	updateTime(findColumn(columnName),x);
    }
1441

Peter Mount's avatar
Peter Mount committed
1442 1443
    public void updateTimestamp(int columnIndex,Timestamp x) throws SQLException
    {
1444 1445
      // only sub-classes implement CONCUR_UPDATEABLE
      notUpdateable();
Peter Mount's avatar
Peter Mount committed
1446
    }
1447

Peter Mount's avatar
Peter Mount committed
1448 1449 1450 1451
    public void updateTimestamp(String columnName,Timestamp x) throws SQLException
    {
	updateTimestamp(findColumn(columnName),x);
    }
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463

    // helper method. Throws an SQLException when an update is not possible
    public void notUpdateable() throws SQLException
    {
      throw new PSQLException("postgresql.noupdate");
    }

    /**
     * This is called by Statement to register itself with this statement.
     * It's used currently by getStatement() but may also with the new core
     * package.
     */
1464
    public void setStatement(org.postgresql.jdbc2.Statement statement) {
1465 1466 1467
      this.statement=statement;
    }

Peter Mount's avatar
Peter Mount committed
1468 1469
}