/* * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.rowset; import java.sql.*;import javax.sql.*;import javax.naming.*;import java.io.*;import java.math.*;import java.util.*;import java.beans.*; import javax.sql.rowset.*; /** * The standard implementation of the <code>JdbcRowSet</code> interface. See the interface * defintion for full behavior and implementation requirements. * * @author Jonathan Bruce, Amit Handa */ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { /** * The <code>Connection</code> object that is this rowset's * current connection to the database. This field is set * internally when the connection is established. */ private Connection conn; /** * The <code>PreparedStatement</code> object that is this rowset's * current command. This field is set internally when the method * <code>execute</code> creates the <code>PreparedStatement</code> * object. */ private PreparedStatement ps; /** * The <code>ResultSet</code> object that is this rowset's * current result set. This field is set internally when the method * <code>execute</code> executes the rowset's command and thereby * creates the rowset's <code>ResultSet</code> object. */ private ResultSet rs; /** * The <code>RowSetMetaDataImpl</code> object that is contructed when * a <code>ResultSet</code> object is passed to the <code>JdbcRowSet</code> * constructor. This helps in constructing all metadata associated * with the <code>ResultSet</code> object using the setter methods of * <code>RowSetMetaDataImpl</code>. */ private RowSetMetaDataImpl rowsMD; /** * The <code>ResultSetMetaData</code> object from which this * <code>RowSetMetaDataImpl</code> is formed and which helps in getting * the metadata information. */ private ResultSetMetaData resMD; /** * The property that helps to fire the property changed event when certain * properties are changed in the <code>JdbcRowSet</code> object. This property * is being added to satisfy Rave requirements. */ private PropertyChangeSupport propertyChangeSupport; /** * The Vector holding the Match Columns */ private Vector<Integer> iMatchColumns; /** * The Vector that will hold the Match Column names. */ private Vector<String> strMatchColumns; protected transient JdbcRowSetResourceBundle resBundle; /** * Constructs a default <code>JdbcRowSet</code> object. * The new instance of <code>JdbcRowSet</code> will serve as a proxy * for the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * A newly created <code>JdbcRowSet</code> object must have its * <code>execute</code> method invoked before other public methods * are called on it; otherwise, such method calls will cause an * exception to be thrown. * * @throws SQLException [1] if any of its public methods are called prior * to calling the <code>execute</code> method; [2] if invalid JDBC driver * properties are set or [3] if no connection to a data source exists. */ public JdbcRowSetImpl() { conn = null; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // set the defaults try { setShowDeleted(false); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + sqle.getLocalizedMessage()); } try { setQueryTimeout(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + sqle.getLocalizedMessage()); } try { setMaxRows(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + sqle.getLocalizedMessage()); } try { setMaxFieldSize(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + sqle.getLocalizedMessage()); } try { setEscapeProcessing(true); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + sqle.getLocalizedMessage()); } try { setConcurrency(ResultSet.CONCUR_UPDATABLE); } catch (SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + sqle.getLocalizedMessage()); } setTypeMap(null); try { setType(ResultSet.TYPE_SCROLL_INSENSITIVE); } catch(SQLException sqle){ System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + sqle.getLocalizedMessage()); } setReadOnly(true); try { setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } catch(SQLException sqle){ System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + sqle.getLocalizedMessage()); } //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a default <code>JdbcRowSet</code> object given a * valid <code>Connection</code> object. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * A newly created <code>JdbcRowSet</code> object must have its * <code>execute</code> method invoked before other public methods * are called on it; otherwise, such method calls will cause an * exception to be thrown. * * @throws SQLException [1] if any of its public methods are called prior * to calling the <code>execute</code> method, [2] if invalid JDBC driver * properties are set, or [3] if no connection to a data source exists. */ public JdbcRowSetImpl(Connection con) throws SQLException { conn = con; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // set the defaults setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a default <code>JdbcRowSet</code> object using the * URL, username, and password arguments supplied. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * * @param url - a JDBC URL for the database to which this <code>JdbcRowSet</code> * object will be connected. The form for a JDBC URL is * <code>jdbc:subprotocol:subname</code>. * @param user - the database user on whose behalf the connection * is being made * @param password - the user's password * * @throws SQLException if a database access error occurs * */ public JdbcRowSetImpl(String url, String user, String password) throws SQLException { conn = null; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // Pass the arguments to BaseRowSet // setter methods now. setUsername(user); setPassword(password); setUrl(url); // set the defaults setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); // to ensure connection to a db call connect now // and associate a conn with "this" object // in this case. conn = connect(); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a <code>JdbcRowSet</code> object using the given valid * <code>ResultSet</code> object. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * * @param res a valid <code>ResultSet</code> object * * @throws SQLException if a database access occurs due to a non * valid ResultSet handle. */ public JdbcRowSetImpl(ResultSet res) throws SQLException { // A ResultSet handle encapsulates a connection handle. // But there is no way we can retrieve a Connection handle // from a ResultSet object. // So to avoid any anomalies we keep the conn = null // The passed rs handle will be a wrapper around for // "this" object's all operations. conn = null; ps = null; rs = res; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // get the values from the resultset handle. setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); // Get a handle to ResultSetMetaData // Construct RowSetMetaData out of it. resMD = rs.getMetaData(); rowsMD = new RowSetMetaDataImpl(); initMetaData(rowsMD, resMD); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Initializes the given <code>RowSetMetaData</code> object with the values * in the given <code>ResultSetMetaData</code> object. * * @param md the <code>RowSetMetaData</code> object for this * <code>JdbcRowSetImpl</code> object, which will be set with * values from rsmd * @param rsmd the <code>ResultSetMetaData</code> object from which new * values for md will be read * @throws SQLException if an error occurs */ protected void initMetaData(RowSetMetaData md, ResultSetMetaData rsmd) throws SQLException { int numCols = rsmd.getColumnCount(); md.setColumnCount(numCols); for (int col=1; col <= numCols; col++) { md.setAutoIncrement(col, rsmd.isAutoIncrement(col)); md.setCaseSensitive(col, rsmd.isCaseSensitive(col)); md.setCurrency(col, rsmd.isCurrency(col)); md.setNullable(col, rsmd.isNullable(col)); md.setSigned(col, rsmd.isSigned(col)); md.setSearchable(col, rsmd.isSearchable(col)); md.setColumnDisplaySize(col, rsmd.getColumnDisplaySize(col)); md.setColumnLabel(col, rsmd.getColumnLabel(col));Lines 1–500 of 7047. Load more
/* * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.rowset; import java.sql.*; import javax.sql.*; import javax.naming.*; import java.io.*; import java.math.*; import java.util.*; import java.beans.*; import javax.sql.rowset.*; /** * The standard implementation of the <code>JdbcRowSet</code> interface. See the interface * defintion for full behavior and implementation requirements. * * @author Jonathan Bruce, Amit Handa */ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable { /** * The <code>Connection</code> object that is this rowset's * current connection to the database. This field is set * internally when the connection is established. */ private Connection conn; /** * The <code>PreparedStatement</code> object that is this rowset's * current command. This field is set internally when the method * <code>execute</code> creates the <code>PreparedStatement</code> * object. */ private PreparedStatement ps; /** * The <code>ResultSet</code> object that is this rowset's * current result set. This field is set internally when the method * <code>execute</code> executes the rowset's command and thereby * creates the rowset's <code>ResultSet</code> object. */ private ResultSet rs; /** * The <code>RowSetMetaDataImpl</code> object that is contructed when * a <code>ResultSet</code> object is passed to the <code>JdbcRowSet</code> * constructor. This helps in constructing all metadata associated * with the <code>ResultSet</code> object using the setter methods of * <code>RowSetMetaDataImpl</code>. */ private RowSetMetaDataImpl rowsMD; /** * The <code>ResultSetMetaData</code> object from which this * <code>RowSetMetaDataImpl</code> is formed and which helps in getting * the metadata information. */ private ResultSetMetaData resMD; /** * The property that helps to fire the property changed event when certain * properties are changed in the <code>JdbcRowSet</code> object. This property * is being added to satisfy Rave requirements. */ private PropertyChangeSupport propertyChangeSupport; /** * The Vector holding the Match Columns */ private Vector<Integer> iMatchColumns; /** * The Vector that will hold the Match Column names. */ private Vector<String> strMatchColumns; protected transient JdbcRowSetResourceBundle resBundle; /** * Constructs a default <code>JdbcRowSet</code> object. * The new instance of <code>JdbcRowSet</code> will serve as a proxy * for the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * A newly created <code>JdbcRowSet</code> object must have its * <code>execute</code> method invoked before other public methods * are called on it; otherwise, such method calls will cause an * exception to be thrown. * * @throws SQLException [1] if any of its public methods are called prior * to calling the <code>execute</code> method; [2] if invalid JDBC driver * properties are set or [3] if no connection to a data source exists. */ public JdbcRowSetImpl() { conn = null; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // set the defaults try { setShowDeleted(false); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + sqle.getLocalizedMessage()); } try { setQueryTimeout(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + sqle.getLocalizedMessage()); } try { setMaxRows(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + sqle.getLocalizedMessage()); } try { setMaxFieldSize(0); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + sqle.getLocalizedMessage()); } try { setEscapeProcessing(true); } catch(SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + sqle.getLocalizedMessage()); } try { setConcurrency(ResultSet.CONCUR_UPDATABLE); } catch (SQLException sqle) { System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + sqle.getLocalizedMessage()); } setTypeMap(null); try { setType(ResultSet.TYPE_SCROLL_INSENSITIVE); } catch(SQLException sqle){ System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + sqle.getLocalizedMessage()); } setReadOnly(true); try { setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } catch(SQLException sqle){ System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + sqle.getLocalizedMessage()); } //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a default <code>JdbcRowSet</code> object given a * valid <code>Connection</code> object. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * A newly created <code>JdbcRowSet</code> object must have its * <code>execute</code> method invoked before other public methods * are called on it; otherwise, such method calls will cause an * exception to be thrown. * * @throws SQLException [1] if any of its public methods are called prior * to calling the <code>execute</code> method, [2] if invalid JDBC driver * properties are set, or [3] if no connection to a data source exists. */ public JdbcRowSetImpl(Connection con) throws SQLException { conn = con; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // set the defaults setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a default <code>JdbcRowSet</code> object using the * URL, username, and password arguments supplied. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object it creates, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * * @param url - a JDBC URL for the database to which this <code>JdbcRowSet</code> * object will be connected. The form for a JDBC URL is * <code>jdbc:subprotocol:subname</code>. * @param user - the database user on whose behalf the connection * is being made * @param password - the user's password * * @throws SQLException if a database access error occurs * */ public JdbcRowSetImpl(String url, String user, String password) throws SQLException { conn = null; ps = null; rs = null; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // Pass the arguments to BaseRowSet // setter methods now. setUsername(user); setPassword(password); setUrl(url); // set the defaults setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); // to ensure connection to a db call connect now // and associate a conn with "this" object // in this case. conn = connect(); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Constructs a <code>JdbcRowSet</code> object using the given valid * <code>ResultSet</code> object. The new * instance of <code>JdbcRowSet</code> will serve as a proxy for * the <code>ResultSet</code> object, and by so doing, * it will make it possible to use the result set as a JavaBeans * component. * * <P> * The following is true of a default <code>JdbcRowSet</code> instance: * <UL> * <LI>Does not show deleted rows * <LI>Has no time limit for how long a driver may take to * execute the rowset's command * <LI>Has no limit for the number of rows it may contain * <LI>Has no limit for the number of bytes a column may contain * <LI>Has a scrollable cursor and does not show changes * made by others * <LI>Will not see uncommitted data (make "dirty" reads) * <LI>Has escape processing turned on * <LI>Has its connection's type map set to <code>null</code> * <LI>Has an empty <code>Hashtable</code> object for storing any * parameters that are set * </UL> * * @param res a valid <code>ResultSet</code> object * * @throws SQLException if a database access occurs due to a non * valid ResultSet handle. */ public JdbcRowSetImpl(ResultSet res) throws SQLException { // A ResultSet handle encapsulates a connection handle. // But there is no way we can retrieve a Connection handle // from a ResultSet object. // So to avoid any anomalies we keep the conn = null // The passed rs handle will be a wrapper around for // "this" object's all operations. conn = null; ps = null; rs = res; try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } propertyChangeSupport = new PropertyChangeSupport(this); initParams(); // get the values from the resultset handle. setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); setParams(); setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); // Get a handle to ResultSetMetaData // Construct RowSetMetaData out of it. resMD = rs.getMetaData(); rowsMD = new RowSetMetaDataImpl(); initMetaData(rowsMD, resMD); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for(int i = 0; i < 10 ; i++) { iMatchColumns.add(i,Integer.valueOf(-1)); } strMatchColumns = new Vector<String>(10); for(int j = 0; j < 10; j++) { strMatchColumns.add(j,null); } } /** * Initializes the given <code>RowSetMetaData</code> object with the values * in the given <code>ResultSetMetaData</code> object. * * @param md the <code>RowSetMetaData</code> object for this * <code>JdbcRowSetImpl</code> object, which will be set with * values from rsmd * @param rsmd the <code>ResultSetMetaData</code> object from which new * values for md will be read * @throws SQLException if an error occurs */ protected void initMetaData(RowSetMetaData md, ResultSetMetaData rsmd) throws SQLException { int numCols = rsmd.getColumnCount(); md.setColumnCount(numCols); for (int col=1; col <= numCols; col++) { md.setAutoIncrement(col, rsmd.isAutoIncrement(col)); md.setCaseSensitive(col, rsmd.isCaseSensitive(col)); md.setCurrency(col, rsmd.isCurrency(col)); md.setNullable(col, rsmd.isNullable(col)); md.setSigned(col, rsmd.isSigned(col)); md.setSearchable(col, rsmd.isSearchable(col)); md.setColumnDisplaySize(col, rsmd.getColumnDisplaySize(col)); md.setColumnLabel(col, rsmd.getColumnLabel(col));