Changeset: 85ce293e7229 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/85ce293e7229
Modified Files:
src/main/java/org/monetdb/client/JdbcClient.java
src/main/java/org/monetdb/jdbc/MonetConnection.java
Branch: default
Log Message:
Extend JdbcClient welcome message with server product release string, same as
done by mclient.
For this MonetConnection is extended with public method
getServerProductRelease().
diffs (120 lines):
diff --git a/src/main/java/org/monetdb/client/JdbcClient.java
b/src/main/java/org/monetdb/client/JdbcClient.java
--- a/src/main/java/org/monetdb/client/JdbcClient.java
+++ b/src/main/java/org/monetdb/client/JdbcClient.java
@@ -410,7 +410,7 @@ public final class JdbcClient {
// we only want user tables and views to be dumped (DDL
and optional data), unless a specific table is requested
final String[] types = {"TABLE","VIEW","MERGE
TABLE","REMOTE TABLE","REPLICA TABLE","STREAM TABLE"};
// Future: fetch all type names using
dbmd.getTableTypes() and construct String[] with all
- // table type names excluding the SYSTEM ... ones and
LOCAL TEMPORARY TABLE ones.
+ // table type names excluding the SYSTEM ... ones and
LOCAL TEMPORARY TABLE/VIEW ones.
// request the list of tables/views available in the
current schema in the database
ResultSet tbl = dbmd.getTables(null, con.getSchema(),
null, (argcount == 0) ? types : null);
@@ -558,14 +558,17 @@ public final class JdbcClient {
} else {
if (!copts.getOption("quiet").isPresent()) {
// print welcome message
- out.println("Welcome to the MonetDB
interactive JDBC terminal!");
+ out.println("Welcome to JdbcClient, the
MonetDB interactive SQL client");
if (dbmd != null) {
- out.println("JDBC Driver: " +
dbmd.getDriverName() +
+ String monet_release = "";
+ if (con instanceof
MonetConnection)
+ monet_release =
((MonetConnection) con).getServerProductRelease();
+ out.println("Using JDBC Driver:
" + dbmd.getDriverName() +
" v" +
dbmd.getDriverVersion());
- out.println("Database Server: "
+ dbmd.getDatabaseProductName() +
- " v" +
dbmd.getDatabaseProductVersion());
+ out.println("Connected Server :
" + dbmd.getDatabaseProductName() +
+ " v" +
dbmd.getDatabaseProductVersion() + " " + monet_release);
}
- out.println("Current Schema: " +
con.getSchema());
+ out.println("Current Schema : \"" +
con.getSchema() + "\"");
out.println("Type \\q to quit (you can
also use: quit or exit), \\? or \\h for a list of available commands");
out.flush();
}
diff --git a/src/main/java/org/monetdb/jdbc/MonetConnection.java
b/src/main/java/org/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -1786,15 +1786,16 @@ public class MonetConnection
return target.buildUrl();
}
- // Internal caches for 4 static mserver5 environment values
+ // Internal caches for 5 static mserver5 environment values
private String env_current_user;
private String env_monet_version;
+ private String env_monet_release;
private String env_raw_strings; // Note: this is only supported from
Jun2020 (11.37) servers
private int maxConnections;
/**
- * Utility method to fetch 4 mserver5 environment values combined in
one query for efficiency.
- * We fetch the env values of: current_user, monet_version, max_clients
and raw_strings.
+ * Utility method to fetch 5 mserver5 environment values combined in
one query for efficiency.
+ * We fetch the env() values of: current_user, monet_version,
monet_release, max_clients and raw_strings.
* We cache them such that we do not need to query the server again and
again.
* Note: raw_strings is available in sys.env() result set since release
Jun2020 (11.37)
*
@@ -1808,7 +1809,7 @@ public class MonetConnection
if (st != null) {
rs = st.executeQuery(
"SELECT \"name\", \"value\" FROM
\"sys\".\"env\"()" +
- " WHERE \"name\" IN ('monet_version',
'max_clients', 'raw_strings')" +
+ " WHERE \"name\" IN ('monet_version',
'monet_release', 'max_clients', 'raw_strings')" +
" UNION SELECT 'current_user' as
\"name\", current_user as \"value\"");
if (rs != null) {
while (rs.next()) {
@@ -1820,6 +1821,9 @@ public class MonetConnection
if
("monet_version".equals(prop)) {
env_monet_version =
value;
} else
+ if
("monet_release".equals(prop)) {
+ env_monet_release =
value;
+ } else
if ("raw_strings".equals(prop))
{
env_raw_strings = value;
} else
@@ -1839,7 +1843,7 @@ public class MonetConnection
} finally {
closeResultsetStatement(rs, st);
}
- // for debug: System.out.println("Read: env_current_user: " +
env_current_user + " env_monet_version: " + env_monet_version + "
env_max_clients: " + maxConnections + " env_raw_strings: " + env_raw_strings);
+ // for debug: System.out.println("Read: env_current_user: " +
env_current_user + " env_monet_version: " + env_monet_version + "
env_monet_release: " + env_monet_release + " env_max_clients: " +
maxConnections + " env_raw_strings: " + env_raw_strings);
}
/**
@@ -1894,6 +1898,22 @@ public class MonetConnection
}
/**
+ * Get the product release of the connected MonetDB server.
+ * It is called from JdbcClient, hence it is made public.
+ *
+ * @return the MonetDB server release string.
+ * @throws SQLException if fetching MonetDB server release string failed
+ */
+ public String getServerProductRelease() throws SQLException {
+ if (env_monet_release == null)
+ getEnvValues();
+ if (env_monet_version != null)
+ return env_monet_release;
+ // always return a valid String to prevent NPE
+ return "";
+ }
+
+ /**
* Get the product version of the connected MonetDB Database Server.
* It is called from: MonetDatabaseMetaData
*
@@ -1903,9 +1923,9 @@ public class MonetConnection
String getDatabaseProductVersion() throws SQLException {
if (env_monet_version == null)
getEnvValues();
- // always return a valid String to prevent NPE in getTables()
and getTableTypes()
if (env_monet_version != null)
return env_monet_version;
+ // always return a valid String to prevent NPE in getTables()
and getTableTypes()
return "";
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]