Menu

Using HA-JDBC for DB-metadata extraction, problems upgrading from 2.0.x to 3.0

Help
2017-07-31
2017-07-31
  • Héctor Cadavid

    Héctor Cadavid - 2017-07-31

    Dear friends,

    I'm trying to upgrande a 8-years legacy application that worked with some HA-JDBC 2.0.x classes for database meta-data extraction. Unfortunately, such version is no longer available in the official Maven repository, and the new API have changed a lot!... I haven't found any documentation so I don't have any clue how to update the following code, intented to identify if a given column name, in a given table, is a unique key:

    DatabaseMetaDataSupport metaSup = new DatabaseMetaDataSupport(dbMetaData,new OracleDialect()); <- Not defined
    
    Iterator<UniqueConstraint> uniqueConstraints =
    
    metaSup.getUniqueConstraints(dbMetaData,new QualifiedName(dbMetaData.getUserName(),table), null).iterator(); <- Not defined
    
        while(uniqueConstraints.hasNext() && !response){
                    UniqueConstraint uc = uniqueConstraints.next();
                    List<String> columns = uc.getColumnList();
                    for(int i=0;i<columns.size() && !response;i++)
                        if(columns.get(i).equals(name))
                            response = true;
                }
                return response;
            } catch (SQLException e) {
                throw new OracleRetrieverException(SQL_ERROR,e);
            }
        }
    

    DatabaseMetaDataSupport and QualifiedName are now interfaces, so I have been checking the latest API, but there is no documentation on how to use the new provided classes: DatabaseMetaDataSupportFactory, UniqueConstraint, etc.

    Any clarification on how to use the new API for this scenario would be really appreciated!

    Héctor

     

    Last edit: Héctor Cadavid 2017-07-31
    • Paul Ferraro

      Paul Ferraro - 2017-08-07

      This is the equivalent code in HA-JDBC 3.0:

      Dialect dialect = new OracleDialect();
      DatabaseProperties database = new LazyDatabaseProperties(new
      SimpleDatabaseMetaDataProvider(metaData), dialect);
      TableProperties table = databaseProperties.findTable(tableName);
      Collection<UniqueConstraint> constraints = table.getUniqueConstraints();

      Paul

      On Mon, Jul 31, 2017 at 7:14 PM "Héctor Cadavid" hectorcadavid@users.sf.net
      wrote:

      Dear friends,

      I'm trying to upgrande a 8-years legacy application that worked with some
      HA-JDBC 2.0.x classes for meta-data extraction. Unfortunately, such version
      is no longer available in the official Mavenrepositories, and the API have
      changed considerably!... I haven't found any documentation so I don't have
      any clue how to update the following code, intented to identify if a given
      column name, in a given table, is a unique key:

      DatabaseMetaDataSupport metaSup = new DatabaseMetaDataSupport(dbMetaData,new OracleDialect()); <- Not defined

      Iterator<UniqueConstraint> uniqueConstraints =

      metaSup.getUniqueConstraints(dbMetaData,new QualifiedName(dbMetaData.getUserName(),table), null).iterator(); <- Not defined

      while(uniqueConstraints.hasNext() && !response){
                  UniqueConstraint uc = uniqueConstraints.next();
                  List<String> columns = uc.getColumnList();
                  for(int i=0;i<columns.size() && !response;i++)
                      if(columns.get(i).equals(name))
                          response = true;
              }
              return response;
          } catch (SQLException e) {
              throw new OracleRetrieverException(SQL_ERROR,e);
          }
      }
      

      DatabaseMetaDataSupport and QualifiedName are now interfaces, so I have
      been checking the latest API, but there is no documentation on how to use
      the new provided classes: DatabaseMetaDataSupportFactory, UniqueConstraint,
      etc.

      Any clarification on how to use the new API for this scenario would be
      really appreciated!

      Héctor

      Using HA-JDBC for DB-metadata extraction, problems upgrading from 2.0.x to
      3.0
      https://sourceforge.net/p/ha-jdbc/discussion/383397/thread/4f482ac9/?limit=25#306d


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ha-jdbc/discussion/383397/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Héctor Cadavid

    Héctor Cadavid - 2017-08-09

    Thank you so much for your reponse Paul!, I will give it a try!

     

Log in to post a comment.