Examples of ConnectionInfo


Examples of org.apache.tuscany.das.rdb.config.ConnectionInfo

    public void testConnectionInfo() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addConnectionInfo("jdbc/adatasource");

        Config config = helper.getConfig();
        ConnectionInfo info = config.getConnectionInfo();
        assertEquals(info.getDataSource(), "jdbc/adatasource");
        assertEquals(info.isManagedtx(), true);
    }
View Full Code Here

Examples of org.apache.tuscany.das.rdb.config.ConnectionInfo

    public void testConnectionInfo2() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addConnectionInfo("jdbc/adatasource", false);

        Config config = helper.getConfig();
        ConnectionInfo info = config.getConnectionInfo();
        assertEquals(info.getDataSource(), "jdbc/adatasource");
        assertEquals(info.isManagedtx(), false);
    }
View Full Code Here

Examples of org.apache.tuscany.sca.data.engine.config.ConnectionInfo

     */
    public ConnectionInfo read(XMLStreamReader reader) throws ContributionReadException {
        assert CONNECTION_INFO.equals(reader.getName());

        // Create a ConnectionInfo from the component type model
        ConnectionInfo connectionInfo = new ConnectionInfo();

        /*
         *  <connectionInfo dataSource="jdbc:derby:target/test-classes/dastest; create = true"/>
         */
        String dataSource = reader.getAttributeValue(null, "datasource"); // exclusive with connection properties
        if (dataSource != null && dataSource.length() > 0) {
            connectionInfo.setDataSource(dataSource);
        } else {
            try {
                int event = reader.next();
                while (event == XMLStreamConstants.CHARACTERS) {
                    event = reader.next();
                }
            } catch (XMLStreamException e) {
              ContributionReadException ce = new ContributionReadException(e);
              error("ContributionReadException", reader, ce);
                throw ce;
            }

            QName element = reader.getName();
           
            assert CONNECTION_PROPERTIES.equals(element);
           
            /*
             * <connectionProperties
             *  driverClass="org.apache.derby.jdbc.EmbeddedDriver"
             *  databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
             *  username=""
             *  password=""
             *  loginTimeout="600000"/>
             */
           
            String driverClass = reader.getAttributeValue(null, "driverClass");
            String databaseURL = reader.getAttributeValue(null, "databaseURL");
            String username = reader.getAttributeValue(null, "username");
            String password = reader.getAttributeValue(null, "password");
            String loginTimeout = reader.getAttributeValue(null, "loginTimeout");

            // FIXME: validation sending info to monitor....
            ConnectionProperties connectionProperties = new ConnectionProperties();
            connectionProperties.setDriverClass(driverClass);
            connectionProperties.setDatabaseURL(databaseURL);
            connectionProperties.setUsername(username);
            connectionProperties.setPassword(password);
            if (loginTimeout != null) {
                connectionProperties.setLoginTimeout(Integer.parseInt(loginTimeout));
            }

            connectionInfo.setConnectionProperties(connectionProperties);
        }
       
        return connectionInfo;
    }
View Full Code Here

Examples of org.codehaus.activemq.message.ConnectionInfo

            return;
        }
       
        this.isConnectionInfoSentToBroker = true;
        ensureClientIDInitialised();
        ConnectionInfo info = new ConnectionInfo();
        info.setClientId(this.clientID);
        info.setHostName(IdGenerator.getHostName());
        info.setUserName(userName);
        info.setPassword(password);
        info.setId(packetIdGenerator.generateId());
        info.setStartTime(startTime);
        info.setStarted(started.get());
        info.setClosed(closed.get() || closing);
        info.setClientVersion(connectionMetaData.getProviderVersion());
        info.setWireFormatVersion(transportChannel.getCurrentWireFormatVersion());
        syncSendPacket(info, timeout);
    }
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

                getConnection("jdbc:h2:mem:;init=runscript from 'wrong.file'");
    }

    private void testConnectionInfo() throws Exception {
        Properties info = new Properties();
        ConnectionInfo connectionInfo = new ConnectionInfo(
                "jdbc:h2:mem:test" +
                        ";LOG=2" +
                        ";ACCESS_MODE_DATA=rws" +
                        ";INIT=CREATE this...\\;INSERT that..." +
                        ";IFEXISTS=TRUE",
                info);

        assertEquals("jdbc:h2:mem:test", connectionInfo.getURL());

        assertEquals("2", connectionInfo.getProperty("LOG", ""));
        assertEquals("rws", connectionInfo.getProperty("ACCESS_MODE_DATA", ""));
        assertEquals("CREATE this...;INSERT that...", connectionInfo.getProperty("INIT", ""));
        assertEquals("TRUE", connectionInfo.getProperty("IFEXISTS", ""));
        assertEquals("undefined", connectionInfo.getProperty("CACHE_TYPE", "undefined"));
    }
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

        assertEquals("undefined", connectionInfo.getProperty("CACHE_TYPE", "undefined"));
    }

    private void testName() throws Exception {
        char differentFileSeparator = File.separatorChar == '/' ? '\\' : '/';
        ConnectionInfo connectionInfo = new ConnectionInfo("test" + differentFileSeparator + "subDir");
        File file = new File("test" + File.separatorChar + "subDir");
        assertEquals(file.getCanonicalPath(), connectionInfo.getName());
    }
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

    /**
     * INTERNAL
     */
    public JdbcConnection(String url, Properties info) throws SQLException {
        this(new ConnectionInfo(url, info), true);
    }
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

            // avoid using the Engine class to avoid deadlocks
            Properties p = new Properties();
            String userName =  getUser();
            p.setProperty("user", userName);
            p.setProperty("password", getPassword());
            ConnectionInfo ci = new ConnectionInfo("jdbc:h2:" + testDatabase + ";FILE_LOCK=NO;TRACE_LEVEL_FILE=0", p);
            Database database = new Database(ci, null);
            // close the database
            Session session = database.getSystemSession();
            session.prepare("shutdown immediately").update();
            database.removeSession(null);
            // everything OK - return
            return;
        } catch (DbException e) {
            SQLException e2 = DbException.toSQLException(e);
            int errorCode = e2.getErrorCode();
            if (errorCode == ErrorCode.WRONG_USER_OR_PASSWORD) {
                return;
            } else if (errorCode == ErrorCode.FILE_ENCRYPTION_ERROR_1) {
                return;
            }
            e.printStackTrace(System.out);
        } catch (Exception e) {
            // failed
            int errorCode = 0;
            if (e instanceof SQLException) {
                errorCode = ((SQLException) e).getErrorCode();
            }
            if (errorCode == ErrorCode.WRONG_USER_OR_PASSWORD) {
                return;
            } else if (errorCode == ErrorCode.FILE_ENCRYPTION_ERROR_1) {
                return;
            }
            e.printStackTrace(System.out);
        }
        System.out.println("begin ------------------------------ " + writeCount);
        try {
            Recover.execute(fileName.substring(0, fileName.lastIndexOf('/')), null);
        } catch (SQLException e) {
            // ignore
        }
        testDatabase += "X";
        try {
            IOUtils.copy(fileName, testDatabase + Constants.SUFFIX_PAGE_FILE);
            // avoid using the Engine class to avoid deadlocks
            Properties p = new Properties();
            ConnectionInfo ci = new ConnectionInfo("jdbc:h2:" + testDatabase + ";FILE_LOCK=NO", p);
            Database database = new Database(ci, null);
            // close the database
            database.removeSession(null);
        } catch (Exception e) {
            int errorCode = 0;
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

        Object o = info.get("password");
        if (o != null && o instanceof char[]) {
            i2.put("password", StringUtils.cloneCharArray((char[]) o));
        }
        info = i2;
        ConnectionInfo ci = new ConnectionInfo(url, info);
        if (ci.isRemote() || !ci.isPersistent()) {
            return null;
        }
        String name = ci.getName();
        if (IOUtils.exists(name + ".h2.db")) {
            return null;
        }
        if (!IOUtils.exists(name + ".data.db")) {
            return null;
        }
        if (ci.removeProperty("NO_UPGRADE", false)) {
            return connectWithOldVersion(url, info);
        }
        synchronized (DbUpgrade.class) {
            upgrade(ci, info);
            return null;
View Full Code Here

Examples of org.h2.engine.ConnectionInfo

                Properties info = new Properties();
                info.put("MODE", "PostgreSQL");
                info.put("USER", userName);
                info.put("PASSWORD", password);
                String url = "jdbc:h2:" + databaseName;
                ConnectionInfo ci = new ConnectionInfo(url, info);
                String baseDir = server.getBaseDir();
                if (baseDir == null) {
                    baseDir = SysProperties.getBaseDir();
                }
                if (baseDir != null) {
                    ci.setBaseDir(baseDir);
                }
                if (server.getIfExists()) {
                    ci.setProperty("IFEXISTS", "TRUE");
                }
                conn = new JdbcConnection(ci, false);
                // can not do this because when called inside
                // DriverManager.getConnection, a deadlock occurs
                // conn = DriverManager.getConnection(url, userName, password);
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.