+
+ Connection getConnection() throws ClassNotFoundException, SQLException, SquelchException
+ {
+ String jdbcUrl = m_args.getUrl();
+ DbDriver driver = getDriverFor(jdbcUrl);
+
+ return driver.connect(jdbcUrl, m_args.getUser(), m_args.getPass());
+ }
+
+ DbDriver getDriverFor(String jdbcUrl) throws SquelchException
+ {
+ for (DbDriver driver : DB_DRIVERS) {
+ if (driver.handles(jdbcUrl)) {
+ return driver;
+ }
+ }
+ throw new SquelchException("Cannot determine DB Driver for JDBC URL: \"" + jdbcUrl + "\".");
+ }
+
+ void pumpLines(PrintWriter pw, ConsoleInput ci) throws IOException, ClassNotFoundException, SQLException, SquelchException
+ {
+ String line = null;
+ try (Connection conn = getConnection())
+ {
+ while (true) {
+ boolean processed = false;
+ line = ci.readLine(PROMPT);
+
+ for (Stmt statement : m_statements) {
+ if (statement.handles(line)) {
+ statement.exec(conn, pw, line);
+ processed = true;
+ break;
+ }
+ }
+
+ if ((!processed)) {
+ if (isQuit(line)) {
+ break;
+ }
+ // Unrecognized command
+ pw.println("??? \"" + line + "\"");
+ }
+ }
+ }
+ }