• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Loop to read through a string of fields and database table column names

 
Ranch Hand
Posts: 225
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string that has pairs of field names and database column names. These fields will be set to the value of the database table columns. Some fields are mapped with only one database column. Some fields are mapped with three database columns separated by slashes and some fields are mapped with two database columns separated by a colon. I have a setField() method that takes two parameters: a pdf field name and its corresponding value. I have a hash map called columnValues that has database column names paired with their corresponding values. In order to find the value of a particular database table column my application executes this line of code: columnValues.get(databaseColumn)

How would I make a loop that would do the following?

1. If a field is mapped with only one database column, then do this
pdf.setField(field, columnValues.get(databaseColumn));

2. If a field is mapped three database columns separated by slashes, then get the values of all three database columns and concatenate them with slashes separating them.

3. If a field is mapped with two database columns separated by a colon, then get the values of both database columns and concatenate them.

My application is reading through a string such as the following. It is field names with their corresponding database column names.
vehicleMake=makeColumn, dateOfCollision=monthColumn/dayColumn/yearColumn, vehicleYear=centuryColumn:yearColumn


 
I don't even know how to spell CIA. But this tiny ad does:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic