Skip to content

Instantly share code, notes, and snippets.

@idler
Created June 8, 2017 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idler/bb1c9078ccc0f06ef3a8565a7a91f1bb to your computer and use it in GitHub Desktop.
Save idler/bb1c9078ccc0f06ef3a8565a7a91f1bb to your computer and use it in GitHub Desktop.
java fuck
private PreparedStatement getPreparedCategoryQuery() {
if (categoryPreparedQuery == null) {
try {
categoryPreparedQuery = dbconn.prepareStatement("INSERT INTO category (code) values(?)");
} catch (SQLException e) {
e.printStackTrace();
}
}
try {
categoryPreparedQuery.clearParameters();
categoryPreparedQuery.clearWarnings();
} catch (SQLException e) {
e.printStackTrace();
}
return categoryPreparedQuery;
}
public void createCategory(String code) {
LOG.info("CREATING Category with code = " + code);
PreparedStatement st = getPreparedCategoryQuery();
try {
st.setString(1, code);
boolean result = st.execute();
if (!result) {
LOG.error("FAILED ADD CATEGORY with code = " + code);
LOG.error(st.getWarnings());
}else{
LOG.info("success");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment