Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes How do you format SQL strings??[Solved] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do you format SQL strings??[Solved]" Watch "How do you format SQL strings??[Solved]" New topic
Author

How do you format SQL strings??[Solved]

Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
I have a SQL statement like this and I want to preserve the same format while coding so as to maintain readability but unfortunately Java does not allow me to write a string in more than a line....
I want to write a query something like this...

[ January 05, 2006: Message edited by: Raghavan Chockalingam ]

Raghavan
SCJP 6
Don Morgan
Ranch Hand

Joined: Jul 24, 2003
Posts: 84
I have used a couple of things before:

1. Break up the string so your query can be across multiple lines of source code. For example:


2. Store the SQL in an external file. This is handy if you think you may want to change the SQL without rebuilding the class file.


Don Morgan, Founder
www.DeveloperAdvantage.com - FREE Audiobooks for Software Developers
Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
Thanks for your idea...I have done something like this...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you format SQL strings??[Solved]
 
Similar Threads
Bug fix for deleting posts
Hibernate: Different Join in Save() and Get()
Combining Multiple Inner Joins with a Left Join
hibernate mysql "Like"
outer join in HQL