wood burning stoves 2.0*
The moose likes JDBC and the fly likes Not recognising names containing underscores [RESOLVED] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Not recognising names containing underscores [RESOLVED]" Watch "Not recognising names containing underscores [RESOLVED]" New topic
Author

Not recognising names containing underscores [RESOLVED]

Tom Robinson
Greenhorn

Joined: Nov 13, 2006
Posts: 4
Hi,

I'm using the executeQuery method (java.sql.Statement) to run a Sybase SQL query. I'm using the AS keyword to set the names of the returned data like so:


I get the metadata of the returned data and make an XML document. The problem that I am having is that in the XML document instead of 'XAF_object' it just has 'object' (like wise XAF_service becomes just service).

Does anybody know why this may be happening? I'd be happy to try and provide more information if you need it and I'm able to

Thanks in advance for any help,
Tom

Edit: I got mixed up, I'm using Sybase not DB2 :roll:

[ November 13, 2006: Message edited by: Tom Robinson ]
[ November 14, 2006: Message edited by: Tom Robinson ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Don't know about DB2, but the underscore character is somtimes used as a special character representing whitespace - at least ist is in Sybase and SQL Server. It might be the same in DB2 - worth checking your DB2 documentation.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Tom Robinson
Greenhorn

Joined: Nov 13, 2006
Posts: 4
Thanks for the reply, I got mixed up and it's Sybase I'm using not DB2.

The underscore doesn't seem to be my problem - I forgot to include in my first post that the right names are returned when I run my SQL statement in an isql terminal so I'm assuming it's something to do with the conversion to XML.

Any ideas ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Can you show us your code?
Tom Robinson
Greenhorn

Joined: Nov 13, 2006
Posts: 4
I think this should be the stuff you need...

My SQL query is:


My code that executes the statement and converts it to XML is:
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Well my guess is that getColumnName() will return the column name regardless of what alias you give it, but getColumnLabel() might give you the alias. You could try that.
Tom Robinson
Greenhorn

Joined: Nov 13, 2006
Posts: 4
Worked a treat, thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Not recognising names containing underscores [RESOLVED]
 
Similar Threads
Front controller and DAO, design question!
Need help-Poor performance-Delay while I type characters in the text box of JSP Page
Insert XML document directly into database
Castor Marshaller and SAX Content Handler
Sybase Database to XML