Exemplo n.º 1
0
 @Override
 public String getViewDDL(DBRProgressMonitor monitor, GenericTable sourceObject)
     throws DBException {
   GenericDataSource dataSource = sourceObject.getDataSource();
   try (JDBCSession session =
       DBUtils.openMetaSession(monitor, dataSource, "Read H2 view source")) {
     try (JDBCPreparedStatement dbStat =
         session.prepareStatement(
             "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS "
                 + "WHERE TABLE_SCHEMA=? AND TABLE_NAME=?")) {
       dbStat.setString(1, sourceObject.getContainer().getName());
       dbStat.setString(2, sourceObject.getName());
       try (JDBCResultSet dbResult = dbStat.executeQuery()) {
         if (dbResult.nextRow()) {
           return dbResult.getString(1);
         }
         return "-- H2 view definition not found";
       }
     }
   } catch (SQLException e) {
     throw new DBException(e, dataSource);
   }
 }