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 is the difference between ojdbc6 and ojdbc7?
Explain in detail about JDBC and its general features?
How do I check in my code whether a maximum limit of database connections have been reached?
Why do we use jdbc?
What is the difference between triggers and procedures?
What driver should I use for scalable Oracle JDBC applications?
Diff. types of triggers..
How can I write to the log used by DriverManager and JDBC drivers?
What is JDBC?
3 Answers Akamai Technologies,
What is url in jdbc connection?
How to execute bulk number of queries at once?
What is difference between java.util.Date and java.sql.Date?