mirror of https://github.com/apache/openjpa.git
Initialize Database Prodcut/Vendor name to empty string to avoid NPE
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@675387 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7a9063146
commit
89e7531398
|
@ -72,8 +72,8 @@ public class DB2Dictionary
|
||||||
protected static final String useKeepExclusiveLockClause
|
protected static final String useKeepExclusiveLockClause
|
||||||
= "USE AND KEEP EXCLUSIVE LOCKS";
|
= "USE AND KEEP EXCLUSIVE LOCKS";
|
||||||
protected static final String forReadOnlyClause = "FOR READ ONLY";
|
protected static final String forReadOnlyClause = "FOR READ ONLY";
|
||||||
protected String databaseProductName = null;
|
protected String databaseProductName = "";
|
||||||
protected String databaseProductVersion = null;
|
protected String databaseProductVersion = "";
|
||||||
protected int maj = 0;
|
protected int maj = 0;
|
||||||
protected int min = 0;
|
protected int min = 0;
|
||||||
|
|
||||||
|
@ -242,8 +242,8 @@ public class DB2Dictionary
|
||||||
super.connectedConfiguration(conn);
|
super.connectedConfiguration(conn);
|
||||||
|
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
databaseProductName = metaData.getDatabaseProductName();
|
databaseProductName = nullSafe(metaData.getDatabaseProductName());
|
||||||
databaseProductVersion = metaData.getDatabaseProductVersion();
|
databaseProductVersion = nullSafe(metaData.getDatabaseProductVersion());
|
||||||
|
|
||||||
// Determine the type of DB2 database
|
// Determine the type of DB2 database
|
||||||
// First check for AS/400
|
// First check for AS/400
|
||||||
|
@ -384,51 +384,32 @@ public class DB2Dictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDB2UDBV82OrLater() {
|
public boolean isDB2UDBV82OrLater() {
|
||||||
boolean match = false;
|
return (databaseProductVersion.indexOf("SQL") != -1
|
||||||
if (databaseProductName != null &&
|
|| databaseProductName.indexOf("DB2/") != -1)
|
||||||
(databaseProductVersion.indexOf("SQL") != -1
|
&& ((maj == 8 && min >= 2) || (maj >= 9));
|
||||||
|| databaseProductName.indexOf("DB2/") != -1)
|
|
||||||
&& ((maj == 8 && min >= 2) || (maj >= 9)))
|
|
||||||
match = true;
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDB2ZOSV8xOrLater() {
|
public boolean isDB2ZOSV8xOrLater() {
|
||||||
boolean match = false;
|
return (databaseProductVersion.indexOf("DSN") != -1
|
||||||
if (databaseProductName != null &&
|
|| databaseProductName.indexOf("DB2/") == -1)
|
||||||
(databaseProductVersion.indexOf("DSN") != -1
|
&& maj >= 8;
|
||||||
|| databaseProductName.indexOf("DB2/") == -1)
|
|
||||||
&& maj >= 8)
|
|
||||||
match = true;
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDB2ISeriesV5R3OrEarlier() {
|
public boolean isDB2ISeriesV5R3OrEarlier() {
|
||||||
boolean match = false;
|
return (databaseProductName.indexOf("AS") != -1
|
||||||
if (databaseProductName != null &&
|
&& ((maj == 5 && min <=3) || maj < 5));
|
||||||
databaseProductName.indexOf("AS") != -1
|
|
||||||
&& ((maj == 5 && min <=3) || maj < 5))
|
|
||||||
match = true;
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDB2ISeriesV5R4OrLater() {
|
public boolean isDB2ISeriesV5R4OrLater() {
|
||||||
boolean match = false;
|
return databaseProductName.indexOf("AS") != -1
|
||||||
if (databaseProductName != null &&
|
&& (maj >=6 || (maj == 5 && min >=4));
|
||||||
databaseProductName.indexOf("AS") != -1
|
|
||||||
&& (maj >=6 || (maj == 5 && min >=4)))
|
|
||||||
match = true;
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDB2UDBV81OrEarlier() {
|
public boolean isDB2UDBV81OrEarlier() {
|
||||||
boolean match = false;
|
return (databaseProductVersion.indexOf("SQL") != -1
|
||||||
if (databaseProductName != null &&
|
|| databaseProductName.indexOf("DB2/") != -1)
|
||||||
(databaseProductVersion.indexOf("SQL") != -1
|
&& ((maj == 8 && min <= 1) || maj < 8);
|
||||||
|| databaseProductName.indexOf("DB2/") != -1) &&
|
|
||||||
((maj == 8 && min <= 1) || maj < 8))
|
|
||||||
match = true;
|
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the version Major/Minor for the ISeries
|
/** Get the version Major/Minor for the ISeries
|
||||||
|
@ -456,8 +437,7 @@ public class DB2Dictionary
|
||||||
String s2 = stringtokenizer.nextToken();
|
String s2 = stringtokenizer.nextToken();
|
||||||
min = Integer.parseInt(s2);
|
min = Integer.parseInt(s2);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
index = databaseProductVersion.indexOf('0');
|
index = databaseProductVersion.indexOf('0');
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
String s = databaseProductVersion.substring(index);
|
String s = databaseProductVersion.substring(index);
|
||||||
|
@ -844,4 +824,8 @@ public class DB2Dictionary
|
||||||
idx.addColumn(pkColumn);
|
idx.addColumn(pkColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String nullSafe(String s) {
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue