title: SQLNonTransientConnectionException: No current connection, in my application while interacting with Derby database
body: <p>I implemented derby data base in my application to save my data,and I am getting this exception in retrieval of result set form <code>select</code> query in Derby database.
  To establish the connection I use connection string as:</p>
  
  <p>I establish connection using this method:</p>
  
  <p>I declare this method in class <em>Connection.java</em>:</p>
  
  <pre><code> public synchronized Connection createConnection() throws Exception {
  
          Connection rescon = null;
  
          try {
              if (this.dbuser == null) {
                  rescon = DriverManager.getConnection(this.URI + ";create=true");
                  } else {
                  rescon = DriverManager.getConnection(this.URI + ";create=true",
                          this.dbuser, this.dbpass);
              }
              // new connection in connection pool created
          } catch (SQLException e) {
              final String stackNum = Utility.exceptionHandler(e);
              throw new Exception("Exception get during Connection - " + e.getMessage());
          }
          return rescon;
      }
  </code></pre>
  
  <p>I used this method as and create connection, create connection during intraction using string:</p>
  
  <pre><code>private Connection objConnection = null;
  objConnectionpool = new Connection("jdbc:derby:" + Folder.getAbsolutePath() +        "/myapplication" + sFileName, null, null, "org.apache.derby.jdbc.EmbeddedDriver");
  objConnection =  objConnectionpool.createNewConnection();
  </code></pre>
  
  <p>I am getting exception in execution of query:</p>
  
  <pre><code>sQuery = "select value,reason from " + TableNm + " where fileName ='" + FileName + "' AND type='"+Type+"' AND status ='remaining'"; 
  </code></pre>
  
  <p>during processing and interaction with Derby database we might update as well get the data from the database:</p>
  
  <p>I perform setAutoCommit as false before inserting in the database</p>
  
  <pre><code>objConnection.setAutoCommit(false);
  </code></pre>
  
  <p>after insertion:</p>
  
  <pre><code>ps = objConnection.prepareStatement(sQuery);
  rs = ps.executeQuery();
  objConnection.commit();
  objConnection.setAutoCommit(true);
  </code></pre>
  
  <p>I am getting Exception as </p>
  
  <pre><code>java.sql.SQLNonTransientConnectionException: No current connection.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.Util.noCurrentConnection(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.checkIfClosed(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.setupContextStack(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
      at com.myapplication.c.aw.a(Unknown Source)
      at com.myapplication.c.aw.a(Unknown Source)
      at com.myapplication.main.avd.run(Unknown Source)
  Caused by: java.sql.SQLException: No current connection.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
      ... 11 more
  </code></pre>