Package de.innovationgate.webgate.api.jdbc.custom

Examples of de.innovationgate.webgate.api.jdbc.custom.JDBCConnectionProvider


        Properties props = new Properties();
        props.put("user", user);
        props.put("password", pwd);
        props.put("hsqldb.default_table_type", "cached");
        props.put("shutdown", "true");
        JDBCConnectionProvider conProvider = null;
       
        boolean isInitialized = false;
        boolean migrateToCS5 = false;
        double csVersion = 0;
        try {
            conProvider = new JDBCConnectionProvider(jdbcPath, driver.getClass().getName(), props, false);
            List<String> tables = conProvider.getDatabaseTables();
           
            // Look if the database is empty and we must initialize it
            String contentTable = (String) Groq.selectFrom(tables).whereEqualsIgnoreCase("content").singleValue();
            if (contentTable != null) {
                isInitialized = true;
                if (db.getCreationOptions().containsKey(WGDatabase.COPTION_CONTENT_STORE_VERSION)) {
                   
                    // Look if the desired target format is CS5 (or higher)
                    double targetCsVersion = Double.valueOf((String) db.getCreationOptions().get(WGDatabase.COPTION_CONTENT_STORE_VERSION)).doubleValue();
                    if (targetCsVersion >= WGDatabase.CSVERSION_WGA5) {
                        // Look if the actual format it is lower than CS5. If so we automatically migrate it to that format
                        csVersion = determineCSVersion(conProvider);
                        if (csVersion < WGDatabase.CSVERSION_WGA5) {
                            migrateToCS5 = true;
                            isInitialized = false;
                        }
                    }
                }
            }
        }
        catch (Exception e) {
            throw new WGInvalidDatabaseException("Unable to connect to database", e);
        }
        finally {
            if (conProvider != null) {
                try {
                    conProvider.close();
                }
                catch (JDBCConnectionException e) {
                }
            }
        }
View Full Code Here




    private boolean isContentStore(String dbName, WGDatabaseServer dbServer) {
       
        JDBCConnectionProvider connProvider = null;
        try {
            Properties props = new Properties();
            props.put("user", "sa");
            props.put("password", "");
           
            HsqlDatabaseServer hsqlServer = (HsqlDatabaseServer) dbServer;
            File dir = hsqlServer.getDatabaseDirectory();
            File dbFile = new File(dir, dbName);
            String path = "jdbc:hsqldb:file:" + dbFile.getPath();
           
            connProvider = new JDBCConnectionProvider(path, WGDatabaseImpl.DRIVER, props, false);
            Iterator<String> tables = connProvider.getDatabaseTables().iterator();
            boolean isContentStore = false;
            while (tables.hasNext()) {
                String tableName = (String) tables.next();
                if (tableName.equalsIgnoreCase("WEBAREAS") || tableName.equals("webarea")) {
                    isContentStore = true;
                    break;
                }
               
            }
           
            return isContentStore;
           
        }
        catch (Exception e) {
            WGFactory.getLogger().error("Exception determining database type on hsqldb " + dbName + " on server '" + dbServer.getTitle(Locale.getDefault()) + "'", e);
            return false;
        }
        finally {
            if (connProvider != null) {
                try {
                    connProvider.close();
                }
                catch (JDBCConnectionException e) {
                    WGFactory.getLogger().error("Exception closing connection on hsqldb " + dbName + " on server '" + dbServer.getTitle(Locale.getDefault()) + "'", e);                }
            }
        }
View Full Code Here

       
        // Set dbkey property so we see DBCP metrics via JMX
        props.put("dbcp.dbkey", db.getDbReference());
   
    try {
            _connProvider = new JDBCConnectionProvider(path, driverName, props, true);
        }
        catch (JDBCConnectionException e) {
            throw new WGInvalidDatabaseException("Exception setting up JDBC connection", e);
        }
   
View Full Code Here

                    props.put("hibernate.connection." + option.substring(5), creationOptions.get(option));
                }
            }
            props.put("user", WGUtils.getValueOrDefault(userName, ""));
            props.put("password", WGUtils.getValueOrDefault(password, ""));
            JDBCConnectionProvider connProvider = new JDBCConnectionProvider(path, (String) db.getCreationOptions().get(jdbcDriver), props, false);
            try {
                double version = determineCSVersion(connProvider);
                int patchLevel = 0;
                if (version == WGDatabase.CSVERSION_WGA5) {
                    patchLevel = determinePatchLevel(connProvider);
                }
                return new CSVersion(version, patchLevel);
            }
            finally {
                try {
                    connProvider.close();
                }
                catch (Exception e) {
                    WGFactory.getLogger().error("Exception closing JDBC connection provider", e);
                }
            }
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.jdbc.custom.JDBCConnectionProvider

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.