• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Preserving white space when importing and updating.

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating a program that first reads each line of a fixed-length field document. Each line is a record, and depending on which character you are at, the values mean different things (for example, characters 1 through 20 may be an identification number). I am running into a problem when I load these through the JDBCODBC driver into SQL Server where it is dropping the white spaces. This means that when I am parsing the data, if a field has 3 characters instead of the 4 designated to it, all the fields following that will be off by one characters.

For example:
222 333 444 would be parsed as 222, 333, 444 (fields separated by commas)
but
22 333 444 would be parsed as 22, 334, 44

Is there a way I can force white space to stay?
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the code you using? Nothing in JDBC should be dropping white spaces, although its possible this may be a driver issue. I'd also consult the driver documentation to see if there are any parameters you can pass into the connection string related to white space handling.
 
W Pearce
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

the code and the problem you have in your first post don't seem to relate.
We can see that you are splitting strings separated by ' , and putting the results in three tables based upon the starting sequence of the split.

But where is the problem with spaces happening?
 
W Pearce
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow. I can't believe I overlooked something like this. Every time I split the string on an apostrophe, it cuts that character out, therefore when a field had a description with a possessive noun it was removing those characters. I have it replacing the characters with a space now and we're back up and running. I feel like such a schmuck!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting the solution.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic