Skip to content

Commit

Permalink
[CONJ-391] Use SELECT in place of SHOW command on connection, with fa…
Browse files Browse the repository at this point in the history
…llback to show commands in case of galera non primary node
  • Loading branch information
rusher committed Nov 23, 2016
1 parent 27146f6 commit ab3a83e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,41 @@ private void loadCalendar() throws QueryException {
private void loadServerData() throws QueryException, IOException {
serverData = new TreeMap<>();
SingleExecutionResult qr = new SingleExecutionResult(null, 0, true, false);

try {
executeQuery(true, qr, "SHOW VARIABLES WHERE Variable_name in ("
+ "'max_allowed_packet', "
+ "'system_time_zone', "
+ "'time_zone', "
+ "'sql_mode'"
+ ")", ResultSet.TYPE_FORWARD_ONLY);
executeQuery(true, qr, "SELECT @@max_allowed_packet , "
+ "@@system_time_zone, "
+ "@@time_zone, "
+ "@@sql_mode",
ResultSet.TYPE_FORWARD_ONLY);
MariaSelectResultSet resultSet = qr.getResultSet();
while (resultSet.next()) {
logger.debug("server data " + resultSet.getString(1) + " : " + resultSet.getString(2));
serverData.put(resultSet.getString(1), resultSet.getString(2));
}
resultSet.next();

serverData.put("max_allowed_packet", resultSet.getString(1));
serverData.put("system_time_zone", resultSet.getString(2));
serverData.put("time_zone", resultSet.getString(3));
serverData.put("sql_mode", resultSet.getString(4));

} catch (SQLException sqle) {
throw new QueryException("could not load system variables", -1, CONNECTION_EXCEPTION, sqle);

//fallback in case of galera non primary nodes that permit only show / set command
try {
executeQuery(true, qr, "SHOW VARIABLES WHERE Variable_name in ("
+ "'max_allowed_packet', "
+ "'system_time_zone', "
+ "'time_zone', "
+ "'sql_mode'"
+ ")", ResultSet.TYPE_FORWARD_ONLY);
MariaSelectResultSet resultSet = qr.getResultSet();
while (resultSet.next()) {
logger.debug("server data " + resultSet.getString(1) + " : " + resultSet.getString(2));
serverData.put(resultSet.getString(1), resultSet.getString(2));
}
} catch (SQLException sqlee) {
throw new QueryException("could not load system variables", -1, CONNECTION_EXCEPTION, sqlee);
}
}

}

public String getServerData(String code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
package org.mariadb.jdbc.internal.util.constant;

public final class Version {
public static final String version = "1.6.0-SNAPSHOT";
public static final String version = "1.5.5";
public static final int majorVersion = 1;
public static final int minorVersion = 6;
public static final int patchVersion = 0;
public static final String qualifier = "SNAPSHOT";
public static final int minorVersion = 5;
public static final int patchVersion = 5;
public static final String qualifier = "";

}

0 comments on commit ab3a83e

Please sign in to comment.