コード例 #1
0
  /**
   * Tests that the escape tokenizer converts timestamp values wrt. timezones when useTimezone=true.
   *
   * @throws Exception if the test fails.
   */
  public void testTimestampConversion() throws Exception {
    TimeZone currentTimezone = TimeZone.getDefault();
    String[] availableIds =
        TimeZone.getAvailableIDs(currentTimezone.getRawOffset() + (3600 * 1000 * 2));
    String newTimezone = null;

    if (availableIds.length > 0) {
      newTimezone = availableIds[0];
    } else {
      newTimezone = "UTC"; // punt
    }

    Properties props = new Properties();

    props.setProperty("useTimezone", "true");
    props.setProperty("serverTimezone", newTimezone);
    Connection tzConn = null;

    try {
      String escapeToken = "SELECT {ts '2002-11-12 10:00:00'} {t '05:11:02'}";
      tzConn = getConnectionWithProps(props);
      assertTrue(!tzConn.nativeSQL(escapeToken).equals(this.conn.nativeSQL(escapeToken)));
    } finally {
      if (tzConn != null) {
        tzConn.close();
      }
    }
  }
コード例 #2
0
 public String nativeSQL(String sql) throws SQLException {
   String methodCall = "nativeSQL(" + sql + ")";
   try {
     return (String) reportReturn(methodCall, realConnection.nativeSQL(sql));
   } catch (SQLException s) {
     reportException(methodCall, s, sql);
     throw s;
   }
 }
コード例 #3
0
 /**
  * Pass thru method to the wrapped jdbc 1.x {@link java.sql.Connection}.
  *
  * @exception SQLException if this connection is closed or an error occurs in the wrapped
  *     connection.
  */
 public String nativeSQL(String sql) throws SQLException {
   assertOpen();
   return connection.nativeSQL(sql);
 }
コード例 #4
0
 public String nativeSQL(String sql) throws SQLException {
   return con.nativeSQL(sql);
 }
コード例 #5
0
 @Override
 public String nativeSQL(String s) throws SQLException {
   return conn.nativeSQL(s);
 }
コード例 #6
0
  @Override
  public String nativeSQL(String sql) throws SQLException {
    checkState();

    return conn.nativeSQL(sql);
  }
コード例 #7
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) {
    }
  }
コード例 #8
0
 @Override
 public String nativeSQL(String sql) throws SQLException {
   return _wrapped.nativeSQL(sql);
 }