Package java.sql

Examples of java.sql.Driver.acceptsURL()


    Class cl = Class.forName(line, false, loader);

    Driver driver = (Driver) cl.newInstance();

    System.out.println("NOM: " + driver.acceptsURL(url) + " " + url + " " + driver);
    if (driver.acceptsURL(url))
      return cl.getName();
  } catch (Exception e) {
    log.log(Level.WARNING, e.toString(), e);
  }
      }
View Full Code Here


                } else {
                    // Usage of DriverManager is not possible, as it does not
                    // respect the ContextClassLoader
                    // N.B. This cast may cause ClassCastException which is handled below
                    driverToUse = (Driver) driverFromCCL.newInstance();
                    if (!driverToUse.acceptsURL(url)) {
                        throw new SQLException("No suitable driver", "08001");
                    }
                }
            } catch (Exception t) {
                String message = "Cannot create JDBC driver of class '" +
View Full Code Here

  @Test
  public void testGetConnection() throws Exception {
    Connection conn = createMock(Connection.class);
    Driver driver = createMock(Driver.class);
    String url = "jdbc:bar:mem:baz";
    expect(driver.acceptsURL(url)).andReturn(true);
    expect(driver.connect(isA(String.class), isA(Properties.class))).andReturn(conn);
    replay(driver);
    DriverManager.registerDriver(driver);
    try {
      JdbcConnectionSource sds = new JdbcConnectionSource(url, databaseType);
View Full Code Here

  @Test(expected = SQLException.class)
  public void testGetConnectionNull() throws Exception {
    Driver driver = createMock(Driver.class);
    Properties props = new Properties();
    String url = "jdbc:bar:baz";
    expect(driver.acceptsURL(url)).andReturn(true);
    expect(driver.connect(eq(url), eq(props))).andReturn(null);
    replay(driver);
    DriverManager.registerDriver(driver);
    try {
      JdbcConnectionSource sds = new JdbcConnectionSource(url, databaseType);
View Full Code Here

    Connection conn = createMock(Connection.class);
    conn.setAutoCommit(true);
    conn.close();
    Driver driver = createMock(Driver.class);
    String url = "jdbc:bar:baz";
    expect(driver.acceptsURL(url)).andReturn(true);
    expect(driver.connect(isA(String.class), isA(Properties.class))).andReturn(conn);
    replay(driver, conn);
    DriverManager.registerDriver(driver);
    try {
      JdbcConnectionSource sds = new JdbcConnectionSource(url, databaseType);
View Full Code Here

    Connection conn = createMock(Connection.class);
    conn.setAutoCommit(true);
    expect(conn.isClosed()).andReturn(true);
    Driver driver = createMock(Driver.class);
    String url = "jdbc:bar:baz";
    expect(driver.acceptsURL(url)).andReturn(true);
    expect(driver.connect(isA(String.class), isA(Properties.class))).andReturn(conn);
    replay(driver, conn);
    DriverManager.registerDriver(driver);
    try {
      JdbcConnectionSource sds = new JdbcConnectionSource(url, databaseType);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.