607
608 private Connection connect() throws SQLException {
609
610 // Get a JDBC connection.
611
612 // First check for Connection handle object as such if
613 // "this" initialized using conn.
614
615 if(conn != null) {
616 return conn;
617
618 } else if (getDataSourceName() != null) {
619
620 // Connect using JNDI.
621 try {
622 Context ctx = new InitialContext();
623 DataSource ds = (DataSource)ctx.lookup
624 (getDataSourceName());
625 //return ds.getConnection(getUsername(),getPassword());
626
627 if(getUsername() != null && !getUsername().equals("")) {
628 return ds.getConnection(getUsername(),getPassword());
629 } else {
630 return ds.getConnection();
631 }
632 }
633 catch (javax.naming.NamingException ex) {
634 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString());
635 }
636
637 } else if (getUrl() != null) {
638 // Check only for getUrl() != null because
639 // user, passwd can be null
640 // Connect using the driver manager.
641
642 return DriverManager.getConnection
643 (getUrl(), getUsername(), getPassword());
644 }
645 else {
646 return null;
647 }
3856 }
3857
3858 /**
3859 * Sets the designated parameter to the given String array.
3860 * This forms the basis of the join for the
3861 * {@code JoinRowSet} as the column which will form the basis of the
3862 * join.
3863 * <P>
3864 * The parameter value set by this method is stored internally and
3865 * will be supplied as the appropriate parameter in this rowset's
3866 * command when the method {@code getMatchColumn} is called.
3867 *
3868 * @param columnNames the name of the column into this rowset
3869 * object's internal representation of parameter values
3870 * @throws SQLException if an error occurs or the
3871 * parameter index is out of bounds
3872 */
3873 public void setMatchColumn(String[] columnNames) throws SQLException {
3874
3875 for(int j = 0; j < columnNames.length; j++) {
3876 if( columnNames[j] == null || columnNames[j].equals("")) {
3877 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
3878 }
3879 }
3880 for( int i = 0; i < columnNames.length; i++) {
3881 strMatchColumns.add(i,columnNames[i]);
3882 }
3883 }
3884
3885
3886 /**
3887 * Sets the designated parameter to the given {@code int}
3888 * object. This forms the basis of the join for the
3889 * {@code JoinRowSet} as the column which will form the basis of the
3890 * join.
3891 * <P>
3892 * The parameter value set by this method is stored internally and
3893 * will be supplied as the appropriate parameter in this rowset's
3894 * command when the method {@code getMatchColumn} is called.
3895 *
3896 * @param columnIdx the index into this rowset
3911 }
3912 }
3913
3914 /**
3915 * Sets the designated parameter to the given {@code String}
3916 * object. This forms the basis of the join for the
3917 * {@code JoinRowSet} as the column which will form the basis of the
3918 * join.
3919 * <P>
3920 * The parameter value set by this method is stored internally and
3921 * will be supplied as the appropriate parameter in this rowset's
3922 * command when the method {@code getMatchColumn} is called.
3923 *
3924 * @param columnName the name of the column into this rowset
3925 * object's internal representation of parameter values
3926 * @throws SQLException if an error occurs or the
3927 * parameter index is out of bounds
3928 */
3929 public void setMatchColumn(String columnName) throws SQLException {
3930 // validate, if col is ok to be set
3931 if(columnName == null || (columnName= columnName.trim()).equals("")) {
3932 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
3933 } else {
3934 // set strMatchColumn
3935 strMatchColumns.set(0, columnName);
3936 //iMatchColumn = -1;
3937 }
3938 }
3939
3940 /**
3941 * Unsets the designated parameter to the given {@code int}
3942 * object. This was set using {@code setMatchColumn}
3943 * as the column which will form the basis of the join.
3944 * <P>
3945 * The parameter value unset by this method should be same
3946 * as was set.
3947 *
3948 * @param columnIdx the index into this rowset
3949 * object's internal representation of parameter values
3950 * @throws SQLException if an error occurs or the
3951 * parameter index is out of bounds or if the columnIdx is
|
607
608 private Connection connect() throws SQLException {
609
610 // Get a JDBC connection.
611
612 // First check for Connection handle object as such if
613 // "this" initialized using conn.
614
615 if(conn != null) {
616 return conn;
617
618 } else if (getDataSourceName() != null) {
619
620 // Connect using JNDI.
621 try {
622 Context ctx = new InitialContext();
623 DataSource ds = (DataSource)ctx.lookup
624 (getDataSourceName());
625 //return ds.getConnection(getUsername(),getPassword());
626
627 if(getUsername() != null && !getUsername().isEmpty()) {
628 return ds.getConnection(getUsername(),getPassword());
629 } else {
630 return ds.getConnection();
631 }
632 }
633 catch (javax.naming.NamingException ex) {
634 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString());
635 }
636
637 } else if (getUrl() != null) {
638 // Check only for getUrl() != null because
639 // user, passwd can be null
640 // Connect using the driver manager.
641
642 return DriverManager.getConnection
643 (getUrl(), getUsername(), getPassword());
644 }
645 else {
646 return null;
647 }
3856 }
3857
3858 /**
3859 * Sets the designated parameter to the given String array.
3860 * This forms the basis of the join for the
3861 * {@code JoinRowSet} as the column which will form the basis of the
3862 * join.
3863 * <P>
3864 * The parameter value set by this method is stored internally and
3865 * will be supplied as the appropriate parameter in this rowset's
3866 * command when the method {@code getMatchColumn} is called.
3867 *
3868 * @param columnNames the name of the column into this rowset
3869 * object's internal representation of parameter values
3870 * @throws SQLException if an error occurs or the
3871 * parameter index is out of bounds
3872 */
3873 public void setMatchColumn(String[] columnNames) throws SQLException {
3874
3875 for(int j = 0; j < columnNames.length; j++) {
3876 if( columnNames[j] == null || columnNames[j].isEmpty()) {
3877 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
3878 }
3879 }
3880 for( int i = 0; i < columnNames.length; i++) {
3881 strMatchColumns.add(i,columnNames[i]);
3882 }
3883 }
3884
3885
3886 /**
3887 * Sets the designated parameter to the given {@code int}
3888 * object. This forms the basis of the join for the
3889 * {@code JoinRowSet} as the column which will form the basis of the
3890 * join.
3891 * <P>
3892 * The parameter value set by this method is stored internally and
3893 * will be supplied as the appropriate parameter in this rowset's
3894 * command when the method {@code getMatchColumn} is called.
3895 *
3896 * @param columnIdx the index into this rowset
3911 }
3912 }
3913
3914 /**
3915 * Sets the designated parameter to the given {@code String}
3916 * object. This forms the basis of the join for the
3917 * {@code JoinRowSet} as the column which will form the basis of the
3918 * join.
3919 * <P>
3920 * The parameter value set by this method is stored internally and
3921 * will be supplied as the appropriate parameter in this rowset's
3922 * command when the method {@code getMatchColumn} is called.
3923 *
3924 * @param columnName the name of the column into this rowset
3925 * object's internal representation of parameter values
3926 * @throws SQLException if an error occurs or the
3927 * parameter index is out of bounds
3928 */
3929 public void setMatchColumn(String columnName) throws SQLException {
3930 // validate, if col is ok to be set
3931 if(columnName == null || (columnName= columnName.trim()).isEmpty()) {
3932 throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
3933 } else {
3934 // set strMatchColumn
3935 strMatchColumns.set(0, columnName);
3936 //iMatchColumn = -1;
3937 }
3938 }
3939
3940 /**
3941 * Unsets the designated parameter to the given {@code int}
3942 * object. This was set using {@code setMatchColumn}
3943 * as the column which will form the basis of the join.
3944 * <P>
3945 * The parameter value unset by this method should be same
3946 * as was set.
3947 *
3948 * @param columnIdx the index into this rowset
3949 * object's internal representation of parameter values
3950 * @throws SQLException if an error occurs or the
3951 * parameter index is out of bounds or if the columnIdx is
|