OPENJPA-1540 Modified Informix dictionary to detect non-delimited identifier case for the Informix driver. Also added missing method override.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@917727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2010-03-01 21:29:01 +00:00
parent 18a1a04c77
commit 208f5388ce
2 changed files with 40 additions and 6 deletions

View File

@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Set; import java.util.Set;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType; import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
import org.apache.openjpa.jdbc.kernel.exps.FilterValue; import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
import org.apache.openjpa.jdbc.schema.Column; import org.apache.openjpa.jdbc.schema.Column;
@ -167,11 +168,13 @@ public class InformixDictionary
{ {
driverVendor = VENDOR_IBM; driverVendor = VENDOR_IBM;
useJCC = true; useJCC = true;
try { setIdentifierCase(meta);
if (meta.storesLowerCaseIdentifiers()) }
schemaCase = SCHEMA_CASE_LOWER; else if (driverName.equals("IBM Informix JDBC Driver for IBM Informix Dynamic Server")) {
} catch (SQLException e) {} setIdentifierCase(meta);
} else if ("Informix".equalsIgnoreCase(driverName)) driverVendor = VENDOR_IBM;
}
else if ("Informix".equalsIgnoreCase(driverName))
driverVendor = VENDOR_DATADIRECT; driverVendor = VENDOR_DATADIRECT;
else else
driverVendor = VENDOR_OTHER; driverVendor = VENDOR_OTHER;
@ -187,10 +190,39 @@ public class InformixDictionary
} }
} }
private void setIdentifierCase(DatabaseMetaData meta) {
try {
// lower case identifiers is the default for the JCC and newer
// Informix JDBC drivers
if (meta.storesLowerCaseIdentifiers()) {
schemaCase = SCHEMA_CASE_LOWER;
}
else if (meta.storesMixedCaseIdentifiers()) {
schemaCase = SCHEMA_CASE_PRESERVE;
}
// otherwise, use the default (upper)
}
catch (SQLException e) {
getLog().warn("cannot-determine-identifier-base-case");
if (getLog().isTraceEnabled()) {
getLog().trace(e.toString(), e);
}
}
}
@Override @Override
public Column[] getColumns(DatabaseMetaData meta, String catalog, public Column[] getColumns(DatabaseMetaData meta, String catalog,
String schemaName, String tableName, String columnName, Connection conn) String schemaName, String tableName, String columnName, Connection conn)
throws SQLException { throws SQLException {
return getColumns(meta, DBIdentifier.newCatalog(catalog),
DBIdentifier.newSchema(schemaName),DBIdentifier.newTable(tableName),
DBIdentifier.newColumn(columnName), conn);
}
@Override
public Column[] getColumns(DatabaseMetaData meta, DBIdentifier catalog,
DBIdentifier schemaName, DBIdentifier tableName, DBIdentifier columnName, Connection conn)
throws SQLException {
Column[] cols = super.getColumns(meta, catalog, schemaName, tableName, Column[] cols = super.getColumns(meta, catalog, schemaName, tableName,
columnName, conn); columnName, conn);

View File

@ -205,3 +205,5 @@ cannot-determine-identifier-case: Unable to determine the case to use for delimi
unknown-delim-support: Unable to determine whether delimited identifiers are supported. \ unknown-delim-support: Unable to determine whether delimited identifiers are supported. \
The use of delimiters will not be supported. The use of delimiters will not be supported.
can_not_get_current_schema: Unable to get current schema. SQLException message is "{0}". can_not_get_current_schema: Unable to get current schema. SQLException message is "{0}".
cannot-determine-identifier-base-case: Unable to determine the case to use for \
identifiers. The default value of "{0}" will be used.