aspose file tools
The moose likes JDBC and the fly likes Preserving white space when importing and updating. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Preserving white space when importing and updating." Watch "Preserving white space when importing and updating." New topic
Author

Preserving white space when importing and updating.

W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
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?


SCJP 6, SCWCD 5
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

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.


My Blog: Down Home Country Coding with Scott Selikoff
W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

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?


OCUP UML fundamental
ITIL foundation
W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
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!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26218
    
  66

Thanks for posting the solution.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preserving white space when importing and updating.
 
Similar Threads
RandomAccessFile
How to adding a bullet in table column using when generate WORD or PDF file?
Struts 2 - Problem updating textfields created by iterating over a list of objects
Reference Specific Line in Text File
Tomcat 7 - RemoteAddrValve comma separated IP Address Failure