Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8252985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:43:05+00:00 2026-06-08T00:43:05+00:00

I’m working on creating a test suite that runs on multiple databases using dbunit

  • 0

I’m working on creating a test suite that runs on multiple databases using dbunit xml. Unfortunately, yesterday I discovered that some table names in our schema are over 30 characters, and are truncated for Oracle. For example, a table named unusually_long_table_name_error in mysql is named unusually_long_table_name_erro in Oracle. This means that my dbunit file contains lines like <unusually_long_table_name_error col1="value1" col2="value2 />. These lines throw a NoSuchTableException when running the tests in Oracle.

Is there a programmatic workaround for this? I’d really like to avoid generating special xml files for Oracle. I looked into a custom MetadataHandler but it returns lots of java.sql datatypes that I don’t know how to intercept/spoof. I could read the xml myself, truncate each table name to 30 characters, write that out to a temp file or StringBufferInputStream and then use that as input to my DataSetBuilder, but that seems like a whole lot of steps to accomplish very little. Maybe there’s some ninja Oracle trick with synonyms or stored procedures or goodness-know-what-else that could help me. Is one of these ideas clearly better than the others? Is there some other approach that would blow me away with its simplicity and elegance? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:43:07+00:00Added an answer on June 8, 2026 at 12:43 am

    In light of the lack of answers, I ended up going with my own suggested approach, which

    1. Reads the .xml file
    2. Regex’s out the table name
    3. Truncates the table name if it’s over 30 characters
    4. Appends the (potentially modified) line to a StringBuilder
    5. Feeds that StringBuilder into a ByteArrayInputStream, suitable for passing into a DataSetBuilder

    public InputStream oracleWorkaroundStream(String fileName) throws IOException
    {
      String ls = System.getProperty("line.separator");
    
      // This pattern isolates the table name from the rest of the line
      Pattern pattern = Pattern.compile("(\\s*<)(\\w+)(.*/>)");
    
      FileInputStream fis = new FileInputStream(fileName);
      // Use a StringBuidler for better performance over repeated concatenation
      StringBuilder sb = new StringBuilder(fis.available()*2);
    
      InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
      BufferedReader buff = new BufferedReader(isr);
      while (buff.ready())
      {
        // Read a line from the source xml file
        String line = buff.readLine();
        Matcher matcher = pattern.matcher(line);
    
        // See if the line contains a table name
        if (matcher.matches())
        {
          String tableName = matcher.group(2);
          if (tableName.length() > 30)
          {
            tableName = tableName.substring(0, 30);
          }
    
          // Append the (potentially modified) line
          sb.append(matcher.group(1));
          sb.append(tableName);
          sb.append(matcher.group(3));
        }
        else
        {
          // Some lines don't have tables names (<dataset>, <?xml?>, etc.)
          sb.append(line);
        }
        sb.append(ls);
      }
    
      return new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
    }
    

    EDIT: Swtiched to StringBuilder from repeated String concatenation, which gives a huge performance boost

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.