• 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

Help finding database.properties file in Eclipse

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

I am using MySQL 5 and Eclipse 3.1 on OS X Tiger.

Created the following file (TestDB.java), in Eclipse:



I also added a database.properties file (using Eclipse):



Now, when I right mouse clicked on my project and went to 'Java Build Path',
I added the following jar:

mysql-connector-java-3.1.12-bin.jar

When I tried to run the program using "Run As Java Application", I got the following exception in the Console:

java.io.FileNotFoundException: database.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at TestDB.getConnection(TestDB.java:78)
at TestDB.runTest(TestDB.java:50)
at TestDB.main(TestDB.java:22)

Why couldn't Eclipse detect this file? I created it in Eclipse, so I wonder why it couldn't find its location...

Many, many thanks!
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is strange.

Does the database.properties file reside in the project folder or the source folder

If it is the latter try moving it to the project folder.

A better solution would be to put it into your source folder and get your input stream using this.class.getResourceAsStream("/database.properties");

-Rajagopal
 
Ranch Hand
Posts: 89
Netscape MySQL Database Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should put your properties file in the same directory as your classes. You do not use a package, so put the propertiesfile in the same directory as the class file

(Would you have used a package, put the properties file in the same directory as the begin of the root class directory
e.g. my.package
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic