Permalink
Browse files

Adding null check for username being null.

The username is usually not null, but it  could be for some embedded databases.

Always setting generatedKeysColumnNameArraySupported to false when getGeneratedKeysSupported is false, since it can't be supported without having generated keys supported. This change only affects logging messages.

Issue: SPR-9006
  • Loading branch information...
1 parent 21aed04 commit 66012b951e6fc1f2c8cd9025381f2ae6851bd91c @trisberg committed Feb 3, 2012
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,8 +181,13 @@ public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQL
setGeneratedKeysColumnNameArraySupported(false);
}
else {
- logger.debug("GeneratedKeysColumnNameArray is supported for " + databaseProductName);
- setGeneratedKeysColumnNameArraySupported(true);
+ if (isGetGeneratedKeysSupported()) {
+ logger.debug("GeneratedKeysColumnNameArray is supported for " + databaseProductName);
+ setGeneratedKeysColumnNameArraySupported(true);
+ }
+ else {
+ setGeneratedKeysColumnNameArraySupported(false);
+ }
}
}
catch (SQLException se) {
@@ -307,7 +312,7 @@ private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, St
tmd.setTableName(tables.getString("TABLE_NAME"));
tmd.setType(tables.getString("TABLE_TYPE"));
if (tmd.getSchemaName() == null) {
- tableMeta.put(userName.toUpperCase(), tmd);
+ tableMeta.put(userName != null ? userName.toUpperCase() : "", tmd);
}
else {
tableMeta.put(tmd.getSchemaName().toUpperCase(), tmd);
@@ -335,7 +340,7 @@ private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, St
if (schemaName == null) {
tmd = tableMeta.get(getDefaultSchema());
if (tmd == null) {
- tmd = tableMeta.get(userName.toUpperCase());
+ tmd = tableMeta.get(userName != null ? userName.toUpperCase() : "");
}
if (tmd == null) {
tmd = tableMeta.get("PUBLIC");

0 comments on commit 66012b9

Please sign in to comment.