Skip to content

Commit

Permalink
Merge pull request #3141 from Cousjava/PAYARA-2912-jbatch-postgres
Browse files Browse the repository at this point in the history
PAYARA-2912 JBatch not working with PostgreSQL
  • Loading branch information
Pandrex247 authored Sep 12, 2018
2 parents dbd4dc4 + 02348e0 commit a47ebb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ private List<Long> queryToGetInstanceIDs(String query, String parameter1, String
String columnID = "jobinstanceid";
try (Connection connection = dataSource.getConnection()) {
try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setString(1, parameter1);
preparedStatement.setString(2, parameter2);
preparedStatement.setInt(1, Integer.parseInt(parameter1));
preparedStatement.setInt(2, Integer.parseInt(parameter2));

try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,25 @@ public void createCheckpointData(CheckpointDataKey key, CheckpointData value) {
logger.exiting(CLASSNAME, "createCheckpointData");
}

/**
* Set the default schema to the username obtained from the connection based
* on the datasource
* */

public String setDefaultSchema() throws SQLException {
/**
* Set the default schema to the username obtained from the connection based on the datasource
*
* @return the name of the default database schema
* @throws SQLException
*/
public String setDefaultSchema() throws SQLException {
logger.finest("Entering setDefaultSchema");

logger.finest("Java EE mode, getting connection from data source");
try (Connection connection = dataSource.getConnection()) {

DatabaseMetaData dbmd = connection.getMetaData();
schema = dbmd.getUserName();
if (dbmd.getDatabaseProductName().toLowerCase().contains("mysql")) {
schema = "test";
}
if (dbmd.getDatabaseProductName().toLowerCase().contains("mysql")) {
schema = "test";
} else if (dbmd.getDatabaseProductName().toLowerCase().contains("postgres")) {
schema = "public";
}

} catch (SQLException e) {
logger.severe(e.getLocalizedMessage());
Expand Down

0 comments on commit a47ebb6

Please sign in to comment.