• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQLQueries.properties

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

Does someone know how can I make a special file only for the SQL Queries? And how can I use these queries in a jsp/servlet file? I tried to make a SQLQuesrie.properties but i still get the following errors:

java.util.MissingResourceException: Can't find bundle for base name SQLQueries,
locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:839)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:808)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:552)
at test.TestDatabase.doGet(TestDatabase.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)

It's maybe that I've placed the SQLQueries.properties in a wrong dir. Could someone help me to fix this problem?
I use Resin 2.1.14 webserver.

Abu Romaysa

[ December 08, 2004: Message edited by: Azz Romaysa ]
[ December 08, 2004: Message edited by: Azz Romaysa ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ResourceBundle you are trying to load would be in a file called SQLQueries_en_US.properties. And that file would need to be in the classpath. Are both of these things true? And why are you trying to internationalize SQL queries? Unless you are connecting to different schemas dependent on Locale I can't see why you'd do this.
[ December 08, 2004: Message edited by: Paul Sturrock ]
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

Thnx for ur replay.
My file called SQLQueries.properties and it's in the calsspath.

The reason why I did that is that I want to separate the sql queries from the java code.

This is my SQLQueries.properties


And this is a Databasetest calss:


Before that, I used the traditional method in my webapplications, a databaseConnection calss, en all my jsp's call a method in that class to make the connection with the database. I want now to separate that, because I've a lot of queries.

Thanks
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Its one of the approaches to make the application maintainable, but having the SQL queries in DAO objects would be the right aproach, rather than using property files.

Cause, reading property files would rather tend to slow down the system.

See java Blue Prints to know more about DAO Objects.
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you place an example please. I want to try it and see if it'll work.

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Cause, reading property files would rather tend to slow down the system.


Except that Azz Romaysa seems to want to use ResourceBundles for this, which are cached after being read.


My file called SQLQueries.properties and it's in the calsspath


And where is SQLQueries_en_US.properties? Because you are using ResourceBundles, the getBundle() method is looking for a properties file which contains the resources for the current default Locale, which in your case seems to be en_US.

I still don't understand why you need to internationalize your SQL though.

DAO's may well be a better way to go though.
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried to rename my properties file from SQLQueries.properties to SQLQueries_en_US.properties but resin still give me the same error.

Here is a csreenshot of the structure of my resin:


the SQLQueries_en_US.propertie is under props dir.
[ December 08, 2004: Message edited by: Azz Romaysa ]
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I don't know Resin at all, but I always assumed that the classpath for WebApps usually only included WEB-INF/classes and WEB-INF/lib. A simplified explanation of what the getBundle method does is trawls the classpath looking for the file. If it can't find it it is because:
  • There isn't a properties file for the Locale you are using
  • There is a typo either in your code or in the properties file name
  • The properties file is not in the classpath

  • So its one of those reasons, and I suspect its the last.

    I still don't see why you need to internationalize your SQL though.
    [ December 09, 2004: Message edited by: Paul Sturrock ]
     
    Azz Romaysa
    Ranch Hand
    Posts: 66
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks,

    It works now great. The problem was that I should restart resin even I changed the servlet or the .properties file.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic