Package org.apache.derby.jdbc

Examples of org.apache.derby.jdbc.ClientDataSourceInterface


     */
    public void testClientDSConnectionAttributes() throws Exception {
        if (usingEmbedded())
            return;
       
        ClientDataSourceInterface ds = null;

        if (JDBC.vmSupportsJNDI()) {
            // Use reflection to avoid class not found in non-JNDI context
            ds = (ClientDataSourceInterface)Class.forName(
                    "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
                    "org.apache.derby.jdbc.BasicClientDataSource40").
                    newInstance();
        }

        ds.setPortNumber(TestConfiguration.getCurrent().getPort());
       
        // DataSource - EMPTY; expect error 08001 in all cases
        // 08001: Required Derby DataSource property databaseName not set.
        dsConnectionRequests(new String[] 
            {"08001","08001","08001","08001",
             "08001","08001","08001","08001","08001"}, ds);

        // DataSource - connectionAttributes=databaseName=<valid name>
        ds.setConnectionAttributes("databaseName=" + dbName);
        dsConnectionRequests(new String[] 
            {"08001","08001","08001","08001",
             "08001","08001","08001","08001","08001"}, ds);
        ds.setConnectionAttributes(null);

        // Test that (invalid) database name specified in connection
        // attributes is not used
        // DataSource - databaseName=<valid db> and
        // connectionAttributes=databaseName=kangaroo
        ds.setConnectionAttributes("databaseName=kangaroo");
        ds.setDatabaseName(dbName);
        dsConnectionRequests(new String[] 
            {"OK","08001","OK","OK",
             "08001","08001","OK","OK","OK"}, ds);
        ds.setConnectionAttributes(null);
        ds.setDatabaseName(null);

    } // End testClientDSConnectionAttributes
View Full Code Here


        String retrieveMessageTextProperty = "retrieveMessageText";
        Connection conn;

        // DataSource
        // DataSource - retrieveMessageTextProperty
        ClientDataSourceInterface ds = null;

        if (JDBC.vmSupportsJNDI()) {
            // Use reflection to avoid class not found in non-JNDI context
            ds = (ClientDataSourceInterface)Class.forName(
              "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
              "org.apache.derby.jdbc.BasicClientDataSource40").newInstance();
        }

        ds.setPortNumber(TestConfiguration.getCurrent().getPort());
        ds.setDatabaseName(dbName);
        ds.setConnectionAttributes(retrieveMessageTextProperty + "=false");
        conn = ds.getConnection();
        assertMessageText(conn,"false");
        conn.close();
        // now try with retrieveMessageText = true
        ds.setConnectionAttributes(retrieveMessageTextProperty + "=true");
        conn = ds.getConnection();
        assertMessageText(conn,"true");
        ds.setConnectionAttributes(null);
        conn.close();
    }
View Full Code Here

       
    private Connection _getConnection(String databasePath, String dbSubPath,
            String dbName, String serverHost, int serverPort)
        throws Exception
    {
        ClientDataSourceInterface ds;

        if (JDBC.vmSupportsJNDI()) {
            ds = (ClientDataSourceInterface)Class.forName(
               "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
               "org.apache.derby.jdbc.BasicClientDataSource40").newInstance();
        }

        ds.setDatabaseName(databasePath +FS+ dbSubPath +FS+ dbName);
        ds.setServerName(serverHost);
        ds.setPortNumber(serverPort);
        ds.setConnectionAttributes(useEncryption(false));
        return ds.getConnection();
    }
View Full Code Here

    SQLException _connectToSlave(String slaveServerHost, int slaveServerPort,
            String dbPath)
        throws Exception
    {
        util.DEBUG("_connectToSlave");
        ClientDataSourceInterface ds;

        if (JDBC.vmSupportsJNDI()) {
            ds = (ClientDataSourceInterface)Class.forName(
               "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
               "org.apache.derby.jdbc.BasicClientDataSource40").newInstance();
        }

        ds.setDatabaseName(dbPath);
        ds.setServerName(slaveServerHost);
        ds.setPortNumber(slaveServerPort);
        ds.setConnectionAttributes(useEncryption(false));
        try {
            Connection conn = ds.getConnection();
            conn.close();
            return null; // If successfull.
        } catch (SQLException se) {
            return se;
        }      
View Full Code Here

        String sState = "CONNECTED";
        String msg = null;
        Thread.sleep(waitTime); // .... until stable...
        try
        {
            ClientDataSourceInterface ds = configureDataSource(
                    fullDbPath,
                    serverHost,
                    serverPort,
                    useEncryption(false) );
            Connection conn = ds.getConnection();
            conn.close();
        }
        catch ( SQLException se )
        {
            errCode = se.getErrorCode();
View Full Code Here

        String msg = null;
        while (true)
        {
            try
            {
                ClientDataSourceInterface ds = configureDataSource(
                    fullDbPath, serverHost, serverPort, useEncryption(false) );
                Connection conn = ds.getConnection();
                util.DEBUG("Wait Got connection after "
                        + (count-1) +" * "+ sleepTime + " ms.");
                conn.close();
                return;
            }
View Full Code Here

        String msg = null;
        while (true)
        {
            try
            {
                ClientDataSourceInterface ds = configureDataSource(
                        fullDbPath,
                        serverHost,
                        serverPort,
                        useEncryption(false) );
                Connection conn = ds.getConnection();
                // Should never get here!
                conn.close();
                assertTrue("Expected SQLState'"+expectedState
                            + "', but got connection!",
                        false);
View Full Code Here

                     */
                    String  connectionAttributes = "startMaster=true"
                        +";slaveHost="+slaveReplInterface
                        +";slavePort="+slaveReplPort
                        +useEncryption(false);
                    ClientDataSourceInterface ds = configureDataSource
                        ( masterDbPath( dbName ), masterHost, masterServerPort, connectionAttributes );
                    conn = ds.getConnection();
                   
                    done = true;
                    conn.close();
                    util.DEBUG("startMaster_direct connected in " + count + " * 100ms.");
                }
View Full Code Here

                         * using DriverManager.getConnection() concurrently
                         * in startMaster and startSlave!
                        Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
                        conn = DriverManager.getConnection(URL);
                         */
                        ClientDataSourceInterface ds = configureDataSource(
                            fDbPath, fSlaveHost, fSlaveServerPort, fConnAttrs );
                        conn = ds.getConnection();
                        conn.close();
                    }
                    catch (SQLException se)
                    {
                        startSlaveException = se;
View Full Code Here

                    slaveDbPath( replicatedDb ),
                    simpleLoadTuples);
            // return;
        }

        ClientDataSourceInterface ds = configureDataSource
            ( slaveDbPath( replicatedDb ), slaveServerHost, slaveServerPort, useEncryption(false) );
        Connection conn = ds.getConnection();
           
        simpleVerify(conn);
        conn.close();
        /* BEGIN Distributed repl. tests only */
        if ( !slaveServerHost.equalsIgnoreCase("localhost") ){
View Full Code Here

TOP

Related Classes of org.apache.derby.jdbc.ClientDataSourceInterface

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.