title: Connection to a derby database in a dynamic web project
body: <p>I am using the following code to connect to a derby database in a dyamic web project but it does not work. If I use the same code in a normal java project it works can you guys help me out.</p>
  
  <pre><code>  private Connection connection = null;
  
          public DBconnection(){
                  createConnection();
  
          }
  
      public void createConnection(){
  
              try{
                      Class.forName("org.apache.derby.jdbc.ClientDriver");
                      this.connection = DriverManager.getConnection("jdbc:derby://localhost:1527/student");
  
              }catch (Exception e){
                      e.printStackTrace();
              }
  
  
      }
  
      public Connection getConnection(){
              return this.connection;
      }
  </code></pre>
  
  <p>Note:</p>
  
  <p>I have included all the derby libraries in my dynamic web project and also I have I have started the derby server everything works but this code does not connect to the database. Also I am running the dynamic project on a tomcat server the port for that is 8080 and the port for the derby server is 1527.</p>