This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Writting query in xml

 
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.

I need its main advantage and the comparison of it with the normal method of writing it in java file.


Thanks
Varadhan.s
 
Marshal
Posts: 67528
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our XML forum.
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keeping SQL out of code helps code maintainability. You can change SQL statements for only optimization needs in future still not re-building the code again.

Read - Keep SQL out of code
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Varadhan Sesharaman wrote:

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.


Do you have a reference where that's mentioned?
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you can avoid this c**p:


That is a segment from a 114 line SQL statement, JOINing across 9 tables!

Whenever a developer has to change this, he or she must test (externally), the recompile the Class, rebuild the war, and redeploy.

Besides the minimal performance hit, storing SQL in XML will give you (if you do it right), tools like myBatis can really help.


WP
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Varadhan Sesharaman wrote:Hi guys,

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.

I need its main advantage and the comparison of it with the normal method of writing it in java file.


Thanks
Varadhan.s



What do you mean by writing sql query in xml format? Do you mean to use XML to transfer data to and from database? Or do you mean that putting sql query as part of XML?
 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Palak Mathur,

In some cases i saw the query files are kept out of the java code .

The query are written in xml using the proper xml tags and the in run time the queries are converted into a normal query and then executed in java.

I am asking is there any specific reason for keeping the query out of the java file.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am asking is there any specific reason for keeping the query out of the java file.



1. Ease of changing the query without having to recompile
2. Facilitates record keeping, you can document the query using XSLT to create a nicely formatted record.
3. Reduced chance of introducing errors into Java file
4. Facilitate use by non-java-programmers
5. Probably, better security but I'm not sure about that

Bill
 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys for those answers.

Now i had some idea on this concept.


Thanks,
Varadhan.s
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!