how do we get the connection from connection pool



how do we get the connection from connection pool..

Answer / paletipatisrinu

import java.io.*;
import java.sql.*;
inport javax.sql.*;
import javax,servlet.http.*;
public class connection extends HttpServlet
{
public void service(HttpServletRequest
req,HttpServletResponse res)throws ServletException,IOException
{
Connection con=makeConnectionPool();
Statement st =con.createStatement();

----------reqular code as like as jdbc--------









}
public void Connection makeConnectionPool()
{
Connection con=null;
try
{
InitialContext ic =new InitialContext();
DataSource ds =(DataSource)ic.lookUp(" jndi logical Name in
Application server");
con=ds.getcConnection();
}catch(Exception e)
{
e.printStackTrace();
}
return con;
}



Note:-First u create logical name of jndi in application
server and refer this api javax.sql.*

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More JDBC Interview Questions

what is call level interface?

1 Answers  


Can resultset be null in java?

0 Answers  


How to retrieve warnings in jdbc?

0 Answers  


What is jndi lookup?

0 Answers  


How do I find whether a parameter exists in the request object?

0 Answers  






What is the use of JDBC DriverManager class?

0 Answers  


What are collection pools?

0 Answers  


How to move the cursor in scrollable resultset ?

0 Answers  


What is DML?

0 Answers  


What is Normalization?

2 Answers   Accenture, Atos Origin,


How do I check in my code whether a maximum limit of database connections have been reached?

0 Answers  


How many rowset are available in jdbc?

0 Answers  


Categories