/**
  * 
  * @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;
             }
         });
     }
 }
예제 #2
0
  @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());
  }
예제 #3
0
  /**
   * 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
예제 #4
0
  @Override
  public void setClientInfo(Properties properties) throws SQLClientInfoException {
    if (holder == null) {
      throw new SQLClientInfoException();
    }

    conn.setClientInfo(properties);
  }
예제 #5
0
  @Override
  public void setClientInfo(String name, String value) throws SQLClientInfoException {
    if (holder == null) {
      throw new SQLClientInfoException();
    }

    conn.setClientInfo(name, value);
  }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
파일: Validator.java 프로젝트: kumon/presto
 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
   }
 }
예제 #9
0
 @Override
 public void setClientInfo(Properties properties) throws SQLClientInfoException {
   conn.setClientInfo(properties);
 }
예제 #10
0
 @Override
 public void setClientInfo(String s, String s1) throws SQLClientInfoException {
   conn.setClientInfo(s, s1);
 }
예제 #11
0
 public void setClientInfo(String name, String value) throws SQLClientInfoException {
   connection.setClientInfo(name, value);
 }
예제 #12
0
  @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);
  }
예제 #14
0
 @Override
 public void setClientInfo(String name, String value) throws SQLClientInfoException {
   _wrapped.setClientInfo(name, value);
 }