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

where to put SQL queries ?

 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am currently working on a Project in which all the PL/SQL queries has been hard coded inside the java code, My PM asked me to provide some solution to avoid this..He also suggested me to put these queries into one database table whereas I suggested him to put all these queries into one properties file and fetch them from there.! But still confuse which is the better way to do that ? Is there any other alternative way to do that..?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both suggestions sounds good. My preference is for a properties file. This is because

* it is easier to maintain and manipulate in a good text editor or IDE.
* you can put it in your source control, so that you can always retrieve older versions.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
But I want to know which will provide a better performance, I think it will be properties file, once uploaded it easier to fetch Query from there.
where do we generally keep the queries apart from properties file?
 
Steve McLeod
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Properties file is stored on the local drive. Retrieving it is many times faster than establishing a database connection, performing a SQL select statement, and populating a data structure with the results.

The time to read a properties file with, say, 200 SQL queries is so fast it is barely measurable.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Although some of my friends has given me some other options like,
Putting the queries into an XML or EXCEL file. But i don't know the much difference performance vise. So i think i better go with the properties file.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what do you mean by PL/SQL queries? I assume that as PL/SQL blocks/procedures.

So, why not create database stored procedures with those PL/SQL?
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ansari,

Here PL/SQL queries means simple select,delete, update and insert statement, I can not create a procedure with those queries and also I can not hard code them into JAVA code, I am looking for a best place to keep those queries..
 
Sheriff
Posts: 21842
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sunny Jain:
Thanks, Although some of my friends has given me some other options like,
Putting the queries into an XML or EXCEL file. But i don't know the much difference performance vise. So i think i better go with the properties file.


XML and Excel have more complex structures so parsing that will bring performance down a bit more than properties files.

I'd go for properties files - in fact, I'm doing that myself already.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sunny Jain:
Here PL/SQL queries means simple select,delete, update and insert statement, I can not create a procedure with those queries and also I can not hard code them into JAVA code, I am looking for a best place to keep those queries..



O'rite. Actually, I got confused a bit, because for those we just normally use the word "SQL queries", instead. The word PL/SQL sounds procedural to me and I start thinking of procedures, cursors, triggers etc.. However, the properties file sounds better in your case, as already suggested by a few folks.
 
Does this tiny ad smell okay to you?
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!