/** * * @throws Exception */ public void testBug56122() throws Exception { for (final Connection testConn : new Connection[] { this.conn, getFailoverConnection(), getLoadBalancedConnection(), getMasterSlaveReplicationConnection() }) { testConn.createClob(); testConn.createBlob(); testConn.createNClob(); testConn.createSQLXML(); testConn.isValid(12345); testConn.setClientInfo(new Properties()); testConn.setClientInfo("NAME", "VALUE"); testConn.getClientInfo(); testConn.getClientInfo("CLIENT"); assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() { public Void call() throws Exception { testConn.createArrayOf("A_TYPE", null); return null; } }); assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() { public Void call() throws Exception { testConn.createStruct("A_TYPE", null); return null; } }); } }
@Test public void testConnection() throws Exception { Connection conn = getConnection(); assertNull(conn.getMetaData()); assertFalse(conn.getAutoCommit()); conn.setAutoCommit(true); assertTrue(conn.getAutoCommit()); conn.setAutoCommit(false); assertTrue(conn.isReadOnly()); conn.setReadOnly(true); assertTrue(conn.isReadOnly()); assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); assertEquals(Connection.TRANSACTION_READ_UNCOMMITTED, conn.getTransactionIsolation()); conn.setTransactionIsolation(Connection.TRANSACTION_NONE); assertNull(conn.getWarnings()); conn.clearWarnings(); assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, conn.getHoldability()); conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT); conn.commit(); conn.rollback(); assertTrue(conn.isValid(0)); conn.setClientInfo("prop1", "value1"); Properties props = new Properties(); props.setProperty("prop2", "value2"); props.setProperty("prop3", "value3"); conn.setClientInfo(props); assertEquals("value1", conn.getClientInfo("prop1")); assertEquals("value2", conn.getClientInfo("prop2")); assertEquals("value3", conn.getClientInfo("prop3")); Properties props2 = conn.getClientInfo(); assertEquals("value1", props2.getProperty("prop1")); assertEquals("value2", props2.getProperty("prop2")); assertEquals("value3", props2.getProperty("prop3")); assertNotNull(((JcrJdbcConnection) conn).getJcrSession()); assertFalse(conn.isClosed()); conn.close(); assertTrue(conn.isClosed()); }
/** * Set Connection * * @param conn connection */ private void setConnection(Connection conn) { if (conn == null) { return; } m_connection = conn; log.trace("Connection={}", conn); // // Configure the connection try { m_connection.setAutoCommit(false); // // Get Connection's backend PID (if configured) if (getTrxManager().isDebugConnectionBackendId()) { final boolean throwDBException = true; // we expect everything to be in order to get a PID final String debugConnectionBackendId = DB.getDatabase().getConnectionBackendId(m_connection, throwDBException); setDebugConnectionBackendId(debugConnectionBackendId); } // NOTE: works with c3p0 from version 0.9.5 (released on 02.01.2015) m_connection.setClientInfo("ApplicationName", "adempiere/" + getTrxName()); // task 08353 } catch (Exception e) { log.error("connection", e); } } // setConnection
@Override public void setClientInfo(Properties properties) throws SQLClientInfoException { if (holder == null) { throw new SQLClientInfoException(); } conn.setClientInfo(properties); }
@Override public void setClientInfo(String name, String value) throws SQLClientInfoException { if (holder == null) { throw new SQLClientInfoException(); } conn.setClientInfo(name, value); }
public void setClientInfo(String name, String value) throws SQLClientInfoException { String methodCall = "setClientInfo(" + name + ", " + value + ")"; try { realConnection.setClientInfo(name, value); } catch (SQLClientInfoException s) { reportException(methodCall, s); throw s; } reportReturn(methodCall); }
public void setClientInfo(Properties properties) throws SQLClientInfoException { // todo: dump properties? String methodCall = "setClientInfo(" + properties + ")"; try { realConnection.setClientInfo(properties); } catch (SQLClientInfoException s) { reportException(methodCall, s); throw s; } reportReturn(methodCall); }
private void trySetConnectionProperties(Query query, Connection connection) throws SQLException { // Required for jdbc drivers that do not implement all/some of these functions (eg. impala jdbc // driver) // For these drivers, set the database default values in the query database try { connection.setClientInfo("ApplicationName", "verifier-test:" + queryPair.getName()); connection.setCatalog(query.getCatalog()); connection.setSchema(query.getSchema()); } catch (SQLClientInfoException ignored) { // Do nothing } }
@Override public void setClientInfo(Properties properties) throws SQLClientInfoException { conn.setClientInfo(properties); }
@Override public void setClientInfo(String s, String s1) throws SQLClientInfoException { conn.setClientInfo(s, s1); }
public void setClientInfo(String name, String value) throws SQLClientInfoException { connection.setClientInfo(name, value); }
@Test public void testConnectionWhenClosed() throws Exception { Connection conn = getConnection(); conn.close(); try { conn.createStatement(); fail(); } catch (SQLException ignore) { } try { conn.createStatement(1, 1); fail(); } catch (SQLException ignore) { } try { conn.createStatement(1, 1, 1); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null, 1, 1); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null, 1, 1, 1); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null, 1); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null, (int[]) null); fail(); } catch (SQLException ignore) { } try { conn.prepareStatement(null, (String[]) null); fail(); } catch (SQLException ignore) { } try { conn.nativeSQL(null); fail(); } catch (SQLException ignore) { } try { conn.setAutoCommit(true); fail(); } catch (SQLException ignore) { } try { conn.getAutoCommit(); fail(); } catch (SQLException ignore) { } try { conn.commit(); fail(); } catch (SQLException ignore) { } try { conn.rollback(); fail(); } catch (SQLException ignore) { } try { conn.setReadOnly(true); fail(); } catch (SQLException ignore) { } try { conn.isReadOnly(); fail(); } catch (SQLException ignore) { } try { conn.setTransactionIsolation(1); fail(); } catch (SQLException ignore) { } try { conn.getTransactionIsolation(); fail(); } catch (SQLException ignore) { } try { conn.setHoldability(1); fail(); } catch (SQLException ignore) { } try { conn.getHoldability(); fail(); } catch (SQLException ignore) { } try { conn.setClientInfo("var1", "value1"); fail(); } catch (SQLException ignore) { } try { conn.getClientInfo("var1"); fail(); } catch (SQLException ignore) { } try { conn.setClientInfo(null); fail(); } catch (SQLException ignore) { } try { conn.getClientInfo(); fail(); } catch (SQLException ignore) { } }
private void setModule(Connection conn, String module_name) throws SQLException { conn.setClientInfo("OCSID.MODULE", module_name); }
@Override public void setClientInfo(String name, String value) throws SQLClientInfoException { _wrapped.setClientInfo(name, value); }