Search in sources :

Example 1 with FailedProperties40

use of org.apache.derby.iapi.jdbc.FailedProperties40 in project derby by apache.

the class EmbedConnection method setClientInfo.

/**
 * <code>setClientInfo</code> will always throw a
 * <code>SQLClientInfoException</code> since Derby does not support
 * any properties.
 *
 * @param name a property key <code>String</code>
 * @param value a property value <code>String</code>
 * @exception SQLClientInfoException unless both name and value are null
 */
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    Properties p = FailedProperties40.makeProperties(name, value);
    try {
        checkIfClosed();
    } catch (SQLException se) {
        FailedProperties40 fp = new FailedProperties40(p);
        throw new SQLClientInfoException(se.getMessage(), se.getSQLState(), se.getErrorCode(), fp.getProperties());
    }
    // arguments)
    if (name == null && value == null) {
        return;
    }
    setClientInfo(p);
}
Also used : SQLClientInfoException(java.sql.SQLClientInfoException) FailedProperties40(org.apache.derby.iapi.jdbc.FailedProperties40) SQLException(java.sql.SQLException) Properties(java.util.Properties)

Example 2 with FailedProperties40

use of org.apache.derby.iapi.jdbc.FailedProperties40 in project derby by apache.

the class EmbedConnection method setClientInfo.

/**
 * <code>setClientInfo</code> will throw a
 * <code>SQLClientInfoException</code> unless the <code>properties</code>
 * parameter is empty, since Derby does not support any
 * properties. All the property keys in the
 * <code>properties</code> parameter are added to failedProperties
 * of the exception thrown, with REASON_UNKNOWN_PROPERTY as the
 * value.
 *
 * @param properties a <code>Properties</code> object with the
 * properties to set
 * @exception SQLClientInfoException unless properties parameter
 * is null or empty
 */
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    FailedProperties40 fp = new FailedProperties40(properties);
    try {
        checkIfClosed();
    } catch (SQLException se) {
        throw new SQLClientInfoException(se.getMessage(), se.getSQLState(), se.getErrorCode(), fp.getProperties());
    }
    // An empty properties object is meaningless, but allowed
    if (properties == null || properties.isEmpty()) {
        return;
    }
    StandardException se = StandardException.newException(SQLState.PROPERTY_UNSUPPORTED_CHANGE, fp.getFirstKey(), fp.getFirstValue());
    throw new SQLClientInfoException(se.getMessage(), se.getSQLState(), se.getErrorCode(), fp.getProperties());
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) SQLClientInfoException(java.sql.SQLClientInfoException) FailedProperties40(org.apache.derby.iapi.jdbc.FailedProperties40) SQLException(java.sql.SQLException)

Aggregations

SQLClientInfoException (java.sql.SQLClientInfoException)2 SQLException (java.sql.SQLException)2 FailedProperties40 (org.apache.derby.iapi.jdbc.FailedProperties40)2 Properties (java.util.Properties)1 StandardException (org.apache.derby.shared.common.error.StandardException)1