
Sir,
In my project i want to implement connection pooling with ms-sql server 2005. i wrote the code in JSP like this...
<% Connection con=DbCon.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from userdetails"); while(rs.next()) { out.println(rs.getString("username")); }
%> <% if(con!=null) con.close(); %>
and this is my java program
package MyPackage; import java.sql.Connection; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; public class DbConnection { public static Connection getConnection() throws Exception { return getPooledConnection(); } public static Connection getPooledConnection() throws Exception{ Connection conn = null;
try{
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("No Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/SMSPooling");
if (ds != null) {
conn = ds.getConnection();
return conn;
}else{
return null;
}
}catch(Exception e) {
e.printStackTrace();
throw e;
}
}
public static void main(String[] args) { new DbConnection(); System.out.println("Database has been connected at...."+new java.util.Date()); } }
When i am executing this code i am getting the exception like the below....
java.lang.StackOverflowError
and naming not found exception...
How to solve this...
Thanks in advance..

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.