{"record":{"id":"933b8efadd8e398c","repo":"pentaho/pentaho-kettle","slug":"error","errorCode":null,"errorMessage":"Error : ","messagePattern":"Error : ","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/BaseDatabaseMeta.java","lineNumber":2199,"sourceCode":"        case ValueMetaInterface.TYPE_STRING:\n          String string = valueMeta.getString( valueData );\n          // Have the database dialect do the quoting.\n          // This also adds the single quotes around the string (thanks to PostgreSQL)\n          //\n          string = quoteSQLString( string );\n          ins.append( string );\n          break;\n        case ValueMetaInterface.TYPE_DATE:\n          Date date = valueMeta.getDate( valueData );\n\n          if ( Utils.isEmpty( dateFormat ) ) {\n            ins.append( \"'\" + valueMeta.getString( valueData ) + \"'\" );\n          } else {\n            try {\n              java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat( dateFormat );\n              ins.append( \"'\" + formatter.format( date ) + \"'\" );\n            } catch ( Exception e ) {\n              throw new KettleValueException( \"Error : \", e );\n            }\n          }\n          break;\n        default:\n          ins.append( valueMeta.getString( valueData ) );\n          break;\n      }\n    }\n\n    return ins.toString();\n  }\n\n  protected String getFieldnameProtector() {\n    return FIELDNAME_PROTECTOR;\n  }\n\n  /**\n   * Sanitize a string for usage as a field name","sourceCodeStart":2181,"sourceCodeEnd":2217,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/BaseDatabaseMeta.java#L2181-L2217","documentation":"While building a SQL literal for a Date value, the code formats the java.util.Date with a SimpleDateFormat using the database's date format string. If formatting fails (Exception from SimpleDateFormat, typically an invalid pattern), it throws a KettleValueException with the bare prefix 'Error : ' and the cause attached.","triggerScenarios":"getSqlValue-style SQL literal construction where valueMeta is a Date and new SimpleDateFormat(dateFormat).format(date) throws — the database dialect's date format pattern is invalid (bad pattern characters) or the format string is empty/mangled.","commonSituations":"Custom database dialects or overridden dateFormat values containing invalid pattern letters; locale-related pattern issues; misconfigured database type detection selecting the wrong dialect's format string.","solutions":["Inspect the exception's cause (getCause) to see the actual SimpleDateFormat error and fix the offending dateFormat pattern.","Use a dialect-appropriate date format (e.g. 'yyyy-MM-dd HH:mm:ss') or the database's TO_DATE/CAST syntax.","Ensure the correct DatabaseMeta dialect is detected so its dateFormat field is valid.","Catch KettleValueException and log the dateFormat string in use to identify the bad pattern."],"exampleFix":"// before\nString dateFormat = \"yyyy-mm-dd hh:mm:ss.SSS\"; // 'mm' is minutes in date part, likely intended months\n\n// after\nString dateFormat = \"yyyy-MM-dd HH:mm:ss.SSS\";","handlingStrategy":"validation","validationCode":"try {\n  new java.text.SimpleDateFormat(dateFormat); // fail fast on invalid pattern\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\"Database dialect dateFormat is invalid: \" + dateFormat, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  String sql = buildInsertSql(valueMeta, valueData);\n} catch (KettleValueException e) {\n  LOG.error(\"Date literal formatting failed; check dateFormat pattern\", e);\n}","preventionTips":["Validate dialect dateFormat patterns with SimpleDateFormat at startup.","Use a standard pattern like yyyy-MM-dd HH:mm:ss for custom dialects.","Check the cause (getCause) — the message 'Error : ' itself carries no detail."],"tags":["database","sql","date-formatting","poor-message"],"backgroundTag":"invalid-date-format","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}