Package java.sql

Examples of java.sql.Driver


            updateAutoCommitBox();

            // Workaround for EXTREME SLOWNESS getting this info from O.
            showIndexDetails = !isOracle;

            Driver driver = DriverManager.getDriver(dMeta.getURL());
            ConnectionSetting newSetting = new ConnectionSetting(
                dMeta.getDatabaseProductName(), driver.getClass().getName(),
                dMeta.getURL(),
                dMeta.getUserName().replaceAll("@localhost", ""), "");
            Hashtable settings =
                ConnectionDialogCommon.loadRecentConnectionSettings();
View Full Code Here


        planView.include(renderRequest, renderResponse);
    }

    private static String attemptConnect(PortletRequest request, PoolData data) throws SQLException, IllegalAccessException, InstantiationException {
        Class driverClass = attemptDriverLoad(request, data);
        Driver driver = (Driver) driverClass.newInstance();
        if (driver.acceptsURL(data.url)) {
            Properties props = new Properties();
            if (data.user != null) {
                props.put("user", data.user);
            }
            if (data.password != null) {
                props.put("password", data.password);
            }
            Connection con = null;
            try {
                con = driver.connect(data.url, props);
                final DatabaseMetaData metaData = con.getMetaData();
                return metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion();
            } finally {
                if (con != null) {
                    try {
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(getProject(), 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", getLocation());
        }
        catch (IllegalAccessException e)
        {
            throw new BuildException("Illegal Access: JDBC driver " + driver
                    + " could not be loaded", getLocation());
        }
        catch (InstantiationException e)
        {
            throw new BuildException("Instantiation Exception: JDBC driver "
                    + driver + " could not be loaded", getLocation());
        }

        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

    private Driver getDriver() throws BuildException {
        if (driver == null) {
            throw new BuildException("Driver attribute must be set!", getLocation());
        }

        Driver driverInstance = null;
        try {
            Class dc;
            if (classpath != null) {
                // check first that it is not already loaded otherwise
                // consecutive runs seems to end into an OutOfMemoryError
View Full Code Here

      {
        whenExhaustedActionType = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
      }

      final PoolingDataSource poolingDataSource = new PoolingDataSource();
      final Driver driver = ObjectUtilities.loadAndInstantiate(driverClass, PooledDatasourceHelper.class, Driver.class);

      // As the name says, this is a generic pool; it returns  basic Object-class objects.
      final GenericObjectPool pool = new GenericObjectPool(null);
      pool.setWhenExhaustedAction(whenExhaustedActionType);
View Full Code Here

    if (url == null)
    {
      throw new NullPointerException("URL must not be null when connecting"); //$NON-NLS-1$
    }

    Driver driverImpl = null;
    try
    {
      if (driver != null)
      {
        driverImpl = ObjectUtilities.loadAndInstantiate(driver, getClass(), Driver.class);
        if (driverImpl == null)
        {
          logger.warn ("Unable to load specified driver class: " + driver + ". See ObjectUtilities logger for error details.");
        }
      }
    }
    catch (Throwable e)
    {
      throw new SQLException("Unable to load the driver: " + driver, e.getMessage()); //$NON-NLS-1$
    }

    final Properties p = new Properties();
    for (final Map.Entry entry : properties.entrySet())
    {
      final String entryKey = (String) entry.getKey();
      if (isFilteredKey(entryKey))
      {
        continue;
      }
      p.setProperty(entryKey, (String) entry.getValue());
    }
    if (user != null)
    {
      p.setProperty("user", user);
    }
    if (password != null)
    {
      p.setProperty("password", password);
    }
   
    final Connection connection;
    if (driverImpl != null)
    {
      connection = driverImpl.connect(url, p);
    }
    else
    {
      connection = DriverManager.getConnection(url, p);
    }
View Full Code Here

      attributeRegistry.putAttributeDescription(metaData);
    }

    try
    {
      Driver driver = ObjectUtilities.loadAndInstantiate
          ("org.hsqldb.jdbcDriver", TestSetupModule.class, Driver.class);
      populateDatabase(driver);
    }
    catch (Exception e)
    {
View Full Code Here

    }

    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        Enumeration<Driver> drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = drivers.nextElement();
            try {
                DriverManager.deregisterDriver(driver);
                LOGGER.debug("deregistering jdbc driver:" + driver);
            } catch (SQLException e) {
                LOGGER.error(e);
View Full Code Here

    private Driver getDriver() throws BuildException {
        if (driver == null) {
            throw new BuildException("Driver attribute must be set!", location);
        }

        Driver driverInstance = null;
        try {
            Class dc;
            if (classpath != null) {
                // check first that it is not already loaded otherwise
                // consecutive runs seems to end into an OutOfMemoryError
View Full Code Here

         * side-effects are all de-registered.
         */
        Enumeration<Driver> drivers = DriverManager.getDrivers();
        drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = drivers.nextElement();
            Bundle driverBundle = BundleUtils.getBundle(driver.getClass().getClassLoader(), true);
            if (driverBundle != bundle) {
                continue;
            }
            try {
                DriverManager.deregisterDriver(driver);
            } catch (Exception e) {
                logger.warn("Fail to unregister the driver " + driver.getClass().getName(), e);
            }
        }
    }
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.