• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using ResourceBundle

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to load driver info, URL info, userID info, and password info for my MySQL database by using a ConnectU.properties file that contains:

I trying to get this info from a java file with that contains the following snippet:

I keep getting the error:
Specific Error: Can't find bundle for base name ConectU cal.en_US
which is printed from the above catch statement.
Can someone please explain how the properties file works and how I can get a program to access this file if I need to write a program for a DB in which the user will not need to know the driver location, URL, login, and password? I hope all of this makes sense as I am green in this area.
Thanks in advance, Brian!!!
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually answered my own question with thanks to long sun. I didn;t realize you had to actually set the properties using a properties file. Thanks!!
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I compiled and tested your original code, and it worked fine for me. Are you absolutely sure about the properties file name? It has to be "ConnectU.properties", in the same directory as the .class file (or in the same relative path in a JAR file), otherwise you'll get the error you mention. From the error message, it looks like you tried to load "ConectU.properties", with one "n". Also, if the program is in a package (foo.bar.ConnectU), the getBundle() method must use the full package name prefix ("foo.bar.ConnectU").
So you don't have to explicitly treat the properties file as a java.util.Properties object - it can be a ResourceBundle as well, exactly as you have written it.

------------------
Phil Hanna
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Phil. I works for me now as well. It must have been a typo. I was also working on that problem at 4:00 AM. I slept on it and the next day, all was well. Sorry for the confusion!!
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic