Mercurial > hg > monetdb-java
changeset 794:a418afda6b21 monetdbs
Suppress jdbcclient warnings about unknown .monetdb settings
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Wed, 06 Dec 2023 16:50:37 +0100 (16 months ago) |
parents | 5bfe3357fb1c |
children | 04a27386789f |
files | src/main/java/org/monetdb/client/JdbcClient.java src/main/java/org/monetdb/util/CmdLineOpts.java |
diffstat | 2 files changed, 20 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/monetdb/client/JdbcClient.java +++ b/src/main/java/org/monetdb/client/JdbcClient.java @@ -190,6 +190,13 @@ public final class JdbcClient { "statements read. Batching can greatly speedup the " + "process of restoring a database dump."); +// This file can contain defaults for the flags user, password, language, +// database, save_history, format, host, port, and width. For example, an + + copts.addIgnored("save_history"); + copts.addIgnored("format"); + copts.addIgnored("width"); + // we store user and password in separate variables in order to // be able to properly act on them like forgetting the password // from the user's file if the user supplies a username on the @@ -325,11 +332,9 @@ public final class JdbcClient { // make sure the driver class is loaded (and thus register itself with the DriverManager) Class.forName("org.monetdb.jdbc.MonetDriver"); - con = DriverManager.getConnection( - "jdbc:monetdb://" + host + "/" + database + attr, - user, - pass - ); + String url = "jdbc:monetdb://" + host + "/" + database + attr; + System.err.println(url); + con = DriverManager.getConnection(url, user, pass); SQLWarning warn = con.getWarnings(); while (warn != null) { System.err.println("Connection warning: " + warn.getMessage());
--- a/src/main/java/org/monetdb/util/CmdLineOpts.java +++ b/src/main/java/org/monetdb/util/CmdLineOpts.java @@ -10,11 +10,13 @@ package org.monetdb.util; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Properties; public final class CmdLineOpts { /** the arguments we handle */ private HashMap<String, OptionContainer> opts = new HashMap<String, OptionContainer>(); + private final HashSet<String> ignoredInFile = new HashSet<>(); /** the options themself */ private ArrayList<OptionContainer> options = new ArrayList<OptionContainer>(); @@ -53,6 +55,10 @@ public final class CmdLineOpts { opts.put(longa, oc); } + public void addIgnored(String name) { + ignoredInFile.add(name); + } + public void removeOption(final String name) { final OptionContainer oc = opts.get(name); if (oc != null) { @@ -88,10 +94,11 @@ public final class CmdLineOpts { if (option != null) { option.resetArguments(); option.addArgument(prop.getProperty(key)); - } else + } else if (!ignoredInFile.contains(key)) { // ignore unknown options (it used to throw an OptionsException) - System.out.println("Info: Ignoring unknown/unsupported option (in " + file.getAbsolutePath() + "): " + key); - } + System.out.println("Info: Ignoring unknown/unsupported option (in " + file.getAbsolutePath() + "): " + key); + } + } } catch (java.io.IOException e) { throw new OptionsException("File IO Exception: " + e); }