Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-12930

DB2TableManager looks into all schemas during table existence check

XMLWordPrintable

      This may border with a feature request.

      Scenario:

      When user configures a JDBC cache store, with IBM DB2 as a backing database, but doesn't specify a schema name, the DB2TableManager#tableExists(Connection connection, TableName tableName) call returns true even if the caching table is present in different schema.

      In effect the caching table in the current schema is not created and attempt to cache anything fails with SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=dballo14.ispn_entry_cbnc_ear_a_war, DRIVER=4.25.23 error (i.e. table doesn't exist).

      For reproduction steps, see JBEAP-21362.

      The code that checks the existence of a table looks like this:

               DatabaseMetaData metaData = connection.getMetaData();
               String schemaPattern = tableName.getSchema(); // <- this is null
               rs = metaData.getTables(null, schemaPattern, tableName.getName(), new String[]{"TABLE"});
      

      Suggested improvement:

      If tableName.getSchema() returns null, the current schema name should be determined and supplied. On DB2 current schema can be obtained with SQL query "VALUES CURRENT SCHEMA".

            thofman Tomas Hofman
            thofman Tomas Hofman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: