Package java.sql

Examples of java.sql.Driver.connect()


               if (userPassword.hasValue())
                  properties.setProperty("password", userPassword.getValue());
               try
               {
                  Driver driver = (Driver) driverClass.getValue().newInstance();
                  try (Connection connection = driver.connect(jdbcUrl.getValue(), properties))
                  {
                     context.addValidationInformation(verifyConnection, "Connection successful.");
                  }
                  finally
                  {
View Full Code Here


            String url = clientCreateUrls[i];
            try{
                if (url.equals(CLIENT_CREATE_URL_WITH_COLON1))
                {
                    Driver driver = DriverManager.getDriver(url);
                    assertNull(driver.connect(url,info));
                }
                else
                    assertConnect(true, url, info);
            }
            catch(SQLException se){
View Full Code Here

        boolean expectUrlEqualsGetUrl, String url, Properties info)
    throws SQLException
    {
        Driver driver = DriverManager.getDriver(url);

        Connection conn = driver.connect(url, info);
        assertNotNull(conn);
  
        if (expectUrlEqualsGetUrl)
            assertEquals(url, conn.getMetaData().getURL());
        else
View Full Code Here

     */
    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

            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

        DriverManager.registerDriver( driver );
      }
      Properties info = new Properties();
      info.put( "user", userName == null ? "" : userName ); //$NON-NLS-1$
      info.put( "password", password == null ? "" : password ); //$NON-NLS-1$
      nativeConnection = captureConnection( driver.connect( location, info ) );
      if ( nativeConnection == null ) {
        logger.error( Messages.getInstance().getErrorString(
          "ConnectFactory.ERROR_0001_INVALID_CONNECTION2", driverName, location ) ); //$NON-NLS-1$
      } else {
        enhanceConnection( nativeConnection );
View Full Code Here

        // Create the data source and initialize the database tables
        final Driver hsqlDriver = (Driver) Class.forName("org.hsqldb.jdbcDriver").newInstance();
        final Properties info = new Properties();
        info.setProperty("shutdown", "false");
        final Connection conn = hsqlDriver.connect("jdbc:hsqldb:mem:sqltest", info);
//        Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:sqltest");
        conn.createStatement().execute("CREATE TABLE users (username VARCHAR(255), password VARCHAR(255))");
        conn.createStatement().execute("CREATE TABLE groups (grp VARCHAR(255), username VARCHAR(255))");

        // Add users
View Full Code Here

    String url2 = "jdbc:alternate:morestuff";
    Mockito.when( mockDriver.connect( url, new Properties() ) ).thenReturn( mockConn );
    Mockito.when( mockDriver.acceptsURL( url ) ).thenReturn( true );
    Mockito.when( mockDriver.connect( url2, new Properties() ) ).thenReturn( null );
    Mockito.when( mockDriver.acceptsURL( url2 ) ).thenReturn( false );
    Mockito.when( mockDriver2.connect( url, new Properties() ) ).thenReturn( null );
    Mockito.when( mockDriver2.acceptsURL( url ) ).thenReturn( false );
    Mockito.when( mockDriver2.connect( url2, new Properties() ) ).thenReturn( mockConn2 );
    Mockito.when( mockDriver2.acceptsURL( url2 ) ).thenReturn( true );
    Connection conn = DriverManager.getConnection( url );
    Assert.assertSame( mockConn, conn );
View Full Code Here

    Mockito.when( mockDriver.acceptsURL( url ) ).thenReturn( true );
    Mockito.when( mockDriver.connect( url2, new Properties() ) ).thenReturn( null );
    Mockito.when( mockDriver.acceptsURL( url2 ) ).thenReturn( false );
    Mockito.when( mockDriver2.connect( url, new Properties() ) ).thenReturn( null );
    Mockito.when( mockDriver2.acceptsURL( url ) ).thenReturn( false );
    Mockito.when( mockDriver2.connect( url2, new Properties() ) ).thenReturn( mockConn2 );
    Mockito.when( mockDriver2.acceptsURL( url2 ) ).thenReturn( true );
    Connection conn = DriverManager.getConnection( url );
    Assert.assertSame( mockConn, conn );
    Connection conn2 = DriverManager.getConnection( url2 );
    Assert.assertSame( mockConn2, conn2 );
View Full Code Here

      }
    };
    DriverManager.registerDriver( driver );
    String url = "jdbc:driver4:morestuff";
    String url2 = "jdbc:driver1:morestuff";
    Mockito.when( mockDriver.connect( url2, new Properties() ) ).thenReturn( mockConn );
    Mockito.when( mockDriver.acceptsURL( url2 ) ).thenReturn( true );
    Connection conn = DriverManager.getConnection( url );
    Assert.assertSame( mockConn, conn );
    DriverManager.deregisterDriver( driver );
  }
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.