mirror of https://github.com/apache/openjpa.git
OPENJPA-644 Merge 675806 from trunk to 1.0.x
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.0.x@675811 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
722e07f72b
commit
15715ab0db
|
@ -68,8 +68,8 @@ public class DB2Dictionary
|
|||
private static final String useKeepExclusiveLockClause
|
||||
= "USE AND KEEP EXCLUSIVE LOCKS";
|
||||
private static final String forReadOnlyClause = "FOR READ ONLY";
|
||||
protected String databaseProductName = null;
|
||||
protected String databaseProductVersion = null;
|
||||
protected String databaseProductName = "";
|
||||
protected String databaseProductVersion = "";
|
||||
protected int maj = 0;
|
||||
protected int min = 0;
|
||||
|
||||
|
@ -216,8 +216,8 @@ public class DB2Dictionary
|
|||
super.connectedConfiguration(conn);
|
||||
|
||||
DatabaseMetaData metaData = conn.getMetaData();
|
||||
databaseProductName = metaData.getDatabaseProductName();
|
||||
databaseProductVersion = metaData.getDatabaseProductVersion();
|
||||
databaseProductName = nullSafe(metaData.getDatabaseProductName());
|
||||
databaseProductVersion = nullSafe(metaData.getDatabaseProductVersion());
|
||||
|
||||
// Determine the type of DB2 database
|
||||
// First check for AS/400
|
||||
|
@ -358,51 +358,32 @@ public class DB2Dictionary
|
|||
}
|
||||
|
||||
public boolean isDB2UDBV82OrLater() {
|
||||
boolean match = false;
|
||||
if (databaseProductName != null &&
|
||||
(databaseProductVersion.indexOf("SQL") != -1
|
||||
|| databaseProductName.indexOf("DB2/") != -1)
|
||||
&& ((maj == 8 && min >= 2) || (maj >= 9)))
|
||||
match = true;
|
||||
return match;
|
||||
return (databaseProductVersion.indexOf("SQL") != -1
|
||||
|| databaseProductName.indexOf("DB2/") != -1)
|
||||
&& ((maj == 8 && min >= 2) || (maj >= 9));
|
||||
}
|
||||
|
||||
public boolean isDB2ZOSV8xOrLater() {
|
||||
boolean match = false;
|
||||
if (databaseProductName != null &&
|
||||
(databaseProductVersion.indexOf("DSN") != -1
|
||||
|| databaseProductName.indexOf("DB2/") == -1)
|
||||
&& maj >= 8)
|
||||
match = true;
|
||||
return match;
|
||||
return (databaseProductVersion.indexOf("DSN") != -1
|
||||
|| databaseProductName.indexOf("DB2/") == -1)
|
||||
&& maj >= 8;
|
||||
|
||||
}
|
||||
|
||||
public boolean isDB2ISeriesV5R3OrEarlier() {
|
||||
boolean match = false;
|
||||
if (databaseProductName != null &&
|
||||
databaseProductName.indexOf("AS") != -1
|
||||
&& ((maj == 5 && min <=3) || maj < 5))
|
||||
match = true;
|
||||
return match;
|
||||
return (databaseProductName.indexOf("AS") != -1
|
||||
&& ((maj == 5 && min <=3) || maj < 5));
|
||||
}
|
||||
|
||||
public boolean isDB2ISeriesV5R4OrLater() {
|
||||
boolean match = false;
|
||||
if (databaseProductName != null &&
|
||||
databaseProductName.indexOf("AS") != -1
|
||||
&& (maj >=6 || (maj == 5 && min >=4)))
|
||||
match = true;
|
||||
return match;
|
||||
return databaseProductName.indexOf("AS") != -1
|
||||
&& (maj >=6 || (maj == 5 && min >=4));
|
||||
}
|
||||
|
||||
public boolean isDB2UDBV81OrEarlier() {
|
||||
boolean match = false;
|
||||
if (databaseProductName != null &&
|
||||
(databaseProductVersion.indexOf("SQL") != -1
|
||||
|| databaseProductName.indexOf("DB2/") != -1) &&
|
||||
((maj == 8 && min <= 1) || maj < 8))
|
||||
match = true;
|
||||
return match;
|
||||
return (databaseProductVersion.indexOf("SQL") != -1
|
||||
|| databaseProductName.indexOf("DB2/") != -1)
|
||||
&& ((maj == 8 && min <= 1) || maj < 8);
|
||||
}
|
||||
|
||||
/** Get the version Major/Minor for the ISeries
|
||||
|
@ -413,17 +394,37 @@ public class DB2Dictionary
|
|||
// ISeries DB2 UDB for AS/400
|
||||
// (Native) V5R4M0
|
||||
if (databaseProductName.indexOf("AS") != -1) {
|
||||
String s = databaseProductVersion.substring(databaseProductVersion
|
||||
.indexOf('V'));
|
||||
s = s.toUpperCase();
|
||||
// default to V5R4
|
||||
maj = 5;
|
||||
min = 4;
|
||||
int index = databaseProductVersion.indexOf('V');
|
||||
if (index != -1) {
|
||||
String s = databaseProductVersion.substring(index);
|
||||
s = s.toUpperCase();
|
||||
|
||||
StringTokenizer stringtokenizer = new StringTokenizer(s, "VRM"
|
||||
, false);
|
||||
if (stringtokenizer.countTokens() == 3) {
|
||||
String s1 = stringtokenizer.nextToken();
|
||||
maj = Integer.parseInt(s1);
|
||||
String s2 = stringtokenizer.nextToken();
|
||||
min = Integer.parseInt(s2);
|
||||
StringTokenizer stringtokenizer = new StringTokenizer(s, "VRM"
|
||||
, false);
|
||||
if (stringtokenizer.countTokens() == 3) {
|
||||
String s1 = stringtokenizer.nextToken();
|
||||
maj = Integer.parseInt(s1);
|
||||
String s2 = stringtokenizer.nextToken();
|
||||
min = Integer.parseInt(s2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
index = databaseProductVersion.indexOf('0');
|
||||
if (index != -1) {
|
||||
String s = databaseProductVersion.substring(index);
|
||||
s = s.toUpperCase();
|
||||
StringTokenizer stringtokenizer = new StringTokenizer(s, "0"
|
||||
, false);
|
||||
if (stringtokenizer.countTokens() == 2) {
|
||||
String s1 = stringtokenizer.nextToken();
|
||||
maj = Integer.parseInt(s1);
|
||||
String s2 = stringtokenizer.nextToken();
|
||||
min = Integer.parseInt(s2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -772,4 +773,8 @@ public class DB2Dictionary
|
|||
idx.addColumn(pkColumn);
|
||||
}
|
||||
}
|
||||
|
||||
String nullSafe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue