Examples of ClientDataSourceInterface


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

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

        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

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

            String dbPath,
            int startVal,
            int _noTuplesToInsert)
        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(dbPath);
        ds.setServerName(serverHost);
        ds.setPortNumber(serverPort);
        ds.setConnectionAttributes(useEncryption(false));
        Connection conn = ds.getConnection();
       
        PreparedStatement ps = conn.prepareStatement("insert into t values (?,?,?)");
        for (int i = 0; i< _noTuplesToInsert; i++)
        {
            ps.setInt(1,(i+startVal));
View Full Code Here

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

    SQLException _failOver(String serverHost, int serverPort, String dbPath)
            throws Exception
    {
        util.DEBUG("BEGIN _failOver");
        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(serverHost);
        ds.setPortNumber(serverPort);
        ds.setConnectionAttributes("failover=true"
                +useEncryption(false));
        try {
            Connection conn = ds.getConnection(); //
            conn.close();
            util.DEBUG("END   _failOver. Got Connection");
            return null; // If successfull - could only happen on slave after a master stopMaster.
        } catch (SQLException se) {
            util.DEBUG("END   _failOver. " + se.getSQLState());
View Full Code Here

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

            int serverPort,
            String dbPath)
        throws Exception
    {
        util.DEBUG("_startSlaveTrueAndCreateTrue");
        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(serverHost);
        ds.setPortNumber(serverPort);
        ds.setConnectionAttributes("startSlave=true;create=true"
                +useEncryption(true));
        try {
            Connection conn = ds.getConnection(); // XRE10 - REPLICATION_CONFLICTING_ATTRIBUTES
            conn.close();
            return null; // Should never get here.
        } catch (SQLException se) {
            return se;
        }
View Full Code Here

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

    SQLException _stopMaster(String masterServerHost, int masterServerPort, String dbPath)
            throws Exception
    {
        util.DEBUG("_stopMaster");
        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(masterServerHost);
        ds.setPortNumber(masterServerPort);
        ds.setConnectionAttributes("stopMaster=true"
                +useEncryption(false));
        try {
            Connection conn = ds.getConnection(); //
            conn.close();
            return null; // If successfull.
        } catch (SQLException se) {
            util.DEBUG(se.getErrorCode()+" "+se.getSQLState()+" "+se.getMessage());
            return se;
View Full Code Here

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

       
    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

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

        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

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

        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

Examples of org.apache.derby.jdbc.ClientDataSourceInterface

        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
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.