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 |
What class.forname does, while loading the drivers?
Explain about Join?
What is an odbc driver?
What is transaction processing in jdbc?
How does a file store compare with a jdbc store?
How is jndi useful for Database connection?
What is jdbc and jdbc drivers?
How can I retrieve a String or other object type without creating a new object each time?
What is the syntax of URL to get connection?
How do java applications access the database using jdbc?
What is the jdbc rowset?
Is java a database?