Skip to content

Instantly share code, notes, and snippets.

@zdenekoklestek
Created December 4, 2015 13:36
Show Gist options
  • Save zdenekoklestek/0df493f76e5f86aa2d3e to your computer and use it in GitHub Desktop.
Save zdenekoklestek/0df493f76e5f86aa2d3e to your computer and use it in GitHub Desktop.
Connection connection = null;
CallableStatement call = null;
try {
connection = dataSource.getConnection();
call = connection.prepareCall("{? = call get_entity2 (?)}");
call.registerOutParameter(1, Types.VARCHAR);
call.setString(2, tableName);
call.executeUpdate();
return call.getString(1);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if(call != null) {
try {
call.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
if(connection != null) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment