File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you format SQL strings??[Solved]

 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Don Morgan
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your idea...I have done something like this...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic