Java Code Examples for java.sql.SQLClientInfoException#initCause()

The following examples show how to use java.sql.SQLClientInfoException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDBC4ConnectionWrapper.java    From r-course with MIT License 6 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(properties);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 2
Source File: JDBC4ConnectionWrapper.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(name, value);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 3
Source File: JDBC4ConnectionWrapper.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(properties);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 4
Source File: JDBC4ClientInfoProviderSP.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void setClientInfo(java.sql.Connection conn, Properties properties) throws SQLClientInfoException {
    try {
        Enumeration<?> propNames = properties.propertyNames();

        while (propNames.hasMoreElements()) {
            String name = (String) propNames.nextElement();
            String value = properties.getProperty(name);

            setClientInfo(conn, name, value);
        }
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 5
Source File: ConnectionWrapper.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(properties);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 6
Source File: ClientInfoProviderSP.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void setClientInfo(java.sql.Connection conn, Properties properties) throws SQLClientInfoException {
    try {
        Enumeration<?> propNames = properties.propertyNames();

        while (propNames.hasMoreElements()) {
            String name = (String) propNames.nextElement();
            String value = properties.getProperty(name);

            setClientInfo(conn, name, value);
        }
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 7
Source File: ConnectionWrapper.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(name, value);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 8
Source File: ConnectionWrapper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(properties);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 9
Source File: ConnectionWrapper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        checkClosed();

        ((java.sql.Connection) this.mc).setClientInfo(name, value);
    } catch (SQLException sqlException) {
        try {
            checkAndFireConnectionError(sqlException);
        } catch (SQLException sqlEx2) {
            SQLClientInfoException clientEx = new SQLClientInfoException();
            clientEx.initCause(sqlEx2);

            throw clientEx;
        }
    }
}
 
Example 10
Source File: ConnectionImpl.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, name, value);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException | CJException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 11
Source File: JDBC4Connection.java    From r-course with MIT License 5 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, properties);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 12
Source File: JDBC4Connection.java    From r-course with MIT License 5 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, name, value);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 13
Source File: ConnectionImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, properties);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException | CJException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 14
Source File: JDBC4ClientInfoProviderSP.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
public synchronized void setClientInfo(java.sql.Connection conn, String name, String value) throws SQLClientInfoException {
    try {
        this.setClientInfoSp.setString(1, name);
        this.setClientInfoSp.setString(2, value);
        this.setClientInfoSp.execute();
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 15
Source File: JDBC4Connection.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, properties);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 16
Source File: JDBC4Connection.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, name, value);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 17
Source File: ConnectionImpl.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    try {
        getClientInfoProviderImpl().setClientInfo(this, properties);
    } catch (SQLClientInfoException ciEx) {
        throw ciEx;
    } catch (SQLException | CJException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 18
Source File: ClientInfoProviderSP.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void setClientInfo(java.sql.Connection conn, String name, String value) throws SQLClientInfoException {
    try {
        this.setClientInfoSp.setString(1, name);
        this.setClientInfoSp.setString(2, value);
        this.setClientInfoSp.execute();
    } catch (SQLException sqlEx) {
        SQLClientInfoException clientInfoEx = new SQLClientInfoException();
        clientInfoEx.initCause(sqlEx);

        throw clientInfoEx;
    }
}
 
Example 19
Source File: JDBCConnection.java    From evosql with Apache License 2.0 4 votes vote down vote up
/**
     * Sets the value of the connection's client info properties.  The
     * <code>Properties</code> object contains the names and values of the client info
     * properties to be set.  The set of client info properties contained in
     * the properties list replaces the current set of client info properties
     * on the connection.  If a property that is currently set on the
     * connection is not present in the properties list, that property is
     * cleared.  Specifying an empty properties list will clear all of the
     * properties on the connection.  See <code>setClientInfo (String, String)</code> for
     * more information.
     * <p>
     * If an error occurs in setting any of the client info properties, a
     * <code>SQLClientInfoException</code> is thrown. The <code>SQLClientInfoException</code>
     * contains information indicating which client info properties were not set.
     * The state of the client information is unknown because
     * some databases do not allow multiple client info properties to be set
     * atomically.  For those databases, one or more properties may have been
     * set before the error occurred.
     * <p>
     *
     * @param properties                the list of client info properties to set
     * <p>
     * @see java.sql.Connection#setClientInfo(String, String) setClientInfo(String, String)
     * @since JDK 1.6, HSQLDB 2.0
     * <p>
     * @throws SQLClientInfoException if the database server returns an error while
     *                  setting the clientInfo values on the database server or this method
     * is called on a closed connection
     * <p>
     */
//#ifdef JAVA6
    public void setClientInfo(
            Properties properties) throws SQLClientInfoException {

        if (!this.isClosed && (properties == null || properties.isEmpty())) {
            return;
        }

        SQLClientInfoException ex = new SQLClientInfoException();

        if (this.isClosed) {
            ex.initCause(JDBCUtil.connectionClosedException());
        } else {
            ex.initCause(JDBCUtil.notSupported());
        }

        throw ex;
    }
 
Example 20
Source File: JDBCConnection.java    From evosql with Apache License 2.0 3 votes vote down vote up
/**
     * Sets the value of the client info property specified by name to the
     * value specified by value.
     * <p>
     * Applications may use the <code>DatabaseMetaData.getClientInfoProperties</code>
     * method to determine the client info properties supported by the driver
     * and the maximum length that may be specified for each property.
     * <p>
     * The driver stores the value specified in a suitable location in the
     * database.  For example in a special register, session parameter, or
     * system table column.  For efficiency the driver may defer setting the
     * value in the database until the next time a statement is executed or
     * prepared.  Other than storing the client information in the appropriate
     * place in the database, these methods shall not alter the behavior of
     * the connection in anyway.  The values supplied to these methods are
     * used for accounting, diagnostics and debugging purposes only.
     * <p>
     * The driver shall generate a warning if the client info name specified
     * is not recognized by the driver.
     * <p>
     * If the value specified to this method is greater than the maximum
     * length for the property the driver may either truncate the value and
     * generate a warning or generate a <code>SQLClientInfoException</code>.  If the driver
     * generates a <code>SQLClientInfoException</code>, the value specified was not set on the
     * connection.
     * <p>
     * The following are standard client info properties.  Drivers are not
     * required to support these properties however if the driver supports a
     * client info property that can be described by one of the standard
     * properties, the standard property name should be used.
     * <p>
     * <ul>
     * <li>ApplicationName  -       The name of the application currently utilizing
     *                                                  the connection</li>
     * <li>ClientUser           -       The name of the user that the application using
     *                                                  the connection is performing work for.  This may
     *                                                  not be the same as the user name that was used
     *                                                  in establishing the connection.</li>
     * <li>ClientHostname   -       The host name of the computer the application
     *                                                  using the connection is running on.</li>
     * </ul>
     * <p>
     * <!-- start release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB 2.0, throws an SQLClientInfoException when this method is
     * called.
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param name          The name of the client info property to set
     * @param value         The value to set the client info property to.  If the
     *                                      value is null, the current value of the specified
     *                                      property is cleared.
     * <p>
     * @throws      SQLClientInfoException if the database server returns an error while
     *                      setting the client info value on the database server or this method
     * is called on a closed connection
     * <p>
     * @since JDK 1.6, HSQLDB 2.0
     */
//#ifdef JAVA6
    public void setClientInfo(String name,
                              String value) throws SQLClientInfoException {

        SQLClientInfoException ex = new SQLClientInfoException();

        ex.initCause(JDBCUtil.notSupported());

        throw ex;
    }