• No replies
9224 Posts

Pinned topic SQLNonTransientConnectionException: No current connection

‏2011-07-14T06:16:40Z |
NOTE: this thread was migrated from Some content and formatting may have been lost in the move.

Originally posted by projectzero userid: keerti - f=4&t=2328#p9431
Please suggest a solution i need it in my application
I do following operations
getting exception SQLNonTransientConnectionException: No current connection
Posted: May 29, 2011 11:30 PM

Click to report abuse... Click to reply to this thread Reply

I implemented derby data base in my application to save my data,and i am getting this exception in retrieval of result set form "select" query in derby database.
To establish the connection i use connection string as:

I establish connection using this method:
I declare this method in class "":


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;


I used this method as and create connection, create connection during intraction using string:


private Connection objConnection = null;

objConnectionpool = new Connection("jdbc:derby:" + Folder.getAbsolutePath() + "/myapplication" + sFileName, null, null, "org.apache.derby.jdbc.EmbeddedDriver");

objConnection = objConnectionpool.createNewConnection();

I am getting exception in execution of Query:

sQuery = "select value,reason from " + TableNm + " where fileName ='" + FileName + "' AND type='"Type"' AND status ='remaining'";

during processing and interaction with derby database we might update as well get the data from the database:
I perform setAutoCommit as false before inserting in the database


after insertion:

ps = objConnection.prepareStatement(sQuery);

rs = ps.executeQuery();

I am getting Exception as

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 Source)
at Source)
at 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

Please suggest some solution as i m stuck in this problem..
Thanks in advance..