Skip to content

Output a version of MySQL Connector/J. #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 20, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public ConfigDiff transaction(ConfigSource config,
Schema schema;
try (JdbcInputConnection con = newConnection(task)) {
// TODO incremental_columns is not set => get primary key
con.showDriverVersion();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above (// TODO incremental_columns ...) should be above the following line (schema = setupTask(con, task);).

Copy link
Member Author

@hiroyuki-sato hiroyuki-sato Jun 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move comment to propper place.

schema = setupTask(con, task);
} catch (SQLException ex) {
throw Throwables.propagate(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Locale;
import java.util.Set;

import org.embulk.config.ConfigException;
Expand Down Expand Up @@ -386,4 +387,13 @@ private Set<String> getColumnNames(String tableName) throws SQLException
return columnNamesBuilder.build();
}
}

public void showDriverVersion(){
try {
DatabaseMetaData meta = connection.getMetaData();
logger.info(String.format(Locale.ENGLISH,"Using JDBC Driver %s",meta.getDriverVersion()));
} catch( SQLException e ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to catch SQLException because Connection#getMetaData#getDriverVersion doesn't throw an exception normally.
If thrown, we can't access database after all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw the exception instead of catch.

logger.warn(String.format(Locale.ENGLISH,"Can't get JDBC Driver version. Reason: %s",e.toString()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,16 @@ public void compareTimeZone() throws SQLException
timeZoneComparison.compareTimeZone();
}

//
//
// The MySQL Connector/J 5.1.35 introduce new option `Current MySQL Connect`.
// It has incompatibility behavior current version and 5.1.35.
//
// This method announces users about this change before the update driver version.
//
@Override
public void showDriverVersion() {
super.showDriverVersion();
logger.warn("This plugin will update MySQL Connector/J version on next release...");
}
}