throw new SqlToolException(SYNTAXERR_EXITVAL,
SqltoolRB.SqlTool_syntax.getString(
revnum, RCData.DEFAULT_JDBC_DRIVER));
}
RCData conData = null;
// Use the inline RC file if it was specified
if (rcParams != null) {
rcFields = new HashMap<String, String>();
try {
varParser(rcParams, rcFields, true);
} catch (PrivateException e) {
throw new SqlToolException(SYNTAXERR_EXITVAL, e.getMessage());
}
rcUrl = rcFields.remove("url");
rcUsername = rcFields.remove("user");
rcCharset = rcFields.remove("charset");
rcTruststore = rcFields.remove("truststore");
rcPassword = rcFields.remove("password");
rcTransIso = rcFields.remove("transiso");
// Don't ask for password if what we have already is invalid!
if (rcUrl == null || rcUrl.length() < 1)
throw new SqlToolException(RCERR_EXITVAL,
SqltoolRB.rcdata_inlineurl_missing.getString());
// We now allow both null and "" user name, but we require password
// if the user name != null.
if (rcPassword != null && rcPassword.length() > 0)
throw new SqlToolException(RCERR_EXITVAL,
SqltoolRB.rcdata_password_visible.getString());
if (rcFields.size() > 0) {
throw new SqlToolException(INPUTERR_EXITVAL,
SqltoolRB.rcdata_inline_extravars.getString(
rcFields.keySet().toString()));
}
if (rcUsername != null && rcPassword == null) try {
rcPassword = promptForPassword(rcUsername);
} catch (PrivateException e) {
throw new SqlToolException(INPUTERR_EXITVAL,
SqltoolRB.password_readfail.getString(e.getMessage()));
}
try {
conData = new RCData(CMDLINE_ID, rcUrl, rcUsername,
rcPassword, driver, rcCharset,
rcTruststore, null, rcTransIso);
} catch (RuntimeException re) {
throw re; // Unrecoverable
} catch (Exception e) {
throw new SqlToolException(RCERR_EXITVAL,
SqltoolRB.rcdata_genfromvalues_fail.getString());
}
} else if (listMode || targetDb != null) {
try {
conData = new RCData(new File((rcFile == null)
? DEFAULT_RCFILE
: rcFile), targetDb);
} catch (RuntimeException re) {
throw re; // Unrecoverable
} catch (Exception e) {
throw new SqlToolException(RCERR_EXITVAL,
SqltoolRB.conndata_retrieval_fail.getString(
targetDb, e.getMessage()));
}
}
//if (debug) {
//conData.report();
//}
if (listMode) {
// listMode has been handled above.
// Just returning here to prevent unexpected consequences if the
// user specifies both an inline RC (will will be ignored) and
// --list.
return;
}
if (interactive) System.out.print("SqlTool v. " + revnum + '.' + LS);
if (conData != null) try {
conn = conData.getConnection(
driver, System.getProperty("javax.net.ssl.trustStore"));
conn.setAutoCommit(autoCommit);
String conBanner;