7047 lines · 303.9 KB · Java
RawDownload
        } else {            strMatchColumns.set(0, null);   // that is, we are unsetting it.        }    }     /**     * Retrieves the <code>DatabaseMetaData</code> associated with     * the connection handle associated this this     * <code>JdbcRowSet</code> object.     *     * @return the <code>DatabaseMetadata</code> associated     *  with the rowset's connection.     * @throws SQLException if a database access error occurs     */    public DatabaseMetaData getDatabaseMetaData() throws SQLException {        Connection con = connect();        return con.getMetaData();    }     /**     * Retrieves the <code>ParameterMetaData</code> associated with     * the connection handle associated this this     * <code>JdbcRowSet</code> object.     *     * @return the <code>ParameterMetadata</code> associated     *  with the rowset's connection.     * @throws SQLException if a database access error occurs     */    public ParameterMetaData getParameterMetaData() throws SQLException {        prepare();        return (ps.getParameterMetaData());    }     /**     * Commits all updates in this <code>JdbcRowSet</code> object by     * wrapping the internal <code>Connection</code> object and calling     * its <code>commit</code> method.     * This method sets this <code>JdbcRowSet</code> object's private field     * <code>rs</code> to <code>null</code> after saving its value to another     * object, but only if the <code>ResultSet</code>     * constant <code>HOLD_CURSORS_OVER_COMMIT</code> has not been set.     * (The field <code>rs</code> is this <code>JdbcRowSet</code> object's     * <code>ResultSet</code> object.)     *     * @throws SQLException if autoCommit is set to true or if a database     * access error occurs     */    public void commit() throws SQLException {      conn.commit();       // Checking the holadbility value and making the result set handle null      // Added as per Rave requirements       if( conn.getHoldability() != HOLD_CURSORS_OVER_COMMIT) {         ResultSet oldVal = rs;         rs = null;         // propertyChangeSupport.firePropertyChange("ResultSet",oldVal,rs);      }    }     /**     * Sets auto-commit on the internal <code>Connection</code> object with this     * <code>JdbcRowSet</code>     *     * @throws SQLException if a database access error occurs     */    public void setAutoCommit(boolean autoCommit) throws SQLException {        // The connection object should be there        // in order to commit the connection handle on or off.         if(conn != null) {           conn.setAutoCommit(autoCommit);        } else {           // Coming here means the connection object is null.           // So generate a connection handle internally, since           // a JdbcRowSet is always connected to a db, it is fine           // to get a handle to the connection.            // Get hold of a connection handle           // and change the autcommit as passesd.           conn = connect();            // After setting the below the conn.getAutoCommit()           // should return the same value.           conn.setAutoCommit(autoCommit);         }    }     /**     * Returns the auto-commit status with this <code>JdbcRowSet</code>.     *     * @return true if auto commit is true; false otherwise     * @throws SQLException if a database access error occurs     */    public boolean getAutoCommit() throws SQLException {        return conn.getAutoCommit();    }     /**     * Rolls back all the updates in this <code>JdbcRowSet</code> object by     * wrapping the internal <code>Connection</code> object and calling its     * <code>rollback</code> method.     * This method sets this <code>JdbcRowSet</code> object's private field     * <code>rs</code> to <code>null</code> after saving its value to another object.     * (The field <code>rs</code> is this <code>JdbcRowSet</code> object's     * internal <code>ResultSet</code> object.)     *     * @throws SQLException if autoCommit is set to true or a database     * access error occurs     */    public void rollback() throws SQLException {        conn.rollback();         // Makes the result ste handle null after rollback        // Added as per Rave requirements         ResultSet oldVal = rs;        rs = null;        // propertyChangeSupport.firePropertyChange("ResultSet", oldVal,rs);    }      /**     * Rollbacks all the updates in the <code>JdbcRowSet</code> back to the     * last <code>Savepoint</code> transaction marker. Wraps the internal     * <code>Connection</code> object and call it's rollback method     *     * @param s the <code>Savepoint</code> transaction marker to roll the     * transaction to.     * @throws SQLException if autoCommit is set to true; or ia a database     * access error occurs     */    public void rollback(Savepoint s) throws SQLException {        conn.rollback(s);    }     // Setting the ResultSet Type and Concurrency    protected void setParams() throws SQLException {        if(rs == null) {           setType(ResultSet.TYPE_SCROLL_INSENSITIVE);           setConcurrency(ResultSet.CONCUR_UPDATABLE);        }        else {            setType(rs.getType());            setConcurrency(rs.getConcurrency());        }    }      // Checking ResultSet Type and Concurrency    private void checkTypeConcurrency() throws SQLException {        if(rs.getType() == TYPE_FORWARD_ONLY ||           rs.getConcurrency() == CONCUR_READ_ONLY) {              throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.resnotupd").toString());         }    }      // Returns a Connection Handle    //  Added as per Rave requirements     /**     * Gets this <code>JdbcRowSet</code> object's Connection property     *     *     * @return the <code>Connection</code> object associated with this rowset;     */     protected Connection getConnection() {       return conn;    }     // Sets the connection handle with the parameter    // Added as per rave requirements     /**     * Sets this <code>JdbcRowSet</code> object's connection property     * to the given <code>Connection</code> object.     *     * @param connection the <code>Connection</code> object.     */     protected void setConnection(Connection connection) {       conn = connection;    }     // Returns a PreparedStatement Handle    // Added as per Rave requirements     /**     * Gets this <code>JdbcRowSet</code> object's PreparedStatement property     *     *     * @return the <code>PreparedStatement</code> object associated with this rowset;     */     protected PreparedStatement getPreparedStatement() {       return ps;    }     //Sets the prepared statement handle to the parameter    // Added as per Rave requirements     /**     * Sets this <code>JdbcRowSet</code> object's preparedtsatement property     * to the given <code>PreparedStatemennt</code> object.     *     * @param preparedStatement the <code>PreparedStatement</code> object     *     */    protected void setPreparedStatement(PreparedStatement preparedStatement) {       ps = preparedStatement;    }     // Returns a ResultSet handle    // Added as per Rave requirements     /**     * Gets this <code>JdbcRowSet</code> object's ResultSet property     *     *     * @return the <code>ResultSet</code> object associated with this rowset;     */     protected ResultSet getResultSet() throws SQLException {        checkState();        return rs;    }     // Sets the result set handle to the parameter    // Added as per Rave requirements     /**     * Sets this <code>JdbcRowSet</code> object's resultset property     * to the given <code>ResultSet</code> object.     *     * @param resultSet the <code>ResultSet</code> object     *     */    protected void setResultSet(ResultSet resultSet) {       rs = resultSet;    }      // Over riding the setCommand from BaseRowSet for    // firing the propertyChangeSupport Event for    // Rave requirements when this property's value    // changes.     /**     * Sets this <code>JdbcRowSet</code> object's <code>command</code> property to     * the given <code>String</code> object and clears the parameters, if any,     * that were set for the previous command. In addition,     * if the <code>command</code> property has previously been set to a     * non-null value and it is     * different from the <code>String</code> object supplied,     * this method sets this <code>JdbcRowSet</code> object's private fields     * <code>ps</code> and <code>rs</code> to <code>null</code>.     * (The field <code>ps</code> is its <code>PreparedStatement</code> object, and     * the field <code>rs</code> is its <code>ResultSet</code> object.)     * <P>     * The <code>command</code> property may not be needed if the <code>RowSet</code>     * object gets its data from a source that does not support commands,     * such as a spreadsheet or other tabular file.     * Thus, this property is optional and may be <code>null</code>.     *     * @param command a <code>String</code> object containing an SQL query     *            that will be set as this <code>RowSet</code> object's command     *            property; may be <code>null</code> but may not be an empty string     * @throws SQLException if an empty string is provided as the command value     * @see #getCommand     */    public void setCommand(String command) throws SQLException {       String oldVal;        if (getCommand() != null) {          if(!getCommand().equals(command)) {             oldVal = getCommand();             super.setCommand(command);             ps = null;             rs = null;             propertyChangeSupport.firePropertyChange("command", oldVal,command);          }       }       else {          super.setCommand(command);          propertyChangeSupport.firePropertyChange("command", null,command);       }    }     // Over riding the setDataSourceName from BaseRowSet for    // firing the propertyChangeSupport Event for    // Rave requirements when this property's values    // changes.     /**     * Sets the <code>dataSourceName</code> property for this <code>JdbcRowSet</code>     * object to the given logical name and sets this <code>JdbcRowSet</code> object's     * Url property to <code>null</code>. In addition, if the <code>dataSourceName</code>     * property has previously been set and is different from the one supplied,     * this method sets this <code>JdbcRowSet</code> object's private fields     * <code>ps</code>, <code>rs</code>, and <code>conn</code> to <code>null</code>.     * (The field <code>ps</code> is its <code>PreparedStatement</code> object,     * the field <code>rs</code> is its <code>ResultSet</code> object, and     * the field <code>conn</code> is its <code>Connection</code> object.)     * <P>     * The name supplied to this method must have been bound to a     * <code>DataSource</code> object in a JNDI naming service so that an     * application can do a lookup using that name to retrieve the     * <code>DataSource</code> object bound to it. The <code>DataSource</code>     * object can then be used to establish a connection to the data source it     * represents.     * <P>     * Users should set either the Url property or the dataSourceName property.     * If both properties are set, the driver will use the property set most recently.     *     * @param dsName a <code>String</code> object with the name that can be supplied     *        to a naming service based on JNDI technology to retrieve the     *        <code>DataSource</code> object that can be used to get a connection;     *        may be <code>null</code>     * @throws SQLException if there is a problem setting the     *          <code>dataSourceName</code> property     * @see #getDataSourceName     */    public void setDataSourceName(String dsName) throws SQLException{       String oldVal;        if(getDataSourceName() != null) {          if(!getDataSourceName().equals(dsName)) {             oldVal = getDataSourceName();             super.setDataSourceName(dsName);             conn = null;             ps = null;             rs = null;             propertyChangeSupport.firePropertyChange("dataSourceName",oldVal,dsName);          }       }       else {          super.setDataSourceName(dsName);          propertyChangeSupport.firePropertyChange("dataSourceName",null,dsName);       }    }     // Over riding the setUrl from BaseRowSet for    // firing the propertyChangeSupport Event for    // Rave requirements when this property's values    // changes.     /**     * Sets the Url property for this <code>JdbcRowSet</code> object     * to the given <code>String</code> object and sets the dataSource name     * property to <code>null</code>. In addition, if the Url property has     * previously been set to a non <code>null</code> value and its value     * is different from the value to be set,     * this method sets this <code>JdbcRowSet</code> object's private fields     * <code>ps</code>, <code>rs</code>, and <code>conn</code> to <code>null</code>.     * (The field <code>ps</code> is its <code>PreparedStatement</code> object,     * the field <code>rs</code> is its <code>ResultSet</code> object, and     * the field <code>conn</code> is its <code>Connection</code> object.)     * <P>     * The Url property is a JDBC URL that is used when     * the connection is created using a JDBC technology-enabled driver     * ("JDBC driver") and the <code>DriverManager</code>.     * The correct JDBC URL for the specific driver to be used can be found     * in the driver documentation.  Although there are guidelines for for how     * a JDBC URL is formed,     * a driver vendor can specify any <code>String</code> object except     * one with a length of <code>0</code> (an empty string).     * <P>     * Setting the Url property is optional if connections are established using     * a <code>DataSource</code> object instead of the <code>DriverManager</code>.     * The driver will use either the URL property or the     * dataSourceName property to create a connection, whichever was     * specified most recently. If an application uses a JDBC URL, it     * must load a JDBC driver that accepts the JDBC URL before it uses the     * <code>RowSet</code> object to connect to a database.  The <code>RowSet</code>     * object will use the URL internally to create a database connection in order     * to read or write data.     *     * @param url a <code>String</code> object that contains the JDBC URL     *            that will be used to establish the connection to a database for this     *            <code>RowSet</code> object; may be <code>null</code> but must not     *            be an empty string     * @throws SQLException if an error occurs setting the Url property or the     *         parameter supplied is a string with a length of <code>0</code> (an     *         empty string)     * @see #getUrl     */     public void setUrl(String url) throws SQLException {       String oldVal;        if(getUrl() != null) {          if(!getUrl().equals(url)) {             oldVal = getUrl();             super.setUrl(url);             conn = null;             ps = null;             rs = null;             propertyChangeSupport.firePropertyChange("url", oldVal, url);          }       }       else {          super.setUrl(url);          propertyChangeSupport.firePropertyChange("url", null, url);       }    }     // Over riding the setUsername from BaseRowSet for    // firing the propertyChangeSupport Event for    // Rave requirements when this property's values    // changes.      /**     * Sets the username property for this <code>JdbcRowSet</code> object     * to the given user name. Because it     * is not serialized, the username property is set at run time before     * calling the method <code>execute</code>. In addition,     * if the <code>username</code> property is already set with a     * non-null value and that value is different from the <code>String</code>     * object to be set,     * this method sets this <code>JdbcRowSet</code> object's private fields     * <code>ps</code>, <code>rs</code>, and <code>conn</code> to <code>null</code>.     * (The field <code>ps</code> is its <code>PreparedStatement</code> object,     * <code>rs</code> is its <code>ResultSet</code> object, and     * <code>conn</code> is its <code>Connection</code> object.)     * Setting these fields to <code>null</code> ensures that only current     * values will be used.     *     * @param uname the <code>String</code> object containing the user name that     *     is supplied to the data source to create a connection. It may be null.     * @see #getUsername     */    public void setUsername(String uname) {       String oldVal;        if( getUsername() != null) {          if(!getUsername().equals(uname)) {             oldVal = getUsername();             super.setUsername(uname);             conn = null;             ps = null;             rs = null;             propertyChangeSupport.firePropertyChange("username",oldVal,uname);          }       }       else{          super.setUsername(uname);          propertyChangeSupport.firePropertyChange("username",null,uname);       }    }     // Over riding the setPassword from BaseRowSet for    // firing the propertyChangeSupport Event for    // Rave requirements when this property's values    // changes.      /**     * Sets the password property for this <code>JdbcRowSet</code> object     * to the given <code>String</code> object. Because it     * is not serialized, the password property is set at run time before     * calling the method <code>execute</code>. Its default valus is     * <code>null</code>. In addition,     * if the <code>password</code> property is already set with a     * non-null value and that value is different from the one being set,     * this method sets this <code>JdbcRowSet</code> object's private fields     * <code>ps</code>, <code>rs</code>, and <code>conn</code> to <code>null</code>.     * (The field <code>ps</code> is its <code>PreparedStatement</code> object,     * <code>rs</code> is its <code>ResultSet</code> object, and     * <code>conn</code> is its <code>Connection</code> object.)     * Setting these fields to <code>null</code> ensures that only current     * values will be used.     *     * @param password the <code>String</code> object that represents the password     *     that must be supplied to the database to create a connection     */    public void setPassword(String password) {       String oldVal;        if ( getPassword() != null) {          if(!getPassword().equals(password)) {             oldVal = getPassword();             super.setPassword(password);             conn = null;             ps = null;             rs = null;             propertyChangeSupport.firePropertyChange("password",oldVal,password);          }       }       else{          super.setPassword(password);          propertyChangeSupport.firePropertyChange("password",null,password);       }    }     /**     * Sets the type for this <code>RowSet</code> object to the specified type.     * The default type is <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>.

Lines 4001–4500 of 7047. Previous lines