Package com.mysql.jdbc

Examples of com.mysql.jdbc.NonRegisteringDriver


public class GeminiReplicationConnection extends ReplicationConnection {

  private static final Logger LOGGER = LoggerFactory.getLogger(GeminiReplicationConnection.class);

  public GeminiReplicationConnection(Properties masterProperties, Properties slaveProperties) throws SQLException {
    NonRegisteringDriver driver = new NonRegisteringDriver();

    StringBuilder masterUrl = new StringBuilder("jdbc:mysql://");
    StringBuilder slaveUrl = new StringBuilder("jdbc:mysql://");

    String masterHost = masterProperties.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
    if (masterHost != null) {
      masterUrl.append(masterHost);
    }

    String slaveHost = slaveProperties.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
    if (slaveHost != null) {
      slaveUrl.append(slaveHost);
    }

    String masterDb = masterProperties.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
    masterUrl.append("/");
    if (masterDb != null) {
      masterUrl.append(masterDb);
    }

    String slaveDb = slaveProperties.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
    slaveUrl.append("/");
    if (slaveDb != null) {
      slaveUrl.append(slaveDb);
    }

    slaveProperties.setProperty("roundRobinLoadBalance", "true");

    this.masterConnection = (LoadBalancedMySQLConnection) driver.connect(masterUrl.toString(), masterProperties);

    if (StringUtils.isBlank(slaveHost) && slaveUrl.toString().contains("///")) {
      info(" ----- the salveUrl contains the '///', that means there is no slaver, make slavesConnection = masterConnection --");
      slavesConnection = masterConnection;
    } else {
      this.slavesConnection = (LoadBalancedMySQLConnection) driver.connect(slaveUrl.toString(), slaveProperties);
      this.slavesConnection.setReadOnly(true);
    }

    this.currentConnection = this.masterConnection;
  }
View Full Code Here


   * @throws Exception
   *             if an error ocurrs.
   */
  public void testBug3554() throws Exception {
    try {
      new NonRegisteringDriver().connect(
          "jdbc:mysql://localhost:3306/?user=root&password=root",
          new Properties());
    } catch (SQLException sqlEx) {
      assertTrue(sqlEx.getMessage().indexOf("Malformed") == -1);
    }
View Full Code Here

      try {
        adminConnection = getAdminConnection();

        int bogusPortNumber = 65534;

        NonRegisteringDriver driver = new NonRegisteringDriver();

        Properties oldProps = driver.parseURL(BaseTestCase.dbUrl, null);

        String host = driver.host(oldProps);
        int port = driver.port(oldProps);
        String database = oldProps
            .getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
        String user = oldProps
            .getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
        String password = oldProps
View Full Code Here

  public void testBug6966() throws Exception {
    Properties props = new Driver().parseURL(BaseTestCase.dbUrl, null);
    props.setProperty("autoReconnect", "true");
    props.setProperty("socketFactory", "testsuite.UnreliableSocketFactory");

    Properties urlProps = new NonRegisteringDriver().parseURL(dbUrl,
        null);

    String host = urlProps.getProperty(Driver.HOST_PROPERTY_KEY);
    String port = urlProps.getProperty(Driver.PORT_PROPERTY_KEY);
View Full Code Here

   * @throws Exception
   */
  public void testBug23626() throws Exception {
    Class<?> clazz = this.conn.getClass();

    DriverPropertyInfo[] dpi = new NonRegisteringDriver().getPropertyInfo(
        dbUrl, null);
    StringBuffer missingSettersBuf = new StringBuffer();
    StringBuffer missingGettersBuf = new StringBuffer();

    Class<?>[][] argTypes = { new Class[] { String.class },
View Full Code Here

    Connection _conn = null;

    try {
     
      Properties props = new NonRegisteringDriver().parseURL(dbUrl, null);
      String host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY, "localhost");
      String port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY,  "3306");
      String db = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY,  "test");

      String hostSpec = host;
View Full Code Here

      }
    }
  }

  public void testPropertiesDescriptionsKeys() throws Exception {
    DriverPropertyInfo[] dpi = new NonRegisteringDriver().getPropertyInfo(
        dbUrl, null);

    for (int i = 0; i < dpi.length; i++) {
      String description = dpi[i].description;
      String propertyName = dpi[i].name;
View Full Code Here

    }
    return true;
  }

  public void testBug46637() throws Exception {
    NonRegisteringDriver driver = new NonRegisteringDriver();
    Properties props = new Properties();
    copyBasePropertiesIntoProps(props, driver);
    String hostname = getPortFreeHostname(props, driver);
    UnreliableSocketFactory.flushAllHostLists();
    UnreliableSocketFactory.downHost(hostname);
View Full Code Here

    checkBug32216("www.mysql.com", null, "my_database");
  }

  private void checkBug32216(String host, String port, String dbname)
      throws SQLException {
    NonRegisteringDriver driver = new NonRegisteringDriver();

    StringBuffer url = new StringBuffer("jdbc:mysql://");
    url.append(host);

    if (port != null) {
      url.append(':');
      url.append(port);
    }

    url.append('/');
    url.append(dbname);

    Properties result = driver.parseURL(url.toString(), new Properties());

    assertEquals("hostname not equal", host,
        result.getProperty(Driver.HOST_PROPERTY_KEY));
    if (port != null) {
      assertEquals("port not equal", port,
View Full Code Here

  }

  public void testBug48486() throws Exception {

    Properties props = new NonRegisteringDriver().parseURL(dbUrl, null);
    String host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY,
        "localhost");
    String port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY,
        "3306");
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.NonRegisteringDriver

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.