Java Code Examples for java.sql.SQLClientInfoException

The following are top voted examples for showing how to use java.sql.SQLClientInfoException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProyectoPacientes   File: JDBC4ConnectionWrapper.java   View source code 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 2
Project: the-vigilantes   File: JDBC4ConnectionWrapper.java   View source code 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 3
Project: the-vigilantes   File: JDBC4ConnectionWrapper.java   View source code 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 4
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 6 votes vote down vote up
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
            map, t1);
    SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
            map);
    SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
            map, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
 
Example 5
Project: BibliotecaPS   File: JDBC4ConnectionWrapper.java   View source code 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 6
Project: OpenVertretung   File: JDBC4ConnectionWrapper.java   View source code 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 7
Project: ProyectoPacientes   File: JDBC4ClientInfoProviderSP.java   View source code 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 8
Project: BibliotecaPS   File: JDBC4ConnectionWrapper.java   View source code 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
Project: lams   File: JDBC4ConnectionWrapper.java   View source code 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
Project: dremio-oss   File: Drill2489CallsAfterCloseThrowExceptionsTest.java   View source code 5 votes vote down vote up
@Override
protected boolean isOkaySpecialCaseException(Method method, Throwable cause) {
  final boolean result;
  if (super.isOkaySpecialCaseException(method, cause)) {
    result = true;
  }
  else if (SQLClientInfoException.class == cause.getClass()
            && normalClosedExceptionText.equals(cause.getMessage())
            && (false
                || method.getName().equals("setClientInfo")
                || method.getName().equals("getClientInfo")
                )) {
    // Special good case--we had to use SQLClientInfoException from those.
    result = true;
  }
  else if (RuntimeException.class == cause.getClass()
           && normalClosedExceptionText.equals(cause.getMessage())
           && (false
               || method.getName().equals("getCatalog")
               || method.getName().equals("getSchema")
               )) {
    // Special good-enough case--we had to use RuntimeException for now.
    result = true;
  }
  else {
    result = false;
  }
  return result;
}
 
Example 11
Project: sstore-soft   File: BaseConnectionWrapper.java   View source code 5 votes vote down vote up
public void setClientInfo(
        Properties properties) throws SQLClientInfoException {

    try {
        validate();
    } catch (SQLException e) {
        throw new SQLClientInfoException(e.getMessage(), e.getSQLState(),
                e.getErrorCode(), (Map<String, ClientInfoStatus>) null, e);
    }
    this.getConnection().setClientInfo(properties);
}
 
Example 12
Project: openjdk-jdk10   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Serialize a SQLClientInfoException and make sure you can read it back
 * properly
 */
@Test
public void test10() throws Exception {
    SQLClientInfoException e = new SQLClientInfoException(reason, state,
            errorCode, map, t);
    SQLClientInfoException ex1 =
            createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && cause.equals(ex1.getCause().toString())
            && ex1.getErrorCode() == errorCode
            && ex1.getFailedProperties().equals(map));
}
 
Example 13
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message, SQLState, and error code
 */
@Test
public void test8() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, state,
            errorCode, map, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == errorCode
            && ex.getFailedProperties().equals(map));
}
 
Example 14
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message, SQLState, errorCode, and
 * Throwable
 */
@Test
public void test7() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, state,
            errorCode, map);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == errorCode
            && ex.getFailedProperties().equals(map));
}
 
Example 15
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with null Throwable
 */
@Test
public void test4() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0
            && ex.getFailedProperties().equals(map));
}
 
Example 16
Project: openjdk-jdk10   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message
 */
@Test
public void test3() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, map);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0
            && ex.getFailedProperties().equals(map));
}
 
Example 17
Project: dswork.jdbc   File: ConnectionSpy.java   View source code 5 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException
{
	try
	{
		realConnection.setClientInfo(properties);
	}
	catch(SQLClientInfoException s)
	{
		String methodCall = "setClientInfo(" + properties + ")";
		reportException(methodCall, s, null);
		throw s;
	}
}
 
Example 18
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Serialize a SQLClientInfoException and make sure you can read it back
 * properly
 */
@Test
public void test10() throws Exception {
    SQLClientInfoException e = new SQLClientInfoException(reason, state,
            errorCode, map, t);
    SQLClientInfoException ex1 =
            createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && cause.equals(ex1.getCause().toString())
            && ex1.getErrorCode() == errorCode
            && ex1.getFailedProperties().equals(map));
}
 
Example 19
Project: OpenVertretung   File: JDBC4Connection.java   View source code 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 20
Project: openjdk-jdk10   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message, and SQLState
 */
@Test
public void test5() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, state,
            map);

    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == 0
            && ex.getFailedProperties().equals(map));
}
 
Example 21
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message
 */
@Test
public void test3() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, map);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0
            && ex.getFailedProperties().equals(map));
}
 
Example 22
Project: openjdk-jdk10   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message, SQLState, errorCode, and
 * Throwable
 */
@Test
public void test7() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, state,
            errorCode, map);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == errorCode
            && ex.getFailedProperties().equals(map));
}
 
Example 23
Project: ProyectoPacientes   File: JDBC4Connection.java   View source code 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 24
Project: openjdk-jdk10   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with message, and SQLState
 */
@Test
public void test6() {
    SQLClientInfoException ex = new SQLClientInfoException(reason, state,
            map, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == 0
            && ex.getFailedProperties().equals(map));
}
 
Example 25
Project: dswork.jdbc   File: ConnectionSpy.java   View source code 5 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException
{
	try
	{
		realConnection.setClientInfo(name, value);
	}
	catch(SQLClientInfoException s)
	{
		String methodCall = "setClientInfo(" + name + ", " + value + ")";
		reportException(methodCall, s, null);
		throw s;
	}
}
 
Example 26
Project: lams   File: JDBC4Connection.java   View source code 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 27
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException and setting all objects to null
 */
@Test
public void test() {
    SQLClientInfoException e = new SQLClientInfoException(null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null
            && e.getCause() == null && e.getErrorCode() == 0
            && e.getFailedProperties() == null);
}
 
Example 28
Project: dswork   File: ConnectionSpy.java   View source code 5 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException
{
	try
	{
		realConnection.setClientInfo(properties);
	}
	catch(SQLClientInfoException s)
	{
		String methodCall = "setClientInfo(" + properties + ")";
		reportException(methodCall, s, null);
		throw s;
	}
}
 
Example 29
Project: lams   File: SQLExceptionTypeDelegate.java   View source code 5 votes vote down vote up
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
	if ( SQLClientInfoException.class.isInstance( sqlException )
			|| SQLInvalidAuthorizationSpecException.class.isInstance( sqlException )
			|| SQLNonTransientConnectionException.class.isInstance( sqlException )
			|| SQLTransientConnectionException.class.isInstance( sqlException ) ) {
		return new JDBCConnectionException( message, sqlException, sql );
	}
	else if ( DataTruncation.class.isInstance( sqlException ) ||
			SQLDataException.class.isInstance( sqlException ) ) {
		throw new DataException( message, sqlException, sql );
	}
	else if ( SQLIntegrityConstraintViolationException.class.isInstance( sqlException ) ) {
		return new ConstraintViolationException(
				message,
				sqlException,
				sql,
				getConversionContext().getViolatedConstraintNameExtracter().extractConstraintName( sqlException )
		);
	}
	else if ( SQLSyntaxErrorException.class.isInstance( sqlException ) ) {
		return new SQLGrammarException( message, sqlException, sql );
	}
	else if ( SQLTimeoutException.class.isInstance( sqlException ) ) {
		return new QueryTimeoutException( message, sqlException, sql );
	}
	else if ( SQLTransactionRollbackException.class.isInstance( sqlException ) ) {
		// Not 100% sure this is completely accurate.  The JavaDocs for SQLTransactionRollbackException state that
		// it indicates sql states starting with '40' and that those usually indicate that:
		//		<quote>
		//			the current statement was automatically rolled back by the database because of deadlock or
		// 			other transaction serialization failures.
		//		</quote>
		return new LockAcquisitionException( message, sqlException, sql );
	}

	return null; // allow other delegates the chance to look
}
 
Example 30
Project: jdk8u-jdk   File: SQLClientInfoExceptionTests.java   View source code 5 votes vote down vote up
/**
 * Create SQLClientInfoException with no-arg constructor
 */
@Test
public void test1() {
    SQLClientInfoException ex = new SQLClientInfoException();
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0
            && ex.getFailedProperties() == null);
}
 
Example 31
Project: iotdb-jdbc   File: TsfileConnection.java   View source code 4 votes vote down vote up
@Override
   public void setClientInfo(String arg0, String arg1) throws SQLClientInfoException {
throw new SQLClientInfoException("Method not supported", null);
   }
 
Example 32
Project: OpenDiabetes   File: JDBCConnection.java   View source code 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 33
Project: burstcoin   File: FilteredConnection.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    con.setClientInfo(properties);
}
 
Example 34
Project: openjdk-jdk10   File: StubConnection.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 35
Project: preflex   File: ConnectionWrapper.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    conn.setClientInfo(properties);
}
 
Example 36
Project: BibliotecaPS   File: JDBC4ReplicationMySQLConnection.java   View source code 4 votes vote down vote up
public void setClientInfo(String name, String value) throws SQLClientInfoException {
    this.getJDBC4Connection().setClientInfo(name, value);
}
 
Example 37
Project: pugtsdb   File: PugConnection.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    connection.setClientInfo(properties);
}
 
Example 38
Project: openjdk-jdk10   File: StubConnection.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 39
Project: mycat-src-1.6.1-RELEASE   File: MongoConnection.java   View source code 4 votes vote down vote up
@Override
public void setClientInfo(String name, String value)
		throws SQLClientInfoException {
	
	this._clientInfo.put(name, value);
}
 
Example 40
Project: BibliotecaPS   File: JDBC4ReplicationMySQLConnection.java   View source code 4 votes vote down vote up
public void setClientInfo(Properties properties) throws SQLClientInfoException {
    this.getJDBC4Connection().setClientInfo(properties);
}