• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems in Closing PreparedStatements using WS AS 3.5 Connection Pooling using Oracl

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing a peculiar problem - PreparedStatements and CallableStatements are not getting closed in the backend. I have promptly closed all the statement objects and connection objects after their use. Whereas Statements gets closed perfectly.
This is a sample code I have to used to check the closing of the PreparedStatement.
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.naming.*;
import com.ibm.ejs.ns.jndi.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class dbase
{
public static void main(String arg[])
{
PreparedStatement stmt = null;
try
{
Hashtable ht = new Hashtable();
ht.put(Context.PROVIDER_URL,"iiop://plserver:900");
ht.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
Context ct = new InitialContext(ht);
System.out.println(" ater Context creation ");
DataSource ds = (DataSource) ct.lookup("jdbc/DS_Test");
System.out.println(" after look up ");
Connection con = ds.getConnection("temp","temp12");
System.out.println(" after connection " + con);
stmt = con.prepareStatement("select * from test");
ResultSet rs = stmt.executeQuery();
if(rs.next())
System.out.println(" DATAS FETCHED ");
Thread.sleep(10000);
rs.close();
stmt.close();
con.close();
System.out.println("ITS TERMINATED");
Thread.sleep(20000);
System.out.println("AFTER SLEEP");
}catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
System.out.println("inside close while ");
}
}
catch(Exception e1)
{
System.out.println(" exception caught from finally " + e1);
}
}
}
}
Please help.
regards,
prasadh
 
reply
    Bookmark Topic Watch Topic
  • New Topic