Package java.sql

Examples of java.sql.Driver


        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


     

  public static void main(String[] args) {
   
    try {
      Driver driver = loadAndCheckDriverForFramework();     
      checkAcceptsURL(driver);
      testEmbeddedAttributes(driver);
      testClientAttributes(driver);
      doClientURLTest(driver);
      testDbNameWithSpaces(driver);
View Full Code Here

 
    TestUtil.loadDriver();
    String frameworkURL = TestUtil.getJdbcUrlPrefix() + "testpropdb;create=true";
   
    // Test that we loaded the right driver by making a connection
    Driver driver = DriverManager.getDriver(frameworkURL);
    Properties props = new Properties();
    props.put("user","testuser");
    props.put("password","testpass");
    Connection conn = DriverManager.getConnection(frameworkURL, props);
    DatabaseMetaData dbmd = conn.getMetaData();
    System.out.println("jdbcCompliant() = " +  driver.jdbcCompliant());
   
    // Just check versions against database metadata to avoid more master updates.
    // Metadata test prints the actual version.
   
    int majorVersion = driver.getMajorVersion();
    if (majorVersion == dbmd.getDriverMajorVersion())
      System.out.println("driver.getMajorVersion() = EXPECTED VERSION");
    else
      new Exception("FAILED: unexpected value for  getMajorVersion(): " +
            majorVersion).printStackTrace();
   
    int  minorVersion = driver.getMinorVersion();
    if (minorVersion == dbmd.getDriverMinorVersion())
      System.out.println("driver.getMinorVersion() = EXPECTED VERSION");
    else
      new Exception("FAILED: unexpected value for getMinorVersion()" +
          minorVersion).printStackTrace(System.out);
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

    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

  private static void deregisterAllJdbcDrivers() {
    // This manually deregisters all JDBC drivers
    Enumeration<Driver> drivers = DriverManager.getDrivers();
    while (drivers.hasMoreElements()) {
      Driver driver = drivers.nextElement();
      try {
        logger.info("Deregistering jdbc driver: "+driver);
        DriverManager.deregisterDriver(driver);
      } catch (SQLException e) {
        logger.error("Error deregistering driver "+driver, e);
View Full Code Here

            final List<String> driverNames = servicesAttachment.getServiceImplementations(Driver.class.getName());
            for (String driverClassName : driverNames) {
                try {
                    final Class<? extends Driver> driverClass = classLoader.loadClass(driverClassName).asSubclass(Driver.class);
                    final Constructor<? extends Driver> constructor = driverClass.getConstructor();
                    final Driver driver = constructor.newInstance();
                    final int majorVersion = driver.getMajorVersion();
                    final int minorVersion = driver.getMinorVersion();
                    final boolean compliant = driver.jdbcCompliant();
                    if (compliant) {
                        log.infof("Deploying JDBC-compliant driver %s (version %d.%d)", driverClass,
                                Integer.valueOf(majorVersion), Integer.valueOf(minorVersion));
                    } else {
                        log.infof("Deploying non-JDBC-compliant driver %s (version %d.%d)", driverClass,
View Full Code Here

        } else {
            try {
                final Class<? extends Driver> driverClass = module.getClassLoader().loadClass(driverClassName)
                        .asSubclass(Driver.class);
                final Constructor<? extends Driver> constructor = driverClass.getConstructor();
                final Driver driver = constructor.newInstance();
                startDriverServices(target, moduleId, driver, driverName, majorVersion, minorVersion, xaDataSourceClassName);
            } catch (Exception e) {
                log.warnf("Unable to instantiate driver class \"%s\": %s", driverClassName, e);
            }
        }
View Full Code Here

        } else {
            try {
                final Class<? extends Driver> driverClass = module.getClassLoader().loadClass(driverClassName)
                        .asSubclass(Driver.class);
                final Constructor<? extends Driver> constructor = driverClass.getConstructor();
                final Driver driver = constructor.newInstance();
                startDriverServices(target, moduleId, driver, driverName, majorVersion, minorVersion, dataSourceClassName, xaDataSourceClassName);
            } catch (Exception e) {
                SUBSYSTEM_DATASOURCES_LOGGER.cannotInstantiateDriverClass(driverClassName, e);
                throw new OperationFailedException(new ModelNode().set(MESSAGES.cannotInstantiateDriverClass(driverClassName)));
            }
View Full Code Here

            final List<String> driverNames = servicesAttachment.getServiceImplementations(Driver.class.getName());
            for (String driverClassName : driverNames) {
                try {
                    final Class<? extends Driver> driverClass = classLoader.loadClass(driverClassName).asSubclass(Driver.class);
                    final Constructor<? extends Driver> constructor = driverClass.getConstructor();
                    final Driver driver = constructor.newInstance();
                    final int majorVersion = driver.getMajorVersion();
                    final int minorVersion = driver.getMinorVersion();
                    final boolean compliant = driver.jdbcCompliant();
                    if (compliant) {
                        DEPLOYER_JDBC_LOGGER.deployingCompliantJdbcDriver(driverClass, Integer.valueOf(majorVersion),
                                Integer.valueOf(minorVersion));
                    } else {
                        DEPLOYER_JDBC_LOGGER.deployingNonCompliantJdbcDriver(driverClass, Integer.valueOf(majorVersion),
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.