/** * Get a fresh connection on the engine database. * * @return a DbConn. */ static DbConn getNewDbSession() { getDb(); return _db.getConn(); }
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); }
initAdapter(); initQueries(); if (upgrade) dbUpgrade(); checkSchemaVersion(); versionValid = true;
/** * 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" }); }
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 }
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); } }
/** * Get a fresh connection on the engine database. * * @return a DbConn. */ static DbConn getNewDbSession() { getDb(); return _db.getConn(); }
initAdapter(); initQueries(); if (upgrade) dbUpgrade(); checkSchemaVersion(); versionValid = true;
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 }
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); } }
protected DbConn getNewDbSession() { DbConn cnx = db.getConn(); cnxs.add(cnx); return cnx; }
@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; } } }
/** * Create the query cache (with db-specific queries) */ private void initQueries() { DbConn cnx = getConn(); adapter.prepare(p, cnx._cnx); cnx.close(); }
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); } }
/** * Create the query cache (with db-specific queries) */ private void initQueries() { DbConn cnx = getConn(); adapter.prepare(p, cnx._cnx); cnx.close(); }