title: sqlite error in database
body: <p>This is my code for connection manager class</p>
  
  <pre><code>public class ConnectionFactory {
   Connection con = null;
   Statement stmt = null;
   ResultSet rs = null;
   boolean flag=false;
  
   //Constructor starts
   public ConnectionFactory(){
      try{
          Class.forName("org.sqlite.JDBC");
          con=DriverManager.getConnection("jdbc:sqlite:db.sqlite");
          stmt=con.createStatement();
      }catch(Exception e){
          e.printStackTrace();
      }
  
   }//end of constructor ConnectionFactory
  
   //method Connection starts
   public Connection getConnection(){
      try{
          Class.forName("org.sqlite.JDBC");
          con=DriverManager.getConnection("jdbc:sqlite:db.sqlite");
           System.out.println("Connection to SQLite has been established.");
      }catch(Exception e){
          e.printStackTrace();
      }
  
      return con;
  
   }//end of method Connection
  
   //method checkLogin starts
   public boolean checkLogin(String username,String password, String user){
      if(user=="ADMINISTRATOR"){
          String query="SELECT * FROM users WHERE username='"+username+"' AND password='"+password+"' AND category='ADMINISTRATOR'";
          try{
              rs=stmt.executeQuery(query);
              while(rs.next()){
                  flag=true;
              }
          }catch(Exception e){
              e.printStackTrace();
          }
      }else{
          String query="SELECT * FROM users WHERE username='"+username+"' AND password='"+password+"'AND category='NORMAL USER'";
          try{
              rs=stmt.executeQuery(query);
              while(rs.next()){
                  flag=true;
              }
          }catch(Exception e){
              e.printStackTrace();
          }
      }
      return flag;
    }
   }
  </code></pre>
  
  <p>the connection to database is successful. and the login is successful. so its clear that data is accessible from db but still its giving some errors.</p>
  
  <p>these are the errors</p>
  
  <pre><code>java.sql.SQLException: database connection closed
  at org.sqlite.core.CoreConnection.checkOpen(CoreConnection.java:336)
  at org.sqlite.jdbc4.JDBC4Connection.createStatement(JDBC4Connection.java:38)
  at org.sqlite.jdbc3.JDBC3Connection.createStatement(JDBC3Connection.java:193)
  at com.inventory.dao.ProductDAO.&lt;init&gt;(ProductDAO.java:37)
  at com.inventory.ui.Products.loadDatas(Products.java:421)
  at com.inventory.ui.Products.&lt;init&gt;(Products.java:38)
  at com.inventory.ui.Dashboard.&lt;init&gt;(Dashboard.java:44)
  at com.inventory.ui.LoginDialog.loginBttnMouseClicked(LoginDialog.java:195)
  at com.inventory.ui.LoginDialog.access$100(LoginDialog.java:18)
  at com.inventory.ui.LoginDialog$2.mouseClicked(LoginDialog.java:68)
  at java.awt.Component.processMouseEvent(Component.java:6536)
  at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
  at java.awt.Component.processEvent(Component.java:6298)
  at java.awt.Container.processEvent(Container.java:2236)
  at java.awt.Component.dispatchEventImpl(Component.java:4889)
  at java.awt.Container.dispatchEventImpl(Container.java:2294)
  at java.awt.Component.dispatchEvent(Component.java:4711)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
  at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
  at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
  at java.awt.Container.dispatchEventImpl(Container.java:2280)
  at java.awt.Window.dispatchEventImpl(Window.java:2746)
  at java.awt.Component.dispatchEvent(Component.java:4711)
  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
  at java.awt.EventQueue.access$500(EventQueue.java:97)
  at java.awt.EventQueue$3.run(EventQueue.java:709)
  at java.awt.EventQueue$3.run(EventQueue.java:703)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
  at java.awt.EventQueue$4.run(EventQueue.java:731)
  at java.awt.EventQueue$4.run(EventQueue.java:729)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
  at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at com.inventory.dao.ProductDAO.getQueryResult(ProductDAO.java:482)
      at com.inventory.ui.Products.loadDatas(Products.java:422)
      at com.inventory.ui.Products.&lt;init&gt;(Products.java:38)
      at com.inventory.ui.Dashboard.&lt;init&gt;(Dashboard.java:44)
      at com.inventory.ui.LoginDialog.loginBttnMouseClicked(LoginDialog.java:195)
      at com.inventory.ui.LoginDialog.access$100(LoginDialog.java:18)
      at com.inventory.ui.LoginDialog$2.mouseClicked(LoginDialog.java:68)
      at java.awt.Component.processMouseEvent(Component.java:6536)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
      at java.awt.Component.processEvent(Component.java:6298)
      at java.awt.Container.processEvent(Container.java:2236)
      at java.awt.Component.dispatchEventImpl(Component.java:4889)
      at java.awt.Container.dispatchEventImpl(Container.java:2294)
      at java.awt.Component.dispatchEvent(Component.java:4711)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
      at java.awt.Container.dispatchEventImpl(Container.java:2280)
      at java.awt.Window.dispatchEventImpl(Window.java:2746)
      at java.awt.Component.dispatchEvent(Component.java:4711)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:731)
      at java.awt.EventQueue$4.run(EventQueue.java:729)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  </code></pre>
  
  <p>i have tried most of the options available in online forms. still no help. </p>