X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2FCFB.java;h=63271ec9cdd5c3036b2875ab68a59e8a53fce7b3;hp=c02aa546aa0f7efe1bd29b36f81703127e3e6497;hb=b5ed81c932db5a409f916d736fc9a8e600f8b15e;hpb=2769cf82ccae57ee3716aecc9bd694be1f115d92 diff --git a/prod/net/jaekl/cfb/CFB.java b/prod/net/jaekl/cfb/CFB.java index c02aa54..63271ec 100644 --- a/prod/net/jaekl/cfb/CFB.java +++ b/prod/net/jaekl/cfb/CFB.java @@ -48,13 +48,8 @@ public class CFB { // Command-line parameters File m_configFile; - String m_dbName; // db name File m_fbp; // FindBugsProject file File m_fbDir; // Directory where FindBugs is installed - String m_host; // db host - int m_port; // db port - String m_user; // db user - String m_pass; // db password String m_projName; // project (module) name String m_buildNum; // build number (version) boolean m_removeSchema; // purge DB schema @@ -68,13 +63,8 @@ public class CFB { m_config = new Config(); m_configFile = new File("config.properties"); - m_dbName = "CFB"; m_fbp = null; m_fbDir = null; - m_host = "localhost"; - m_port = 5432; - m_pass = ""; - m_user = "user"; m_projName = null; m_buildNum = null; m_removeSchema = false; @@ -108,13 +98,13 @@ public class CFB { m_configFile = new File(line.getOptionValue("c")); } if (line.hasOption("d")) { - m_dbName = line.getOptionValue("d"); + m_config.setDbName(line.getOptionValue("d")); } if (line.hasOption("f")) { m_fbp = new File(line.getOptionValue("f")); } if (line.hasOption("h")) { - m_host = line.getOptionValue("h"); + m_config.setDbHost(line.getOptionValue("h")); } if (line.hasOption("j")) { m_projName = line.getOptionValue("j"); @@ -126,14 +116,14 @@ public class CFB { m_output = new File(line.getOptionValue("o")); } if (line.hasOption("p")) { - m_pass = line.getOptionValue("p"); + m_config.setDbPass(line.getOptionValue("p")); } m_removeSchema = line.hasOption("drop-tables"); if (line.hasOption("t")) { - m_port = Integer.parseInt(line.getOptionValue("t")); + m_config.setDbPort(Integer.parseInt(line.getOptionValue("t"))); } if (line.hasOption("u")) { - m_user = line.getOptionValue("u"); + m_config.setDbUser(line.getOptionValue("u")); } } catch (ParseException exc) { @@ -196,7 +186,12 @@ public class CFB { MessageMap messageMap = new MessageMap(); messageMap.load(findBugsDir, Locale.getDefault(Category.DISPLAY)); - try (Connection con = m_driver.connect(m_host, m_port, m_dbName, m_user, m_pass)) { + try (Connection con = m_driver.connect( + m_config.getDbHost(), m_config.getDbPort(), + m_config.getDbName(), + m_config.getDbUser(), m_config.getDbPass()) + ) + { m_schema.setMessageMap(messageMap); if (m_removeSchema) { @@ -218,7 +213,14 @@ public class CFB { return; } - try (Connection con = m_driver.connect(m_host, m_port, m_dbName, m_user, m_pass)) { + try ( + Connection con = m_driver.connect( + m_config.getDbHost(), m_config.getDbPort(), + m_config.getDbName(), + m_config.getDbUser(), m_config.getDbPass() + ) + ) + { DbStore store = new DbStore(con, m_driver, messageMap.getColl()); store.put(analysis); @@ -241,7 +243,12 @@ public class CFB { private void reportUnableToConnect(PrintWriter pw, SQLException exc) { String cannotConnectFormat = trans(CfbBundle.CANNOT_CONNECT); - String cannotConnect = MessageFormat.format(cannotConnectFormat, m_host, ""+m_port, m_dbName, m_user); + String cannotConnect = MessageFormat.format(cannotConnectFormat, + m_config.getDbHost(), + ""+m_config.getDbPort(), + m_config.getDbName(), + m_config.getDbUser() + ); exc.printStackTrace(pw); SQLException next = exc.getNextException(); while (null != next) {