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 are the 4 types of jdbc drivers?

0 Answers  


Write a program JDBCcode forfetching student database with SQL.

0 Answers  


What is jdbc and explain jdbc architecture?

0 Answers  


What are clob and blob data types in jdbc?

0 Answers  


What do you understand by jdbc driver and explain its types?

0 Answers  






Can resultset be null in java?

0 Answers  


write down exceptions those appear in java programs when u write JDBC Programs?

2 Answers  


Why resultset is used in java?

0 Answers  


How many locking systems are there in jdbc?

0 Answers  


Why jdbc is used in java?

0 Answers  


What are the packages are used in jdbc?

0 Answers  


What is the use of statement in jdbc?

0 Answers  


Categories