com.mysql.cj.jdbc.JdbcStatement Java Examples
The following examples show how to use
com.mysql.cj.jdbc.JdbcStatement.
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: JDBCMySQLProcessor.java From quarkus with Apache License 2.0 | 6 votes |
@BuildStep List<NativeImageProxyDefinitionBuildItem> registerProxies() { List<NativeImageProxyDefinitionBuildItem> proxies = new ArrayList<>(); proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcConnection.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(MysqlConnection.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(Statement.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(AutoCloseable.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcStatement.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(Connection.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(ResultSet.class.getName())); proxies.add( new NativeImageProxyDefinitionBuildItem(JdbcPreparedStatement.class.getName(), JdbcStatement.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(JdbcPropertySet.class.getName(), PropertySet.class.getName(), Serializable.class.getName())); proxies.add( new NativeImageProxyDefinitionBuildItem(Resultset.class.getName(), ResultSetInternalMethods.class.getName())); proxies.add(new NativeImageProxyDefinitionBuildItem(LoadBalancedConnection.class.getName(), JdbcConnection.class.getName())); proxies.add( new NativeImageProxyDefinitionBuildItem(ReplicationConnection.class.getName(), JdbcConnection.class.getName())); proxies.add( new NativeImageProxyDefinitionBuildItem(ResultSetInternalMethods.class.getName(), WarningListener.class.getName(), Resultset.class.getName())); return proxies; }
Example #2
Source File: UtilsTest.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
/** * Tests Util.isJdbcInterface() * * @throws Exception */ public void testIsJdbcInterface() throws Exception { // Classes directly or indirectly implementing JDBC interfaces. assertTrue(Util.isJdbcInterface(ClientPreparedStatement.class)); assertTrue(Util.isJdbcInterface(StatementImpl.class)); assertTrue(Util.isJdbcInterface(JdbcStatement.class)); assertTrue(Util.isJdbcInterface(ResultSetImpl.class)); JdbcStatement s = (JdbcStatement) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[] { JdbcStatement.class }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return null; } }); assertTrue(Util.isJdbcInterface(s.getClass())); // Classes not implementing JDBC interfaces. assertFalse(Util.isJdbcInterface(Util.class)); assertFalse(Util.isJdbcInterface(UtilsTest.class)); }
Example #3
Source File: UtilsTest.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
/** * Tests Util.isJdbcPackage() * * @throws Exception */ public void testGetImplementedInterfaces() throws Exception { Class<?>[] ifaces; ifaces = Util.getImplementedInterfaces(JdbcStatement.class); assertEquals(2, ifaces.length); assertEquals(ifaces[0], java.sql.Statement.class); ifaces = Util.getImplementedInterfaces(StatementImpl.class); assertEquals(1, ifaces.length); assertEquals(ifaces[0], JdbcStatement.class); ifaces = Util.getImplementedInterfaces(ConnectionImpl.class); assertEquals(3, ifaces.length); List<Class<?>> ifacesList = Arrays.asList(ifaces); for (Class<?> clazz : new Class<?>[] { JdbcConnection.class, Serializable.class }) { assertTrue(ifacesList.contains(clazz)); } }
Example #4
Source File: ReplicationConnectionProxy.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Proxies method invocation on the java.sql.Connection interface. * This is the continuation of MultiHostConnectionProxy#invoke(Object, Method, Object[]). */ @Override Object invokeMore(Object proxy, Method method, Object[] args) throws Throwable { checkConnectionCapabilityForMethod(method); boolean invokeAgain = false; while (true) { try { Object result = method.invoke(this.thisAsConnection, args); if (result != null && result instanceof JdbcStatement) { ((JdbcStatement) result).setPingTarget(this); } return result; } catch (InvocationTargetException e) { if (invokeAgain) { invokeAgain = false; } else if (e.getCause() != null && e.getCause() instanceof SQLException && ((SQLException) e.getCause()).getSQLState() == MysqlErrorNumbers.SQL_STATE_INVALID_TRANSACTION_STATE && ((SQLException) e.getCause()).getErrorCode() == MysqlErrorNumbers.ERROR_CODE_NULL_LOAD_BALANCED_CONNECTION) { try { // Try to re-establish the connection with the last known read-only state. setReadOnly(this.readOnly); invokeAgain = true; } catch (SQLException sqlEx) { // Still not good. Swallow this exception. } } if (!invokeAgain) { throw e; } } } }
Example #5
Source File: ResultSetImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public void setOwningStatement(JdbcStatement owningStatement) { try { synchronized (checkClosed().getConnectionMutex()) { this.owningStatement = (StatementImpl) owningStatement; } } catch (SQLException e) { throw new RuntimeException(e); // FIXME: Need to evolve public interface } }
Example #6
Source File: ReplicationConnectionProxy.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
/** * Proxies method invocation on the java.sql.Connection interface. * This is the continuation of MultiHostConnectionProxy#invoke(Object, Method, Object[]). */ @Override Object invokeMore(Object proxy, Method method, Object[] args) throws Throwable { checkConnectionCapabilityForMethod(method); boolean invokeAgain = false; while (true) { try { Object result = method.invoke(this.thisAsConnection, args); if (result != null && result instanceof JdbcStatement) { ((JdbcStatement) result).setPingTarget(this); } return result; } catch (InvocationTargetException e) { if (invokeAgain) { invokeAgain = false; } else if (e.getCause() != null && e.getCause() instanceof SQLException && ((SQLException) e.getCause()).getSQLState() == MysqlErrorNumbers.SQL_STATE_INVALID_TRANSACTION_STATE && ((SQLException) e.getCause()).getErrorCode() == MysqlErrorNumbers.ERROR_CODE_NULL_LOAD_BALANCED_CONNECTION) { try { // Try to re-establish the connection with the last known read-only state. setReadOnly(this.readOnly); invokeAgain = true; } catch (SQLException sqlEx) { // Still not good. Swallow this exception. } } if (!invokeAgain) { throw e; } } } }
Example #7
Source File: ResultSetImpl.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
@Override public void setOwningStatement(JdbcStatement owningStatement) { try { synchronized (checkClosed().getConnectionMutex()) { this.owningStatement = (StatementImpl) owningStatement; } } catch (SQLException e) { throw new RuntimeException(e); // FIXME: Need to evolve public interface } }
Example #8
Source File: ResultSetInternalMethods.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Sets the statement that "owns" this result set (usually used when the * result set should internally "belong" to one statement, but is created * by another. * * @param owningStatement * the statement this result set will belong to */ void setOwningStatement(JdbcStatement owningStatement);
Example #9
Source File: ResultSetInternalMethods.java From FoxTelem with GNU General Public License v3.0 | 2 votes |
/** * Sets the statement that "owns" this result set (usually used when the * result set should internally "belong" to one statement, but is created * by another. * * @param owningStatement * the statement this result set will belong to */ void setOwningStatement(JdbcStatement owningStatement);