title: connect to database use properties file in java web application
body: <p>I write a code to connect to database from servlet.I want to use properties.but it does not work.i think i my code or properties file has problem.please help me to correct it.</p>
  
  <pre><code>try
          {
              Properties prop=new Properties();
              FileInputStream in = new FileInputStream(System.getProperty("WEB-INF/dbConnection.properties"));
              prop.load(in);
              in.close();
  
              String drivers = prop.getProperty("jdbc.drivers");
              String connectionURL = prop.getProperty("jdbc.url");
              String username = prop.getProperty("jdbc.username");
              String password = prop.getProperty("jdbc.password");
              Class.forName(drivers);
              con=DriverManager.getConnection(connectionURL,username,password);
              System.out.println("Connection Successful");
  
  ..
  </code></pre>
  
  <p>and this is my properties file</p>
  
  <pre><code>jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
  jdbc.url=jdbc:oracle:thin:@192.168.101.84:1521:orcl
  jdbc.username=user1
  jdbc.password=123
  </code></pre>