KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > sql > ResultSet

java.sql
Interface ResultSet

All Known Subinterfaces:
CachedRowSet, FilteredRowSet, JdbcRowSet, JoinRowSet, RowSet, SyncResolver, WebRowSet
See Also:
Top Examples, Source Code, Statement.executeQuery(java.lang.String), Statement.getResultSet(), ResultSetMetaData

boolean absolute(int row)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[363]Updates a specific field in a specific row in a resultset
By Anonymous on 2004/10/28 05:59:17  Rate
rs.absolute ( 5 ) ; // moves the cursor to the fifth row of rs 
 rs.updateString ( "NAME", "AINSWORTH" ) ; // updates the  
   // NAME column of row 5 to be AINSWORTH 
 rs.updateRow (  ) ; // updates the row in the data source 
 


[1405]Create scrollable resultset
By Joseph Bonello on 2005/04/29 09:16:13  Rate
Statement stmt = con.createStatement (  
                                       ResultSet.TYPE_SCROLL_INSENSITIVE, 
                                       ResultSet.CONCUR_UPDATABLE ) ; 
 ResultSet rs = stmt.executeQuery ( "SELECT a, b FROM TABLE2" ) ; 
 // rs will be scrollable, will not show changes made by others, 
 // and will be updatable


void afterLast()
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void beforeFirst()
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void cancelRowUpdates()
                      throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void clearWarnings()
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void close()
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int CLOSE_CURSORS_AT_COMMIT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int CONCUR_READ_ONLY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int CONCUR_UPDATABLE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void deleteRow()
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int FETCH_FORWARD
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int FETCH_REVERSE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int FETCH_UNKNOWN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int findColumn(String columnName)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean first()
              throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Array getArray(int i)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1429]_
By sabbirlx { at } gmail { dot } com on 2005/05/16 05:15:33  Rate
fine code 
 


Array getArray(String colName)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


InputStream getAsciiStream(int columnIndex)
                           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[317]Read an image from DB
By Anonymous on 2003/07/15 09:01:38  Rate
ResultSet rset = stmt.executeQuery ( "select DATECOL, LONGCOL, NUMBERCOL from TABLE" ) ; 
 while rset.next (  )  
  {  
     //get the date data 
     java.sql.Date date = rset.getDate ( 1 ) ; 
     // get the streaming data 
     InputStream is = rset.getAsciiStream ( 2 ) ; 
     // Open a file to store the gif data 
     FileOutputStream file = new FileOutputStream  ( "ascii.dat" ) ; 
     // Loop, reading from the ascii stream and 
     // write to the file 
     int chunk; 
     while  (  ( chunk = is.read  (  )  )  != -1 )  
         file.write ( chunk ) ; 
     // Close the file 
     file.close (  ) ; 
     //get the number column data 
     int n = rset.getInt ( 3 ) ; 
  } 


InputStream getAsciiStream(String columnName)
                           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


BigDecimal getBigDecimal(int columnIndex)
                         throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
BigDecimal getBigDecimal(int columnIndex,
                                    int scale)
                         throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


BigDecimal getBigDecimal(String columnName)
                         throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
BigDecimal getBigDecimal(String columnName,
                                    int scale)
                         throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


InputStream getBinaryStream(int columnIndex)
                            throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[512]Circumvents that hsqldb throws an NullPointerException while trying to getBinaryStream from a null-column
By Anonymous on 2003/11/14 17:55:53  Rate
public static Object getBinary ( ResultSet rs, int offset )   
 throws IOException, ClassNotFoundException, SQLException  {  
  
  
 InputStream is = null; 
 try  {  
     is = rs.getBinaryStream  ( offset ) ; 
  }  catch  ( NullPointerException npe )   {  
     // this circumvents that hsqldb throws an NullPointerException 
     // while trying to getBinaryStream from a null-column. 
     if  ( rs.wasNull (  )  )   {  
     return null; 
      }  
     // oops, different error. 
     throw npe; 
  }  
 if  ( rs.wasNull (  )  )   {  
     return null; 
  }  
 ObjectInputStream ois = new ObjectInputStream ( is ) ; 
 return ois.readObject (  ) ; 
  
  
  } 


