Skip to content
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

Add DatabaseType POSTGRES for the product name EnterpriseDB #4627

Closed
sheelprabhakar opened this issue Jun 27, 2024 · 0 comments
Closed

Add DatabaseType POSTGRES for the product name EnterpriseDB #4627

sheelprabhakar opened this issue Jun 27, 2024 · 0 comments
Labels
for: backport-to-5.1.x Issues that will be back-ported to the 5.1.x line in: core type: feature
Milestone

Comments

@sheelprabhakar
Copy link

sheelprabhakar commented Jun 27, 2024

In version 5.1.1, getting an exception for PostGres Enterprise Database version (EDB JDBC Connector), when using com.edb.Driver for connection
java.lang.IllegalArgumentException: DatabaseType not found for product name: [EnterpriseDB]

A possible solution can be by adding one condition in the method fromMetaData of class DatabaseType for EnterpriseDB

    public static DatabaseType fromMetaData(DataSource dataSource) throws MetaDataAccessException {
        String databaseProductName = (String) JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getDatabaseProductName);
        if (StringUtils.hasText(databaseProductName) && databaseProductName.startsWith("DB2")) {
            String databaseProductVersion = (String)JdbcUtils.extractDatabaseMetaData(dataSource, DatabaseMetaData::getDatabaseProductVersion);
            if (databaseProductVersion.startsWith("ARI")) {
                databaseProductName = "DB2VSE";
            } else if (databaseProductVersion.startsWith("DSN")) {
                databaseProductName = "DB2ZOS";
            } else if (!databaseProductName.contains("AS") || !databaseProductVersion.startsWith("QSQ") && !databaseProductVersion.substring(databaseProductVersion.indexOf(86)).matches("V\\dR\\d[mM]\\d")) {
                databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
            } else {
                databaseProductName = "DB2AS400";
            }
        }else if(StringUtils.hasText(databaseProductName) && databaseProductName.equals("EnterpriseDB")) {
            databaseProductName = "PostgreSQL";
        }else {
            databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
        }

        return fromProductName(databaseProductName);
    }
@sheelprabhakar sheelprabhakar added status: waiting-for-triage Issues that we did not analyse yet type: feature labels Jun 27, 2024
sheelprabhakar pushed a commit to sheelprabhakar/spring-batch that referenced this issue Jun 29, 2024
…ojects#4627

Added one test

Since PostGres EnterpriseDB driver and test container is not available, not written integration test
sheelprabhakar pushed a commit to sheelprabhakar/spring-batch that referenced this issue Jun 29, 2024
…ojects#4627

Added one test

Since PostGres EnterpriseDB driver and test container is not available, not written integration test
@fmbenhassine fmbenhassine added in: core for: backport-to-5.1.x Issues that will be back-ported to the 5.1.x line and removed status: waiting-for-triage Issues that we did not analyse yet labels Sep 19, 2024
@fmbenhassine fmbenhassine added this to the 5.2.0-M2 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-5.1.x Issues that will be back-ported to the 5.1.x line in: core type: feature
Projects
None yet
Development

No branches or pull requests

2 participants