Package java.sql

Examples of java.sql.Driver


     * use this method to shutdown databases in an effort to release
     * any locks they may be holding
     */
    private static void shutdownDB(String url, Properties info) throws SQLException {
       
        Driver driver = DriverManager.getDriver(url);
        try {
            driver.connect(url, info);
        } catch (SQLException se) {
            assertSQLState("08006", se);
        }
    }
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

            String driverName =
                "org.apache.derby.jdbc.EmbeddedDriver";

            Class.forName(driverName).newInstance();

            Driver embedDriver =
                DriverManager.getDriver(Attribute.PROTOCOL);

            String conStr = "jdbc:derby:"+dbname+";"+
                Attribute.REPLICATION_INTERNAL_SHUTDOWN_SLAVE+
                "=true";

            embedDriver.connect(conStr, (Properties) null);
        } catch (Exception e) {
            // Todo: report error to derby.log if exception is not
            // SQLState.SHUTDOWN_DATABASE
        }
    }
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

    if( !acceptsURL(url) ) {
      return null;
    }

    // find the real driver for the URL
    Driver passThru = findPassthru(url);

    P6LogQuery.debug("this is " + this + " and passthru is " + passThru);

    Connection conn = passThru.connect(extractRealUrl(url), properties);

    if (conn != null) {
      conn = P6Core.wrapConnection(conn);
    }
    return conn;
View Full Code Here

    return conn;
  }

  protected Driver findPassthru(String url) throws SQLException {
    String realUrl = extractRealUrl(url);
    Driver passthru = null;
    for (Driver driver: registeredDrivers() ) {
      try {
        if (driver.acceptsURL(extractRealUrl(url))) {
          passthru = driver;
          break;
View Full Code Here

    final String user = "sa";
    final String passwd = "";

    try {
      Class c = Class.forName(driver);
      Driver d = (Driver) c.newInstance();
      DriverManager.registerDriver(d);
      conn = DriverManager.getConnection(url, user, passwd);
      System.out.println(conn);
      // stmt = conn.createStatement();
      // r =
View Full Code Here

   
    for (ClassLoader loader : loaders) {
      try {
        driverClass = loader.loadClass(className.getValue());
        if (driverClass != null) {
          Driver driver = (Driver)driverClass.newInstance();
          DriverManager.registerDriver(new DriverShim(driver));
        }
      } catch (ClassNotFoundException e) {
        ex = e;
        continue;
View Full Code Here

                    // Try the driver
                    String driver = p.getProperty("db.driver");
                   
                    try {
                       Driver d = (Driver) Class.forName(driver, true, Play.classloader).newInstance();
                        DriverManager.registerDriver(new ProxyDriver(d));
                    } catch (Exception e) {
                        throw new Exception("Driver not found (" + driver + ")");
                    }
View Full Code Here

        };
      } else {
        return new ConnectionFactory() {
          @Override
          public Connection createConnection() throws SQLException {
            Driver driver;

            try {
              driver = (Driver) P6Util.forName(getDriverClassName()).newInstance();
            } catch (Exception e) {
              throw new RuntimeException(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.