InputStream getBinaryStream(String columnName)
                            throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Blob getBlob(int i)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1897]Getting BLOB Data from a Database Table
By Anonymous on 2007/06/30 09:46:12  Rate
try  {  
         Statement stmt = connection.createStatement (  ) ; 
         ResultSet rs = stmt.executeQuery ( "SELECT col_blob FROM mysql_all_table" ) ; 
      
         if  ( rs.next (  )  )   {  
             // Get the BLOB from the result set 
             Blob blob = rs.getBlob ( "col_blob" ) ; 
      
             // Get the number bytes in the BLOB 
             long blobLength = blob.length (  ) ; 
      
             // Get bytes from the BLOB in a byte array 
             int pos = 1; // position is 1-based 
             int len = 10; 
             byte [  ]  bytes = blob.getBytes ( pos, len ) ; 
      
             // Get bytes from the BLOB using a stream 
             InputStream is = blob.getBinaryStream (  ) ; 
             int b = is.read (  ) ; 
          }  
      }  catch  ( IOException e )   {  
      }  catch  ( SQLException e )   {  
      } 


Blob getBlob(String colName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean getBoolean(int columnIndex)
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean getBoolean(String columnName)
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


byte getByte(int columnIndex)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


byte getByte(String columnName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


byte[] getBytes(int columnIndex)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


byte[] getBytes(String columnName)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Reader getCharacterStream(int columnIndex)
                          throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Reader getCharacterStream(String columnName)
                          throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Clob getClob(int i)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Clob getClob(String colName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getConcurrency()
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getCursorName()
                     throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Date getDate(int columnIndex)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Date getDate(int columnIndex,
             Calendar cal)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Date getDate(String columnName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1259]ResultSet.getDate returns a util.date, NOT sql.date
By bgunn { at } ppilab { dot } com on 2005/01/20 00:15:31  Rate
When using SQL, the date is save as a java.sql.date in sequel, but this method will return a java.util.data.

Date getDate(String columnName,
             Calendar cal)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


double getDouble(int columnIndex)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


double getDouble(String columnName)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getFetchDirection()
                      throws SQLException
See Also:
setFetchDirection(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getFetchSize()
                 throws SQLException
See Also:
setFetchSize(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[914]Determine number of rows in a ResultSet
By Anonymous on 2005/04/08 06:42:55  Rate
Do not use 'getFetchSize (  ) ' to determine the number of rows in a ResultSet, because fetch size is a hint to the database regarding the number of records that should be obtained in each hop to the database. 
  
  
 If you call the 'last (  ) ' first, then calling 'getRow (  ) ' will give you the number of rows in a ResultSet. But this is very inefficient for a large result set. 
 


float getFloat(int columnIndex)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


float getFloat(String columnName)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getInt(int columnIndex)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getInt(String columnName)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


long getLong(int columnIndex)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


long getLong(String columnName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


ResultSetMetaData getMetaData()
                              throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getObject(int columnIndex)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getObject(int i,
                 Map<String,Class<?>> map)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getObject(String columnName)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Object getObject(String colName,
                 Map<String,Class<?>> map)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Ref getRef(int i)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Ref getRef(String colName)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getRow()
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


short getShort(int columnIndex)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


short getShort(String columnName)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Statement getStatement()
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[513]Get JDBC driver name for the current SQL statement
By Anonymous on 2003/11/14 17:58:12  Rate
String drvName = rs.getStatement (  ) .getConnection (  ) .getMetaData (  ) .getDriverName (  ) ;

String getString(int columnIndex)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


String getString(String columnName)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Time getTime(int columnIndex)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Time getTime(int columnIndex,
             Calendar cal)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Time getTime(String columnName)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Time getTime(String columnName,
             Calendar cal)
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Timestamp getTimestamp(int columnIndex)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Timestamp getTimestamp(int columnIndex,
                       Calendar cal)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Timestamp getTimestamp(String columnName)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Timestamp getTimestamp(String columnName,
                       Calendar cal)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


int getType()
            throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
InputStream getUnicodeStream(int columnIndex)
                             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
InputStream getUnicodeStream(String columnName)
                             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


URL getURL(int columnIndex)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


URL getURL(String columnName)
           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


SQLWarning getWarnings()
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int HOLD_CURSORS_OVER_COMMIT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void insertRow()
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[364]Insert a row into a result set
By Anonymous on 2004/11/23 05:03:16  Rate
rs.moveToInsertRow (  ) ; // moves cursor to the insert row 
 rs.updateString ( 1, "AINSWORTH" ) ; // updates the  
   // first column of the insert row to be AINSWORTH 
 rs.updateInt ( 2,35 ) ; // updates the second column to be 35 
 rs.updateBoolean ( 3, true ) ; // updates the third row to true 
 rs.insertRow (  ) ; 
 rs.moveToCurrentRow (  ) ; 
 


boolean isAfterLast()
                    throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isBeforeFirst()
                      throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isFirst()
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean isLast()
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[261]Use isLast instead of next
By Anonymous on 2004/11/03 06:44:20  Rate
while  ( !rs.isLast (  )  )  {  
  
  
  stCl = rs.getString ( "CODICE_CLIENTE" ) ; 
  while  ( rs.getString ( "CODICE_CLIENTE" ) .equals ( stCl )  )  {  
  
  
   stLicDist = rs.getString ( "ID_PROT" )  + rs.getString ( "CODDISTR" ) ; 
   while  (  ( rs.getString ( "ID_PROT" )  + rs.getString ( "CODDISTR" )  ) .equals ( stLicDist )  )  {  
  
  
     out.println ( " < tr > " ) ; 
     out.println ( " < td colspan=12 > " + rs.getString ( "CODICE_CLIENTE" )  + " < /td > " ) ; 
     out.println ( " < /tr > " ) ; 
     rs.next (  ) ; 
     }  
   } 


boolean last()
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[922]Get result set size
By Anonymous on 2004/09/23 08:56:21  Rate
//Note, this is not very efficient for large set 
 public static int getResultSetSize ( ResultSet rs )  throws SQLException      
  {          
   int currentRow = rs.getRow (  ) ;         
   rs.last (  ) ;         
   int last = rs.getRow (  ) ;                 
  
  
   if  ( currentRow == 0 )              
     rs.first (  ) ;         
   else             
     rs.absolute ( currentRow ) ;                     
   
  return last;     
  } 


void moveToCurrentRow()
                      throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void moveToInsertRow()
                     throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1732]Insertion into ResultSet
By Anonymous on 2006/03/19 01:56:54  Rate
RSet.moveToInsertRow (  ) ; 
        
       RSet.updateLong ( "id",seqno ) ;           
       RSet.updateString ( "DESCR",employerEditorForm.getDescr (  )  ) ;           
       RSet.updateString ( "NUM",employerEditorForm.getNum (  )  ) ;           
       RSet.updateLong ( "permission_group_id",employerEditorForm.getPermissionGroupId (  )  ) ;         
       RSet.updateString ( "CONT_NAME",employerEditorForm.getContName (  )  ) ;           
       RSet.updateString ( "CONT_PHONE",employerEditorForm.getContPhone (  )  ) ; 
       RSet.updateString ( "LOC_ADDRESS1",employerEditorForm.getLocAddress1 (  )  ) ; 
       RSet.updateString ( "LOC_ADDRESS2",employerEditorForm.getLocAddress2 (  )  ) ; 
       RSet.updateString ( "LOC_CITY",employerEditorForm.getLocCity (  )  ) ; 
       RSet.updateString ( "LOC_STATE_POST_CODE",employerEditorForm.getLocStatePostCode (  )  ) ; 
       RSet.updateString ( "LOC_AREA_ZIP",employerEditorForm.getLocAreaZip (  )  ) ; 
       RSet.updateString ( "LOC_BOX_ZIP",employerEditorForm.getLocBoxZip (  )  ) ; 
       RSet.updateString ( "PHYS1_ADDRESS",employerEditorForm.getPhys1Address (  )  ) ; 
       RSet.updateString ( "PHYS2_ADDRESS",employerEditorForm.getPhys2Address (  )  ) ; 
       RSet.updateString ( "PHYS_CITY",employerEditorForm.getPhysCity (  )  ) ; 
       RSet.updateString ( "PHYS_STATE_POST_CODE",employerEditorForm.getPhysStatePostCode (  )  ) ; 
       RSet.updateString ( "PHYS_AREA_ZIP",employerEditorForm.getPhysAreaZip (  )  ) ; 
       RSet.updateString ( "PHYS_BOX_ZIP",employerEditorForm.getPhysBoxZip (  )  ) ;        
        
       RSet.insertRow (  ) ; 
       RSet.moveToCurrentRow (  ) ;


boolean next()
             throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean previous()
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void refreshRow()
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean relative(int rows)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean rowDeleted()
                   throws SQLException
See Also:
DatabaseMetaData.deletesAreDetected(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean rowInserted()
                    throws SQLException
See Also:
DatabaseMetaData.insertsAreDetected(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean rowUpdated()
                   throws SQLException
See Also:
DatabaseMetaData.updatesAreDetected(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void setFetchDirection(int direction)
                       throws SQLException
See Also:
getFetchDirection()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void setFetchSize(int rows)
                  throws SQLException
See Also:
getFetchSize()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int TYPE_FORWARD_ONLY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int TYPE_SCROLL_INSENSITIVE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int TYPE_SCROLL_SENSITIVE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateArray(int columnIndex,
                 Array x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateArray(String columnName,
                 Array x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateAsciiStream(int columnIndex,
                       InputStream x,
                       int length)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateAsciiStream(String columnName,
                       InputStream x,
                       int length)
                       throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBigDecimal(int columnIndex,
                      BigDecimal x)
                      throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBigDecimal(String columnName,
                      BigDecimal x)
                      throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBinaryStream(int columnIndex,
                        InputStream x,
                        int length)
                        throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBinaryStream(String columnName,
                        InputStream x,
                        int length)
                        throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBlob(int columnIndex,
                Blob x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBlob(String columnName,
                Blob x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBoolean(int columnIndex,
                   boolean x)
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBoolean(String columnName,
                   boolean x)
                   throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateByte(int columnIndex,
                byte x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateByte(String columnName,
                byte x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBytes(int columnIndex,
                 byte[] x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateBytes(String columnName,
                 byte[] x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateCharacterStream(int columnIndex,
                           Reader x,
                           int length)
                           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateCharacterStream(String columnName,
                           Reader reader,
                           int length)
                           throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateClob(int columnIndex,
                Clob x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateClob(String columnName,
                Clob x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateDate(int columnIndex,
                Date x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateDate(String columnName,
                Date x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateDouble(int columnIndex,
                  double x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateDouble(String columnName,
                  double x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateFloat(int columnIndex,
                 float x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateFloat(String columnName,
                 float x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateInt(int columnIndex,
               int x)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateInt(String columnName,
               int x)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateLong(int columnIndex,
                long x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateLong(String columnName,
                long x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateNull(int columnIndex)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateNull(String columnName)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateObject(int columnIndex,
                  Object x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateObject(int columnIndex,
                  Object x,
                  int scale)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateObject(String columnName,
                  Object x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateObject(String columnName,
                  Object x,
                  int scale)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateRef(int columnIndex,
               Ref x)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateRef(String columnName,
               Ref x)
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateRow()
               throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateShort(int columnIndex,
                 short x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateShort(String columnName,
                 short x)
                 throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateString(int columnIndex,
                  String x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateString(String columnName,
                  String x)
                  throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateTime(int columnIndex,
                Time x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateTime(String columnName,
                Time x)
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void updateTimestamp(int columnIndex,
                     Timestamp x)
                     throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[794]Set to current time in DB
By Greg Smith on 2004/05/29 01:49:05  Rate
java.sql.Timestamp ts=new java.sql.Timestamp ( System.currentTimeMillis (  )  ) ;             
  
  
 rs.updateTimestamp ( 4,ts ) ; // Puts a timestamp into column 4 
 


void updateTimestamp(String columnName,
                     Timestamp x)
                     throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


boolean wasNull()
                throws SQLException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1019]Create and execute a query statement
By qxl01 { at } health { dot } state { dot } ny { dot } us on 2004/10/06 09:36:14  Rate
private void jButton2_actionPerformed ( ActionEvent e )  
    {  
    
      Statement stmt = null; 
      ResultSet rset = null; 
      int insertResults; 
      int deleteResults; 
      boolean flag = false;  
      int  rowNumber; 
      String test_jdbc_name = null; 
      int  test_jdbc_intr_no = 0; 
        
      
      try  {  
  
  
           System.out.print ( " Creating Statement...\n" ) ; 
           stmt = con.createStatement  (  ) ; 
            
           /** 
            * ----------------------------------------------------------------- 
            * EXECUTE QUERY 
            * ----------------------------------------------------------------- 
            */
 
            System.out.print ( "\n+-------------------------------+\n" ) ; 
            System.out.print ( "| EXECUTE QUERY  ( Forward )        |\n" ) ; 
            System.out.print ( "+-------------------------------+\n\n" ) ; 
              
            System.out.print ( "Opening ResultsSet...\n" ) ; 
             
            rset = stmt.executeQuery  ( "SELECT test_jdbc.test_jdbc_intr_no, test_jdbc.test_jdbc_name " +  
                  " FROM test_jdbc_target, test_jdbc " + 
                  " WHERE test_jdbc_target.test_jdbc_intr_no = test_jdbc.test_jdbc_intr_no " ) ; 
             
          while  ( rset.next  (  )  )   {  
                  rowNumber = rset.getRow (  ) ; 
                  test_jdbc_intr_no = rset.getInt ( 1 ) ; 
                  test_jdbc_name = rset.getString ( 2 ) ; 
                  System.out.print ( "\n While block test_jdbc_intr_no = " + test_jdbc_intr_no +"\n" ) ;  
                  System.out.print ( "\n While block test_jdbc_name = " + test_jdbc_name +"\n" ) ;  
                   
           if  (  rset.wasNull (  )   )  
            {  
               System.out.print ( "\n before If block test_jdbc_name = " + test_jdbc_name +"\n" ) ;  
               stmt.executeUpdate  ( "Insert into test_jdbc_target " + 
                               " SELECT * FROM test_jdbc" ) ; 
               System.out.print ( "\n If block test_jdbc_name = " + test_jdbc_name +"\n" ) ;  
            }  
           else  
             {  
               stmt.executeUpdate (  " UPDATE  ( SELECT test_jdbc_target.test_jdbc_name AS old_test_jdbc_name, " + 
                                 " test_jdbc.test_jdbc_name AS new_test_jdbc_name " + 
                                 " FROM test_jdbc_target INNER JOIN test_jdbc " + 
                                 " ON test_jdbc_target.test_jdbc_intr_no=test_jdbc.test_jdbc_intr_no ) " + 
                                 " SET old_test_jdbc_name=new_test_jdbc_name " ) ; 
               System.out.print ( "\n Test else block" + "\n" ) ;   
             }  
       }  
             
            
            /** 
             * ----------------------------------------------------------------- 
             * COMMIT TRANSACTION 
             * ----------------------------------------------------------------- 
             */
 
             System.out.print ( "Commiting Transaction...\n" ) ; 
             con.commit (  ) ; 
              
            /** 
             * ----------------------------------------------------------------- 
             * CLOSE RESULTSET AND STATEMENT OBJECTS 
             * ----------------------------------------------------------------- 
             */
 
             System.out.println (  ) ; 
             System.out.print ( " Closing ResultSet...\n" ) ; 
             rset.close (  ) ; 
  
  
             System.out.print ( " Closing Statement...\n" ) ; 
             stmt.close (  ) ; 
  
  
          }  catch  ( SQLException ex )   {  
             ex.printStackTrace (  ) ; 
          }  
          
       /** 
       * Close down Oracle connection. 
       */
 
       try  {  
           System.out.print ( " Closing Connection...\n" ) ; 
           con.close (  ) ; 
            }  catch  ( SQLException ec )   {  
               ec.printStackTrace (  ) ; 
            }  
      }  
   

Popular Tags