< prev index next >

src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 835      * application can do a lookup using that name to retrieve the
 836      * <code>DataSource</code> object bound to it. The <code>DataSource</code>
 837      * object can then be used to establish a connection to the data source it
 838      * represents.
 839      * <P>
 840      * Users should set either the Url property or the dataSourceName property.
 841      * If both properties are set, the driver will use the property set most recently.
 842      *
 843      * @param name a <code>String</code> object with the name that can be supplied
 844      *     to a naming service based on JNDI technology to retrieve the
 845      *     <code>DataSource</code> object that can be used to get a connection;
 846      *     may be <code>null</code> but must not be an empty string
 847      * @throws SQLException if an empty string is provided as the <code>DataSource</code>
 848      *    name
 849      * @see #getDataSourceName
 850      */
 851     public void setDataSourceName(String name) throws SQLException {
 852 
 853         if (name == null) {
 854             dataSource = null;
 855         } else if (name.equals("")) {
 856            throw new SQLException("DataSource name cannot be empty string");
 857         } else {
 858            dataSource = name;
 859         }
 860 
 861         URL = null;
 862     }
 863 
 864     /**
 865      * Returns the user name used to create a database connection.  Because it
 866      * is not serialized, the username property is set at runtime before
 867      * calling the method <code>execute</code>.
 868      *
 869      * @return the <code>String</code> object containing the user name that
 870      *         is supplied to the data source to create a connection; may be
 871      *         <code>null</code> (default value) if not set
 872      * @see #setUsername
 873      */
 874     public String getUsername() {
 875         return username;




 835      * application can do a lookup using that name to retrieve the
 836      * <code>DataSource</code> object bound to it. The <code>DataSource</code>
 837      * object can then be used to establish a connection to the data source it
 838      * represents.
 839      * <P>
 840      * Users should set either the Url property or the dataSourceName property.
 841      * If both properties are set, the driver will use the property set most recently.
 842      *
 843      * @param name a <code>String</code> object with the name that can be supplied
 844      *     to a naming service based on JNDI technology to retrieve the
 845      *     <code>DataSource</code> object that can be used to get a connection;
 846      *     may be <code>null</code> but must not be an empty string
 847      * @throws SQLException if an empty string is provided as the <code>DataSource</code>
 848      *    name
 849      * @see #getDataSourceName
 850      */
 851     public void setDataSourceName(String name) throws SQLException {
 852 
 853         if (name == null) {
 854             dataSource = null;
 855         } else if (name.isEmpty()) {
 856            throw new SQLException("DataSource name cannot be empty string");
 857         } else {
 858            dataSource = name;
 859         }
 860 
 861         URL = null;
 862     }
 863 
 864     /**
 865      * Returns the user name used to create a database connection.  Because it
 866      * is not serialized, the username property is set at runtime before
 867      * calling the method <code>execute</code>.
 868      *
 869      * @return the <code>String</code> object containing the user name that
 870      *         is supplied to the data source to create a connection; may be
 871      *         <code>null</code> (default value) if not set
 872      * @see #setUsername
 873      */
 874     public String getUsername() {
 875         return username;


< prev index next >