Handle DB2 on the AS/400 (iSeries) and DB2 Server for VM and VSE

DB2 connections to the AS/400 report incorrectly back as DB2 z/OS. The
current AS/400 reports Database Product Name as "DB2 UDB for AS/400".
Database Product Version has three possible return values based on
product used:
JTOpen reports "07.01.0000 V7R1m0".
Native Driver reports "V7R1M0".
PRDID reports "QSQ07010"

http://www-01.ibm.com/support/knowledgecenter/SSEPEK_10.0.0/com.ibm.db2z10.doc.java/src/tpc/imjcc_c0053013.dita

Also added code to handle DB2 Server for VM and VSE.  This code should
handle the different DB2 Versions.
Spring Community Contributor
This commit is contained in:
Coby Pritchard
2016-02-26 22:23:32 -06:00
committed by Michael Minella
parent a6590c8c54
commit fcf6e94248
3 changed files with 42 additions and 4 deletions

View File

@@ -16,7 +16,9 @@
package org.springframework.batch.item.database.support;
import static org.springframework.batch.support.DatabaseType.DB2;
import static org.springframework.batch.support.DatabaseType.DB2VSE;
import static org.springframework.batch.support.DatabaseType.DB2ZOS;
import static org.springframework.batch.support.DatabaseType.DB2AS400;
import static org.springframework.batch.support.DatabaseType.DERBY;
import static org.springframework.batch.support.DatabaseType.H2;
import static org.springframework.batch.support.DatabaseType.HSQL;
@@ -70,7 +72,9 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean<PagingQuer
{
providers.put(DB2, new Db2PagingQueryProvider());
providers.put(DB2VSE, new Db2PagingQueryProvider());
providers.put(DB2ZOS, new Db2PagingQueryProvider());
providers.put(DB2AS400, new Db2PagingQueryProvider());
providers.put(DERBY,new DerbyPagingQueryProvider());
providers.put(HSQL,new HsqlPagingQueryProvider());
providers.put(H2,new H2PagingQueryProvider());

View File

@@ -37,7 +37,9 @@ public enum DatabaseType {
DERBY("Apache Derby"),
DB2("DB2"),
DB2VSE("DB2VSE"),
DB2ZOS("DB2ZOS"),
DB2AS400("DB2AS400"),
HSQL("HSQL Database Engine"),
SQLSERVER("Microsoft SQL Server"),
MYSQL("MySQL"),
@@ -94,12 +96,19 @@ public enum DatabaseType {
public static DatabaseType fromMetaData(DataSource dataSource) throws MetaDataAccessException {
String databaseProductName =
JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductName").toString();
if (StringUtils.hasText(databaseProductName) && !databaseProductName.equals("DB2/Linux") && databaseProductName.startsWith("DB2")) {
if (StringUtils.hasText(databaseProductName) && databaseProductName.startsWith("DB2")) {
String databaseProductVersion =
JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductVersion").toString();
if (!databaseProductVersion.startsWith("SQL")) {
if (databaseProductVersion.startsWith("ARI")) {
databaseProductName = "DB2VSE";
}
else if (databaseProductVersion.startsWith("DSN")) {
databaseProductName = "DB2ZOS";
}
else if (databaseProductName.indexOf("AS") != -1 && (databaseProductVersion.startsWith("QSQ") ||
databaseProductVersion.substring(databaseProductVersion.indexOf('V')).matches("V\\dR\\d[mM]\\d"))) {
databaseProductName = "DB2AS400";
}
else {
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
}