Package com.mysql.jdbc.jdbc2.optional

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


    String serverName = System.getProperty(DS_HOST_PROP_NAME);

    // Only run this test if at least one of the above are set
    if ((databaseName != null) || (serverName != 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));
      }

      if (serverName != null) {
        ds.setServerName(serverName);
      }

      bindDataSource(jndiName, ds);

      ConnectionPoolDataSource boundDs = null;
View Full Code Here


    this.tempDir = File.createTempFile("jnditest", null);
    this.tempDir.delete();
    this.tempDir.mkdir();
    this.tempDir.deleteOnExit();

    MysqlConnectionPoolDataSource ds;
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
        "com.sun.jndi.fscontext.RefFSContextFactory");
    this.ctx = new InitialContext(env);
    assertTrue("Naming Context not created", this.ctx != null);
    ds = new MysqlConnectionPoolDataSource();
    ds.setUrl(dbUrl); // from BaseTestCase
    ds.setDatabaseName("test");
    this.ctx.bind(this.tempDir.getAbsolutePath() + "/test", ds);
  }
View Full Code Here

    return boundDs;
  }

  public void testCSC4616() throws Exception {
    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
    ds.setURL(BaseTestCase.dbUrl);
    PooledConnection pooledConn = ds.getPooledConnection();
    Connection physConn = pooledConn.getConnection();
    Statement physStatement = physConn.createStatement();

    Method enableStreamingResultsMethodStmt = Class.forName(
        "com.mysql.jdbc.jdbc2.optional.StatementWrapper").getMethod(
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

  public static final int MYSQL_PORT = 3306;

  @Bean
  @Override
  public DataSource dataSource() {
    MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
    ds.setUser("root");
    ds.setPassword(System.getProperty("mysql.password", ""));
    ds.setDatabaseName("spring_data_jdbc_repository_test");
    return ds;
  }
View Full Code Here

    }

    String newUrl = String.format("jdbc:mysql:loadbalance://%s,%s/%s?%s",
        hostSpec, hostSpec, database, configs.toString());

    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

    }

    String newUrl = String.format("jdbc:mysql:loadbalance://%s,%s/%s?%s",
        hostSpec, hostSpec, database, configs.toString());

    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

   */
  public void testBug58728() throws Exception {
    createTable("testbug58728", "(Id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, txt VARCHAR(50))","InnoDB");
    this.stmt.executeUpdate("INSERT INTO testbug58728 VALUES (NULL, 'Text 1'), (NULL, 'Text 2')");
   
    MysqlConnectionPoolDataSource pds = new MysqlConnectionPoolDataSource();
    pds.setUrl(dbUrl);
    Statement stmt1 = pds.getPooledConnection().getConnection().createStatement();
    stmt1.executeUpdate("UPDATE testbug58728 SET txt = 'New text' WHERE Id > 0");
    ResultSet rs1 = stmt1.getResultSet();
    stmt1.close();
    if (rs1 != null) {
      rs1.close();
View Full Code Here

    }

    private synchronized void connect() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        ConsoleLogger.info("MySQL driver loaded");
        MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
        dataSource.setDatabaseName(database);
        dataSource.setServerName(host);
        dataSource.setPort(Integer.parseInt(port));
        dataSource.setUser(username);
        dataSource.setPassword(password);

        conPool = new MiniConnectionPoolManager(dataSource, 10);
        ConsoleLogger.info("Connection pool ready");
    }
View Full Code Here

TOP

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

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.