Skip to content

Commit e7ca4e3

Browse files
OFBIZ-13413 - Fix JdbcSQLDataException during startup caused by null table parameter in getPrimaryKeys (#1229)
Fixed: Here is the fix to remove the null parameter attempt entirely and use the "%" wildcard as our primary optimization path. This preserves performance for databases that accept wildcards, while allowing strict databases to silently return zero rows and gracefully fall back to compliant table-by-table iteration without polluting the logs with stack traces. While some database drivers tolerate a null argument here, the official JDBC specification mandates that this parameter must be an exact table name. Because H2 enforces this specification strictly, it throws an exception before OFBiz eventually catches it and falls back to querying tables individually. This commit will fix the following error/warnings returned on the console: 2026-05-17 23:51:35,252 |OFBiz-batch-2 |DatabaseUtil |I| Getting Column Info From Database 2026-05-17 23:51:35,252 |OFBiz-batch-1 |DatabaseUtil |I| Error getting primary key info from database with null tableName, will try other means: org.h2.jdbc.JdbcSQLDataException: Invalid value "null" for parameter "table" [90008-240] 2026-05-17 23:51:35,252 |OFBiz-batch-1 |DatabaseUtil |I| Searching in 7 tables for primary key fields ... 2026-05-17 23:51:35,252 |OFBiz-batch-1 |DatabaseUtil |I| Reviewed 9 primary key fields from database. 2026-05-17 23:51:35,253 |OFBiz-batch-3 |DatabaseUtil |I| Error getting primary key info from database with null tableName, will try other means: org.h2.jdbc.JdbcSQLDataException: Invalid value "null" for parameter "table" [90008-240] 2026-05-17 23:51:35,253 |OFBiz-batch-3 |DatabaseUtil |I| Searching in 6 tables for primary key fields ... 2026-05-17 23:51:35,253 |OFBiz-batch-3 |DatabaseUtil |I| Reviewed 8 primary key fields from database. 2026-05-17 23:51:35,268 |OFBiz-batch-2 |DatabaseUtil |I| Error getting primary key info from database with null tableName, will try other means: org.h2.jdbc.JdbcSQLDataException: Invalid value "null" for parameter "table" [90008-240] 2026-05-17 23:51:35,268 |OFBiz-batch-2 |DatabaseUtil |I| Searching in 870 tables for primary key fields ... 2026-05-17 23:51:35,274 |OFBiz-batch-2 |DatabaseUtil |I| Reviewed 1697 primary key fields from database.
1 parent 28a54ec commit e7ca4e3

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,20 +1228,12 @@ private Map<String, Map<String, ColumnCheckInfo>> getColumnInfo(Set<String> tabl
12281228

12291229
// first try getting all at once for databases that support that and can generally perform WAY better, if that fails get one at
12301230
// a time so it will at least work
1231-
try (ResultSet rsPks = dbData.getPrimaryKeys(null, lookupSchemaName, null)) {
1231+
try (ResultSet rsPks = dbData.getPrimaryKeys(null, lookupSchemaName, "%")) {
12321232
pkCount += checkPrimaryKeyInfo(rsPks, lookupSchemaName, needsUpperCase, colInfo, messages);
12331233
} catch (Exception e1) {
1234-
Debug.logInfo("Error getting primary key info from database with null tableName, will try other means: " + e1.toString(),
1234+
Debug.logInfo("Error getting primary key info from database with % tableName, will try other means: " + e1.toString(),
12351235
MODULE);
12361236
}
1237-
if (pkCount == 0) {
1238-
try (ResultSet rsPks = dbData.getPrimaryKeys(null, lookupSchemaName, "%")) {
1239-
pkCount += checkPrimaryKeyInfo(rsPks, lookupSchemaName, needsUpperCase, colInfo, messages);
1240-
} catch (Exception e1) {
1241-
Debug.logInfo("Error getting primary key info from database with % tableName, will try other means: " + e1.toString(),
1242-
MODULE);
1243-
}
1244-
}
12451237
if (pkCount == 0) {
12461238
Debug.logInfo("Searching in " + tableNames.size() + " tables for primary key fields ...", MODULE);
12471239
for (String curTable : tableNames) {

0 commit comments

Comments
 (0)