Package java.sql

Examples of java.sql.Driver


    super(db);
  }

  @Test
  public void testVersion() throws Exception {
    Driver driver = new P6SpyDriver();
    assertEquals(2, driver.getMajorVersion());
    assertEquals(0, driver.getMinorVersion());
  }
View Full Code Here


      for (String driverName : driverNames) {
        P6Util.forName(driverName);
      }
    }

    Driver driver = DriverManager.getDriver(url);
    if (log.isDebugEnabled()) {
      log.debug("FRAMEWORK USING DRIVER == " + driver.getClass().getName() + " FOR URL " + url);
    }
    connection = DriverManager.getConnection(url, user, password);

    P6TestUtil.printAllDrivers();
    P6TestUtil.setupTestData(url, user, password);
View Full Code Here

    String url2 = P6TestOptions.getActiveInstance().getUrl2();
    String user2 = P6TestOptions.getActiveInstance().getUser2();
    String password2 = P6TestOptions.getActiveInstance().getPassword2();

    P6TestUtil.printAllDrivers();
    Driver driver = DriverManager.getDriver(url2);
    System.err.println("FRAMEWORK USING DRIVER == " + driver.getClass().getName() + " FOR URL " + url2);
    Connection connection2 = DriverManager.getConnection(url2, user2, password2);

    // setup database for testing
    P6TestUtil.setupTestData(url2, user2, password2);
View Full Code Here

    protected void clearReferences() {

        // Unregister any JDBC drivers loaded by this classloader
        Enumeration drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = (Driver) drivers.nextElement();
            if (driver.getClass().getClassLoader() == this) {
                try {
                    DriverManager.deregisterDriver(driver);
                } catch (SQLException e) {
                    log.warn("SQL driver deregistration failed", e);
                }
View Full Code Here

        // and therefore no need to create a connection
        if (isEmpty(true)) {
            return;
        }

        Driver driver = (Driver) Class.forName(dsi.getJdbcDriver()).newInstance();
        DataSource dataSource = new DriverDataSource(driver, dsi.getDataSourceUrl(), dsi
                .getUserName(), dsi.getPassword());

        runGenerator(dataSource);
    }
View Full Code Here

        try {
            return DriverManager.getConnection(url, properties);
        } catch (Exception e) {
            // if the current class loader can not access the driver class, create driver class directly
            try {
                Driver driverObject = driverClass.getConstructor().newInstance();
                Connection connection = driverObject.connect(url, properties);
                if (connection == null) {
                    throw new IllegalStateException(MessageFormat.format(
                            "Driver class {0} may not support {1}",
                            driverClass.getName(),
                            url));
View Full Code Here

        return connect(databaseSettings, detailSettings.getProperties(), detailSettings.isAutoCommit(), connectionStatus);
    }

    public static Connection connect(ConnectionDatabaseSettings databaseSettings, @Nullable Map<String, String> connectionProperties, boolean autoCommit, @Nullable ConnectionStatus connectionStatus) throws SQLException {
        try {
            Driver driver = DatabaseDriverManager.getInstance().getDriver(
                    databaseSettings.getDriverLibrary(),
                    databaseSettings.getDriver());

            Properties properties = new Properties();
            if (!databaseSettings.isOsAuthentication()) {
                properties.put("user", databaseSettings.getUser());
                properties.put("password", databaseSettings.getPassword());
            }
            if (connectionProperties != null) {
                properties.putAll(connectionProperties);
            }

            Connection connection = driver.connect(databaseSettings.getDatabaseUrl(), properties);
            if (connection == null) {
                throw new SQLException("Driver refused to create connection for this configuration. No failure information provided.");
            }
            connection.setAutoCommit(autoCommit);
            if (connectionStatus != null) {
View Full Code Here

                        try {
                            if (className.contains("Driver")) {
                                Class<?> clazz = classLoader.loadClass(className);
                                if (Driver.class.isAssignableFrom(clazz)) {
                                    Driver driver = (Driver) clazz.newInstance();
                                    drivers.add(driver);
                                }
                            }
                        }
                        catch(Throwable throwable) {
View Full Code Here

    try {
      AdapterFactory.getAdapter().getConnection().close();
     
          Enumeration<Driver> drivers = DriverManager.getDrivers();
          while (drivers.hasMoreElements()) {
              Driver driver = drivers.nextElement();
              try {
                  DriverManager.deregisterDriver(driver);
              } catch (Exception ex) {
                LogUtils.log(Level.WARNING, ex.toString());
              }
View Full Code Here

            List transactions)
    {
        url = StringUtils.replace(url, "@DB@", database);
        System.out.println("Our new url -> " + url);

        Driver driverInstance = null;
        try
        {
            Class dc;
            if (classpath != null)
            {
                log("Loading " + driver
                        + " using AntClassLoader with classpath " + classpath,
                        Project.MSG_VERBOSE);

                loader = new AntClassLoader(project, classpath);
                dc = loader.loadClass(driver);
            }
            else
            {
                log("Loading " + driver + " using system loader.",
                        Project.MSG_VERBOSE);
                dc = Class.forName(driver);
            }
            driverInstance = (Driver) dc.newInstance();
        }
        catch (ClassNotFoundException e)
        {
            throw new BuildException("Class Not Found: JDBC driver " + driver
                    + " could not be loaded", location);
        }
        catch (IllegalAccessException e)
        {
            throw new BuildException("Illegal Access: JDBC driver " + driver
                    + " could not be loaded", location);
        }
        catch (InstantiationException e)
        {
            throw new BuildException("Instantiation Exception: JDBC driver "
                    + driver + " could not be loaded", location);
        }

        try
        {
            log("connecting to " + url, Project.MSG_VERBOSE);
            Properties info = new Properties();
            info.put("user", userId);
            info.put("password", password);
            conn = driverInstance.connect(url, info);

            if (conn == null)
            {
                // Driver doesn't understand the URL
                throw new SQLException("No suitable Driver for " + url);
View Full Code Here

TOP

Related Classes of java.sql.Driver

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.