Search in sources :

Example 91 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test5.

/**
     * Create SQLWarning with message, SQLState, errorCode, and Throwable
     */
@Test
public void test5() {
    SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 92 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test4.

/**
     * Create SQLWarning with message, SQLState, and error code
     */
@Test
public void test4() {
    SQLWarning ex = new SQLWarning(reason, state, errorCode);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && ex.getCause() == null && ex.getErrorCode() == errorCode);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 93 with SQLWarning

use of java.sql.SQLWarning in project jdk8u_jdk by JetBrains.

the class SQLWarningTests method test7.

/**
     * Create SQLWarning with message, and Throwable
     */
@Test
public void test7() {
    SQLWarning ex = new SQLWarning(reason, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
Also used : SQLWarning(java.sql.SQLWarning) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 94 with SQLWarning

use of java.sql.SQLWarning in project voltdb by VoltDB.

the class NonVoltDBBackend method runDDL.

public void runDDL(String ddl) {
    try {
        //LOG.info("Executing " + ddl);
        Statement stmt = dbconn.createStatement();
        /*boolean success =*/
        stmt.execute(ddl);
        SQLWarning warn = stmt.getWarnings();
        if (warn != null)
            sqlLog.warn(warn.getMessage());
    //LOG.info("SQL DDL execute result: " + (success ? "true" : "false"));
    } catch (SQLException e) {
        hostLog.l7dlog(Level.ERROR, LogKeys.host_Backend_RunDDLFailed.name(), new Object[] { ddl }, e);
    }
}
Also used : SQLWarning(java.sql.SQLWarning) SQLException(java.sql.SQLException) Statement(java.sql.Statement)

Example 95 with SQLWarning

use of java.sql.SQLWarning in project voltdb by VoltDB.

the class JDBCConnection method setClientInfo.

//#endif JAVA6
/** @todo 20051207 */
/**
     * 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 hostname of the computer the application
     *                                                  using the connection is running on.</li>
     * </ul>
     * <p>
     * @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 1.9.0
     */
//#ifdef JAVA6
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    try {
        checkClosed();
    } catch (SQLException ex) {
        SQLClientInfoException e = new SQLClientInfoException(ex.getMessage(), null);
        e.initCause(ex);
        throw e;
    }
    SQLWarning warning = new SQLWarning("ClientInfo name not recognized: " + name);
    warning.initCause(Util.notSupported());
    addWarning(warning);
}
Also used : SQLWarning(java.sql.SQLWarning) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException)

Aggregations

SQLWarning (java.sql.SQLWarning)153 SQLException (java.sql.SQLException)49 Statement (java.sql.Statement)37 PreparedStatement (java.sql.PreparedStatement)30 Connection (java.sql.Connection)26 ResultSet (java.sql.ResultSet)23 Test (org.testng.annotations.Test)19 Test (org.junit.Test)17 BaseTest (util.BaseTest)15 CallableStatement (java.sql.CallableStatement)13 ArrayList (java.util.ArrayList)9 JDBCStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement)8 ResultSetMetaData (java.sql.ResultSetMetaData)6 Expectations (org.jmock.Expectations)6 IOException (java.io.IOException)4 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)3 PrestoWarning (com.facebook.presto.spi.PrestoWarning)3 Properties (java.util.Properties)3 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)3 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)3