This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not recognising names containing underscores [RESOLVED]

 
Tom Robinson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tom Robinson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us your code?
 
Tom Robinson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Worked a treat, thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic