/** * Helper method to load the standard JQM property files from class path. * * @return a Properties object, which may be empty but not null. */ public static Properties loadProperties() { return loadProperties(new String[] { "META-INF/jqm.properties", "jqm.properties" }); }
/** * Helper method to load the standard JQM property files from class path. * * @return a Properties object, which may be empty but not null. */ public static Properties loadProperties() { return loadProperties(new String[] { "META-INF/jqm.properties", "jqm.properties" }); }
private Db createFactory() { jqmlogger.debug("Creating connection factory to database"); // Get all properties from all allowed sources. p.putAll(Db.loadProperties()); // Create DB. return new Db(p); }
private static Db createFactory() { try { Properties p = Db.loadProperties(); Db n = new Db(p); p.put("com.enioka.jqm.jdbc.contextobject", n); // Share the DataSource in engine and client. JqmClientFactory.setProperties(p); return n; } catch (Exception e) { jqmlogger.error("Unable to connect with the database. Maybe your configuration file is wrong. " + "Please check the password or the url in the $JQM_DIR/conf/resources.xml", e); throw new JqmInitError("Database connection issue", e); } }
private static Db createFactory() { try { Properties p = Db.loadProperties(); Db n = new Db(p); p.put("com.enioka.jqm.jdbc.contextobject", n); // Share the DataSource in engine and client. JqmClientFactory.setProperties(p); return n; } catch (Exception e) { jqmlogger.error("Unable to connect with the database. Maybe your configuration file is wrong. " + "Please check the password or the url in the $JQM_DIR/conf/resources.xml", e); throw new JqmInitError("Database connection issue", e); } }
@Override int doWork() { if (!Helpers.isDbInitialized()) { jqmlogger.info("Database connector initialization"); Properties p = Db.loadProperties(); p.setProperty("com.enioka.jqm.jdbc.allowSchemaUpdate", "true"); Db db = new Db(p); Helpers.setDb(db); } try (DbConn cnx = Helpers.getNewDbSession()) { Helpers.updateConfiguration(cnx); cnx.commit(); jqmlogger.info("Upgrade done"); jqmlogger.info("Existing nodes: " + MetaService.getNodes(cnx).size()); return 0; } catch (Exception e) { jqmlogger.error("Could not upgrade", e); return 101; } } }
private static void upgrade() { DbConn cnx = null; try { if (!Helpers.isDbInitialized()) { Properties p = Db.loadProperties(); p.setProperty("com.enioka.jqm.jdbc.allowSchemaUpdate", "true"); Db db = new Db(p); Helpers.setDb(db); } cnx = Helpers.getNewDbSession(); Helpers.updateConfiguration(cnx); cnx.commit(); jqmlogger.info("Upgrade done"); jqmlogger.info("Existing nodes: " + MetaService.getNodes(cnx).size()); } catch (Exception e) { throw new JqmRuntimeException("Could not upgrade", e); } finally { Helpers.closeQuietly(cnx); } }