I thought that when the connection gets closed then all resources get closed .
I also included the ResultSet and Statement ;) . But if the Statement closed then only ResultSet closed. But now i got the point ..after closing Connection i am still able to access to iterate the ResultSet . Actually it is tested only with Postgres. Is it sun specified : ?
Now i tested another code ...
The Resultset is still getting iterated ...
But when I get the DataSource using the JNDI look up then my another code is not working ..Saying that the ResultSet is closed.
Could you help me to figure out ...
Please help me to figure out .. ;)
I also included the ResultSet and Statement ;) . But if the Statement closed then only ResultSet closed. But now i got the point ..after closing Connection i am still able to access to iterate the ResultSet . Actually it is tested only with Postgres. Is it sun specified : ?
Now i tested another code ...
Code:
import org.apache.tomcat.dbcp.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.tomcat.dbcp.dbcp.datasources.SharedPoolDataSource;
DriverAdapterCPDS l_adapter = new DriverAdapterCPDS();
l_adapter.setDriver("org.postgresql.Driver");
l_adapter.setUrl("jdbc:postgresql://10.29.32.68:5432/Admin");
l_adapter.setUser("erp");
l_adapter.setPassword("iiterp");
SharedPoolDataSource l_ds = new SharedPoolDataSource();
l_ds.setConnectionPoolDataSource(l_adapter);
Connection l_con = l_ds.getConnection();
Statement l_stmt = l_con.createStatement();
ResultSet l_rs = l_stmt.executeQuery("select * from dpcode");
l_con.close();
while(l_rs.next()){System.out.println("Yahoo!!!");}
But when I get the DataSource using the JNDI look up then my another code is not working ..Saying that the ResultSet is closed.
Could you help me to figure out ...
Code:
Context l_ctx = new InitialContext();
DataSource l_ds = (DataSource)l_ctx.lookup("java:/comp/env/jdbc/admindatasource");
Connection l_con = l_ds.getConnection();
Statement l_stmt = l_con.createStatement();
ResultSet l_rs = l_stmt.executeQuery("select * from dpcode");
l_con.close();
while(l_rs.next()){System.out.println("Yahoo!!!");}
Comment