cancel
Showing results for 
Search instead for 
Did you mean: 

ResultSet closed error

Former Member
0 Kudos

Hi all,

I am using visual admin to connect to my oracle database. The connection and query execution is done in EJB. The business method in the EJB returns a result set.When i use this function in my webdynpro code the lookup is working fine but it is throwing an exception that the result set is already closed.How do i solve this problem

Regards

Bharathwaj.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

hi barath,

It might be as you are using the connection pooling mechanism that you are getting such an error.

Try passing those values using a vector or some hashmap.

Regards,

Shyam.

Answers (4)

Answers (4)

Former Member
0 Kudos

hi anil..

The data is available in the database.Instead of using datasource if i connect directly its working fine.

The error its throwing when i try to connect through visual admin is ....

com.sap.sql.log.OpenSQLException: ResultSet object com.sap.sql.jdbc.direct.DirectResultSet@137d3b1 has already been closed.

If there is no data it wil through a null pointer exception for rs.next...rite!

Regards

Bharathwaj

Former Member
0 Kudos

Hi,

Problem could be resultset doesn't have any data ..i mean resultset returning 0 rows.Please check this.

Regards, Anilkumar

Former Member
0 Kudos

public class ProjectdetailsBean implements SessionBean {

Connection conn = null;

Statement stmt = null;

ResultSet rs = null;

InitialContext ctx = null;

DataSource ds = null;

public void ejbRemove() {

try{ conn.close(); }

catch(Exception e)

{

System.out.println("Error in closing the connection"+ e.toString());

}

}

public void ejbActivate() { getConnection(); }

public void ejbPassivate() {}

public void setSessionContext(SessionContext context) { myContext = context;}

public void ejbCreate() throws CreateException { getConnection();}

public void getConnection() {

try {

ctx = new InitialContext();

ds = (DataSource)ctx.lookup("jdbc/projectsdemo2");

conn = ds.getConnection();

} catch (Exception e) {

System.out.println("Error" + e.getClass());

}

public ResultSet getLinkDetails() {

try {

stmt = conn.createStatement();

rs = stmt.executeQuery("select projectid,projectname from projectsdemo_details");

} catch (Exception e) {

System.out.println("Error" + e.getClass());

}

return rs;

}

}

Former Member
0 Kudos

Hi,

In the java bean program you are closing the resultset somewhere !!! please check the code once.

could you please send the code once.

Regards, Anilkumar

Former Member
0 Kudos

Yes, as AnilKumar said, just before the return of the resultSet you might be perhaps closing the resultSet. If you need to close the resultSet just put the values of the result set into some hashmap and send the hashmap instead of the resultSet. Sending the result Set is not considered a good programming practice.

Regards

Noufal