title: write Junit for JNDI
body: <p>I used JNDI connection in my application and it is working. But I need to write Junits to test the connection. We dont use any spring framework. This is the method i wrote to get JNDI connection.</p>
  
  <pre><code>public Connection getConnection() throws SQLException {
          DataSource ds = null;
          InitialContext ic = null;
          Connection con = null;
          try {
              ic = new InitialContext();
              ds = (DataSource) ic.lookup("java:/DBs");
              con = ds.getConnection();
              return con;
          } catch (Exception e) {
              throw new SQLException(e);
          }
  
  }
  </code></pre>