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 |
How to connect html page to database using jdbc?
How to check jdbc driver version in sql server?
Under what circumstances, that all four drivers are used?
What is batch processing and how to perform batch processing in jdbc?
Where can I find info, frameworks and example source for writing a JDBC driver?
What is java soft framework?
Can the JDBC-ODBC Bridge be used with applets?
How do I start debugging problems related to the JDBC API?
How to rollback a JDBC transaction?
What is the use of the statement in jdbc?
What is use of connection pooling?
How is database middleware used to access legacy databases?