Package com.mysql.jdbc.jdbc2.optional

Examples of com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource


   * @throws Exception
   *             if the test fails.
   */
  public void testChangeUserAndCharsets() throws Exception {
    if (versionMeetsMinimum(4, 1)) {
      MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
      ds.setURL(BaseTestCase.dbUrl);
      ds.setCharacterEncoding("utf-8");
      PooledConnection pooledConnection = ds.getPooledConnection();

      Connection connToMySQL = pooledConnection.getConnection();
      this.rs = connToMySQL.createStatement().executeQuery(
          "SELECT @@character_set_results");
      assertTrue(this.rs.next());
View Full Code Here


      }
    }
   
    public void testInterfaceImplementation() throws Exception {
      testInterfaceImplementation(getConnectionWithProps((Properties)null));
      MysqlConnectionPoolDataSource cpds = new MysqlConnectionPoolDataSource();
      cpds.setUrl(dbUrl);
      testInterfaceImplementation(cpds.getPooledConnection().getConnection());
    }
View Full Code Here

    String host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
    String port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
   
    String newUrl =  "jdbc:mysql:loadbalance://" + host + ":" + port + "," + host + ":" + port + "/" + databaseStuff;
   
    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
    ds.setUrl(newUrl);
   
    Connection c = ds.getPooledConnection().getConnection();
    c.createStatement().executeQuery("SELECT 1");
    c.prepareStatement("SELECT 1").executeQuery();
  }
View Full Code Here

            if (jdbcUrl == null) {
                continue;
            }

            try {
                MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
                dataSource.setUrl(jdbcUrl);
                // these are in MS *not* seconds like everything else in JDBC
                dataSource.setConnectTimeout(getMaxConnectionWaitMillis());
                dataSource.setInitialTimeout(getMaxConnectionWaitMillis());
                dataSource.setDefaultFetchSize(defaultFetchSize);

                PooledConnection connection = dataSource.getPooledConnection();

                // that worked so save the datasource and server id
                this.dataSource = dataSource;
                this.currentServer = serviceDescriptor.getId();
                return connection;
View Full Code Here

    // Reset event count.
    this.closeEventCount = 0;
    this.connectionErrorEventCount = 0;

    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();

    ds.setURL(BaseTestCase.dbUrl);

    this.cpds = ds;
  }
View Full Code Here

   *
   * @throws Exception if the test fails
   */
  public void testBug35489() throws Exception {
    try {
      MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
      pds.setUrl(dbUrl);
      this.pstmt = pds.getPooledConnection().getConnection().prepareStatement("SELECT 1");
      this.pstmt.execute();
      this.pstmt.close();
     
      MysqlXADataSource xads = new MysqlXADataSource();
      xads.setUrl(dbUrl);
View Full Code Here

     * a prepared statement.
     *
   * @throws Exception
   */
  public void testBug32101() throws Exception {
    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
    ds.setURL(BaseTestCase.dbUrl);
    PooledConnection pc = ds.getPooledConnection();
    assertNotNull(pc.getConnection().prepareStatement("SELECT 1"));
    assertNotNull(pc.getConnection().prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
    assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new int[0]));
    assertNotNull(pc.getConnection().prepareStatement("SELECT 1", new String[0]));
    assertNotNull(pc.getConnection().prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
View Full Code Here

  }

  public void testBug35810() throws Exception {
    int defaultConnectTimeout = ((ConnectionProperties) this.conn).getConnectTimeout();
    int nonDefaultConnectTimeout = defaultConnectTimeout + 1000 * 2;
    MysqlConnectionPoolDataSource cpds = new MysqlConnectionPoolDataSource();
    String dsUrl = BaseTestCase.dbUrl;
    if (dsUrl.indexOf("?") == -1) {
      dsUrl += "?";
    } else {
      dsUrl += "&";
    }
   
    dsUrl += "connectTimeout=" + nonDefaultConnectTimeout;
    cpds.setUrl(dsUrl);
   
    Connection dsConn = cpds.getPooledConnection().getConnection();
    int configuredConnectTimeout = ((ConnectionProperties) dsConn).getConnectTimeout();
   
    assertEquals("Connect timeout spec'd by URL didn't take", nonDefaultConnectTimeout, configuredConnectTimeout);
    assertFalse("Connect timeout spec'd by URL didn't take", defaultConnectTimeout == configuredConnectTimeout);
  }
View Full Code Here

   *
   * @throws Exception
   *             if an error occurs.
   */
  public void testBug4808() throws Exception {
    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
    ds.setURL(BaseTestCase.dbUrl);
    PooledConnection closeMeTwice = ds.getPooledConnection();
    closeMeTwice.close();
    closeMeTwice.close();

  }
View Full Code Here

    String port = System.getProperty(DS_PORT_PROP_NAME);

    // Only run this test if at least one of the above are set
    if ((databaseName != null) || (userName != null) || (password != null)
        || (port != null)) {
      MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();

      if (databaseName != null) {
        ds.setDatabaseName(databaseName);
      }

      if (userName != null) {
        ds.setUser(userName);
      }

      if (password != null) {
        ds.setPassword(password);
      }

      if (port != null) {
        ds.setPortNumber(Integer.parseInt(port));
      }

      bindDataSource(jndiName, ds);

      ConnectionPoolDataSource boundDs = null;
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource

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.