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; } } }
db = new Db(ds, true); cnx = db.getConn();
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); } }
db = new Db(ds, true); cnx = db.getConn();
public JqmAsyncTester() { // Ext dir File extDir = new File("./ext"); if (!extDir.exists() && !extDir.mkdir()) { throw new RuntimeException(new IOException("./ext directory does not exist and cannot create it")); } s = Common.createHsqlServer(); s.start(); JDBCDataSource ds = new JDBCDataSource(); ds.setDatabase("jdbc:hsqldb:mem:" + s.getDatabaseName(0, true)); db = new Db(ds, true); cnx = db.getConn(); Properties p2 = Common.dbProperties(s); p2.put("com.enioka.jqm.jdbc.contextobject", db); JqmClientFactory.setProperties(p2); JqmEngineFactory.setDatasource(db); JqmEngineFactory.initializeMetadata(); cnx.runUpdate("dp_delete_all"); cnx.runUpdate("q_delete_all"); cnx.commit(); // Needed parameters addGlobalParameter("defaultConnection", ""); addGlobalParameter("disableWsApi", "true"); addGlobalParameter("logFilePerLaunch", "false"); // Prepare DB }
public JqmAsyncTester() { // Ext dir File extDir = new File("./ext"); if (!extDir.exists() && !extDir.mkdir()) { throw new RuntimeException(new IOException("./ext directory does not exist and cannot create it")); } s = Common.createHsqlServer(); s.start(); JDBCDataSource ds = new JDBCDataSource(); ds.setDatabase("jdbc:hsqldb:mem:" + s.getDatabaseName(0, true)); db = new Db(ds, true); cnx = db.getConn(); Properties p2 = Common.dbProperties(s); p2.put("com.enioka.jqm.jdbc.contextobject", db); JqmClientFactory.setProperties(p2); JqmEngineFactory.setDatasource(db); JqmEngineFactory.initializeMetadata(); cnx.runUpdate("dp_delete_all"); cnx.runUpdate("q_delete_all"); cnx.commit(); // Needed parameters addGlobalParameter("defaultConnection", ""); addGlobalParameter("disableWsApi", "true"); addGlobalParameter("logFilePerLaunch", "false"); // Prepare DB }