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.
[ December 08, 2004: Message edited by: Azz Romaysa ] [ December 08, 2004: Message edited by: Azz Romaysa ]
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 ]
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.
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.
Joined: Dec 08, 2004
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 ]
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 ]
Joined: Dec 08, 2004
It works now great. The problem was that I should restart resin even I changed the servlet or the .properties file.