0

I wrote small web application with wicket and sql2o. I have several DAO classes where I create new Sql2o instances with hardcoded username and password:

Sql2o database = new Sql2o("jdbc:oracle:thin:@127.0.0.1:1521:test", "test", "test");

If I change password I would have to change it everywhere. So my question is where and how to put these settings in wicket so it could be accessed from different classes. Maybe I should use .properties file?

Luke
  • 21
  • 3
  • 2
    You should NOT create a database connection for every query, as this is extremely slow. I never worked with Sql2o but normally you would use jdbc pool. there are many different ways to do this – bert Jan 22 '14 at 15:16
  • 1
    For Basics on connection pooling read this page: http://stackoverflow.com/questions/2835090/jdbc-connection-pooling – thg Jan 22 '14 at 15:30

2 Answers2

0

You can use a .properties file, where you need to type:

jdbc.url=jdbc:oracle:thin:@//localhost:1521/your_database
jdbc.username=user
jdbc.password=password
0

The URL should be chaged to one of the following depending on you configurations

  1. jdbc:oracle:thin:@host:port/service
  2. jdbc:oracle:thin:@host:port:SID (SID - System ID of the Oracle server database instance.)
  3. jdbc:oracle:thin:@myhost:1521:databaseInstance (By default, Oracle Database 10g Express Edition creates one database instance called XE.)
Shanaka
  • 1,670
  • 3
  • 21
  • 42