/** * Save the current connection settings to the properties file. * * @return the file to open afterwards */ private String settingSave() { ConnectionInfo info = new ConnectionInfo(); info.name = attributes.getProperty("name", ""); info.driver = attributes.getProperty("driver", ""); info.url = attributes.getProperty("url", ""); info.user = attributes.getProperty("user", ""); server.updateSetting(info); attributes.put("setting", info.name); server.saveProperties(null); return "index.do"; }
ConnectionInfo info = settings.get(i); if (info != null) { prop.setProperty(String.valueOf(len - i - 1), info.getString());
if (prop.size() == 0) { for (String gen : GENERIC) { ConnectionInfo info = new ConnectionInfo(gen); settings.add(info); updateSetting(info); break; ConnectionInfo info = new ConnectionInfo(data); settings.add(info); updateSetting(info);
synchronized void saveSettings() { try { Properties prop = new SortedProperties(); if (driverList != null) { prop.setProperty("drivers", driverList); } prop.setProperty("webPort", String.valueOf(port)); prop.setProperty("webAllowOthers", String.valueOf(allowOthers)); prop.setProperty("webSSL", String.valueOf(ssl)); ArrayList settings = getSettings(); int len = settings.size(); for (int i = 0; i < len; i++) { ConnectionInfo info = (ConnectionInfo) settings.get(i); if (info != null) { prop.setProperty(String.valueOf(len - i - 1), info.getString()); } } OutputStream out = FileUtils.openFileOutputStream(getPropertiesFileName(), false); prop.store(out, Constants.SERVER_PROPERTIES_TITLE); out.close(); } catch (Exception e) { TraceSystem.traceThrowable(e); } }
@Override public void init() { super.init(); try { Field field = WebServlet.class.getDeclaredField("server"); field.setAccessible(true); org.h2.server.web.WebServer server = (org.h2.server.web.WebServer) field.get(this); ConnectionInfo connectionInfo = new ConnectionInfo("Traccar|" + Context.getConfig().getString("database.driver") + "|" + Context.getConfig().getString("database.url") + "|" + Context.getConfig().getString("database.user")); Method method; method = org.h2.server.web.WebServer.class.getDeclaredMethod("updateSetting", ConnectionInfo.class); method.setAccessible(true); method.invoke(server, connectionInfo); method = org.h2.server.web.WebServer.class.getDeclaredMethod("setAllowOthers", boolean.class); method.setAccessible(true); method.invoke(server, true); } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { LOGGER.warn("Console reflection error", e); } }
ConnectionInfo info = settings.get(i); if (info != null) { prop.setProperty(String.valueOf(len - i - 1), info.getString());
ConnectionInfo info = new ConnectionInfo(data); url = info.url; user = info.user;
ConnectionInfo info = settings.get(i); if (info != null) { prop.setProperty(String.valueOf(len - i - 1), info.getString());
ConnectionInfo info = server.getSetting(setting); if (info == null) { info = new ConnectionInfo();
private String settingSave() { ConnectionInfo info = new ConnectionInfo(); info.name = attributes.getProperty("name", ""); info.driver = attributes.getProperty("driver", ""); info.url = attributes.getProperty("url", ""); info.user = attributes.getProperty("user", ""); server.updateSetting(info); attributes.put("setting", info.name); server.saveSettings(); return "index.do"; }
/** * Save the current connection settings to the properties file. * * @return the file to open afterwards */ private String settingSave() { ConnectionInfo info = new ConnectionInfo(); info.name = attributes.getProperty("name", ""); info.driver = attributes.getProperty("driver", ""); info.url = attributes.getProperty("url", ""); info.user = attributes.getProperty("user", ""); server.updateSetting(info); attributes.put("setting", info.name); server.saveProperties(null); return "index.do"; }
/** * Save the current connection settings to the properties file. * * @return the file to open afterwards */ private String settingSave() { ConnectionInfo info = new ConnectionInfo(); info.name = attributes.getProperty("name", ""); info.driver = attributes.getProperty("driver", ""); info.url = attributes.getProperty("url", ""); info.user = attributes.getProperty("user", ""); server.updateSetting(info); attributes.put("setting", info.name); server.saveProperties(null); return "index.do"; }
synchronized ArrayList getSettings() { ArrayList settings = new ArrayList(); if (connInfoMap.size() == 0) { Properties prop = loadProperties(); if (prop.size() == 0) { for (int i = 0; i < GENERIC.length; i++) { ConnectionInfo info = new ConnectionInfo(GENERIC[i]); settings.add(info); updateSetting(info); } } else { for (int i = 0;; i++) { String data = prop.getProperty(String.valueOf(i)); if (data == null) { break; } ConnectionInfo info = new ConnectionInfo(data); settings.add(info); updateSetting(info); } } } else { settings.addAll(connInfoMap.values()); } sortConnectionInfo(settings); return settings; }
if (prop.size() == 0) { for (String gen : GENERIC) { ConnectionInfo info = new ConnectionInfo(gen); settings.add(info); updateSetting(info); break; ConnectionInfo info = new ConnectionInfo(data); settings.add(info); updateSetting(info);
if (prop.size() == 0) { for (String gen : GENERIC) { ConnectionInfo info = new ConnectionInfo(gen); settings.add(info); updateSetting(info); break; ConnectionInfo info = new ConnectionInfo(data); settings.add(info); updateSetting(info);
ConnectionInfo info = new ConnectionInfo(data); url = info.url; user = info.user;