Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.JndiRefForwardingDataSource


    cpds.setUser( username );
    cpds.setPassword( password );
      cpds.setMaxPoolSize( 10 );
//      cpds.setUsesTraditionalReflectiveProxies( true );
       
    C3P0ProxyConnection conn = (C3P0ProxyConnection) cpds.getConnection();
    Method toStringMethod = Object.class.getMethod("toString", new Class[]{});
    Method identityHashCodeMethod = System.class.getMethod("identityHashCode", new Class[] {Object.class});
    System.out.println("rawConnection.toString() -> " +
           conn.rawConnectionOperation(toStringMethod, C3P0ProxyConnection.RAW_CONNECTION, new Object[]{}));
    Integer ihc = (Integer) conn.rawConnectionOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyConnection.RAW_CONNECTION});
    System.out.println("System.identityHashCode( rawConnection ) -> " + Integer.toHexString( ihc.intValue() ));

    C3P0ProxyStatement stmt = (C3P0ProxyStatement) conn.createStatement();
    System.out.println("rawStatement.toString() -> " +
           stmt.rawStatementOperation(toStringMethod, C3P0ProxyStatement.RAW_STATEMENT, new Object[]{}));
    Integer ihc2 = (Integer) stmt.rawStatementOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyStatement.RAW_STATEMENT});
    System.out.println("System.identityHashCode( rawStatement ) -> " + Integer.toHexString( ihc2.intValue() ));

    conn.close()

      for (int i = 0; i < 10; ++i)
          {
        C3P0ProxyConnection check = null;
        try
            {
          check = (C3P0ProxyConnection) cpds.getConnection();
          //System.err.println( TestUtils.samePhysicalConnection( conn, check ) );
          System.err.println( TestUtils.physicalConnectionIdentityHashCode( check ) == ihc.intValue() );
View Full Code Here


    cpds.setUser( username );
    cpds.setPassword( password );
      cpds.setMaxPoolSize( 10 );
//      cpds.setUsesTraditionalReflectiveProxies( true );
       
    C3P0ProxyConnection conn = (C3P0ProxyConnection) cpds.getConnection();
    Method toStringMethod = Object.class.getMethod("toString", new Class[]{});
    Method identityHashCodeMethod = System.class.getMethod("identityHashCode", new Class[] {Object.class});
    System.out.println("rawConnection.toString() -> " +
           conn.rawConnectionOperation(toStringMethod, C3P0ProxyConnection.RAW_CONNECTION, new Object[]{}));
    Integer ihc = (Integer) conn.rawConnectionOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyConnection.RAW_CONNECTION});
    System.out.println("System.identityHashCode( rawConnection ) -> " + Integer.toHexString( ihc.intValue() ));

    C3P0ProxyStatement stmt = (C3P0ProxyStatement) conn.createStatement();
    System.out.println("rawStatement.toString() -> " +
           stmt.rawStatementOperation(toStringMethod, C3P0ProxyStatement.RAW_STATEMENT, new Object[]{}));
    Integer ihc2 = (Integer) stmt.rawStatementOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyStatement.RAW_STATEMENT});
    System.out.println("System.identityHashCode( rawStatement ) -> " + Integer.toHexString( ihc2.intValue() ));

    conn.close()

      for (int i = 0; i < 10; ++i)
          {
        C3P0ProxyConnection check = null;
        try
            {
          check = (C3P0ProxyConnection) cpds.getConnection();
          //System.err.println( TestUtils.samePhysicalConnection( conn, check ) );
          System.err.println( TestUtils.physicalConnectionIdentityHashCode( check ) == ihc.intValue() );
View Full Code Here

          // We've been passed an instance of a MySQL connection --
          // no need for reflection
          ((com.mysql.jdbc.Connection) con).ping();
        } else {
          // Assume the connection is a C3P0 proxy
          C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;
          castCon.rawConnectionOperation(pingMethod,
              C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
        }
      } else {
        Statement pingStatement = null;
View Full Code Here

   * raw Connection (which is otherwise not directly supported by C3P0).
   * @see #getRawConnection
   */
  protected Connection doGetNativeConnection(Connection con) throws SQLException {
    if (con instanceof C3P0ProxyConnection) {
      C3P0ProxyConnection cpCon = (C3P0ProxyConnection) con;
      try {
        return (Connection) cpCon.rawConnectionOperation(
            this.getRawConnectionMethod, null, new Object[] {C3P0ProxyConnection.RAW_CONNECTION});
      }
      catch (SQLException ex) {
        throw ex;
      }
View Full Code Here

   * raw Connection (which is otherwise not directly supported by C3P0).
   * @see #getRawConnection
   */
  protected Connection doGetNativeConnection(Connection con) throws SQLException {
    if (con instanceof C3P0ProxyConnection) {
      C3P0ProxyConnection cpCon = (C3P0ProxyConnection) con;
      try {
        return (Connection) cpCon.rawConnectionOperation(
            this.getRawConnectionMethod, null, new Object[] {C3P0ProxyConnection.RAW_CONNECTION});
      }
      catch (SQLException ex) {
        throw ex;
      }
View Full Code Here

   * (non-Javadoc)
   *
   * @see com.mchange.v2.c3p0.ConnectionTester#activeCheckConnection(java.sql.Connection)
   */
  public int activeCheckConnection(Connection con) {
    C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;

    try {
      if (pingMethod != null) {
        castCon.rawConnectionOperation(pingMethod,
            C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
      } else {
        Statement pingStatement = null;

        try {
View Full Code Here

    cpds.setUser( username );
    cpds.setPassword( password );
      cpds.setMaxPoolSize( 10 );
//      cpds.setUsesTraditionalReflectiveProxies( true );
       
    C3P0ProxyConnection conn = (C3P0ProxyConnection) cpds.getConnection();
    Method toStringMethod = Object.class.getMethod("toString", new Class[]{});
    Method identityHashCodeMethod = System.class.getMethod("identityHashCode", new Class[] {Object.class});
    System.out.println("rawConnection.toString() -> " +
           conn.rawConnectionOperation(toStringMethod, C3P0ProxyConnection.RAW_CONNECTION, new Object[]{}));
    Integer ihc = (Integer) conn.rawConnectionOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyConnection.RAW_CONNECTION});
    System.out.println("System.identityHashCode( rawConnection ) -> " + Integer.toHexString( ihc.intValue() ));

    C3P0ProxyStatement stmt = (C3P0ProxyStatement) conn.createStatement();
    System.out.println("rawStatement.toString() -> " +
           stmt.rawStatementOperation(toStringMethod, C3P0ProxyStatement.RAW_STATEMENT, new Object[]{}));
    Integer ihc2 = (Integer) stmt.rawStatementOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyStatement.RAW_STATEMENT});
    System.out.println("System.identityHashCode( rawStatement ) -> " + Integer.toHexString( ihc2.intValue() ));

    conn.close()

      for (int i = 0; i < 10; ++i)
          {
        C3P0ProxyConnection check = null;
        try
            {
          check = (C3P0ProxyConnection) cpds.getConnection();
          //System.err.println( TestUtils.samePhysicalConnection( conn, check ) );
          System.err.println( TestUtils.physicalConnectionIdentityHashCode( check ) == ihc.intValue() );
View Full Code Here

          // We've been passed an instance of a MySQL connection --
          // no need for reflection
          ((com.mysql.jdbc.Connection) con).ping();
        } else {
          // Assume the connection is a C3P0 proxy
          C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;
          castCon.rawConnectionOperation(pingMethod,
              C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
        }
      } else {
        Statement pingStatement = null;
View Full Code Here

        //quartz 2.x uses c3p0, c3p0 doesn't support createBlob method as of 0.9.2       
        Connection conn = ps.getConnection();
        if (conn instanceof C3P0ProxyConnection) {
            try {
                C3P0ProxyConnection c3p0Conn = (C3P0ProxyConnection) conn;
                Method m = Connection.class.getMethod("createBlob", new Class[]{}); //will call createBlob method on the underlying connection
                Object[] args = new Object[]{}; //arguments to be passed to the method. none in this case
                Blob blob = (Blob) c3p0Conn.rawConnectionOperation(m, C3P0ProxyConnection.RAW_CONNECTION, args);
                blob.setBytes(1, byteArray);
                ps.setBlob(index, blob);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
View Full Code Here

   * @see #getRawConnection
   */
  @Override
  protected Connection doGetNativeConnection(Connection con) throws SQLException {
    if (con instanceof C3P0ProxyConnection) {
      C3P0ProxyConnection cpCon = (C3P0ProxyConnection) con;
      try {
        return (Connection) cpCon.rawConnectionOperation(
            this.getRawConnectionMethod, null, new Object[] {C3P0ProxyConnection.RAW_CONNECTION});
      }
      catch (SQLException ex) {
        throw ex;
      }
View Full Code Here

TOP

Related Classes of com.mchange.v2.c3p0.JndiRefForwardingDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.