Skip to content

Instantly share code, notes, and snippets.

@bryder
Created December 18, 2016 01:47
Show Gist options
  • Save bryder/3d119c84e4a5581eb620fc6be718eb39 to your computer and use it in GitHub Desktop.
Save bryder/3d119c84e4a5581eb620fc6be718eb39 to your computer and use it in GitHub Desktop.
Prepare a sql statement in java and print it as a string
List<Object> params = Lists.newArrayList();
if (logger.isDebugEnabled()){
try {
PreparedStatement ps = this.getConnection().prepareStatement(q);
for (int i=0 ; i < params.size(); i++){
ps.setObject(i+1, params.get(i));
}
logger.debug("Build this {}", ps);
} catch (Exception e) {
logger.debug("Problem getting prepared statement{}", e);
}
}
// works in a standard dso.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment