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 are the 4 types of jdbc drivers?
Write a program JDBCcode forfetching student database with SQL.
What is jdbc and explain jdbc architecture?
What are clob and blob data types in jdbc?
What do you understand by jdbc driver and explain its types?
Can resultset be null in java?
write down exceptions those appear in java programs when u write JDBC Programs?
Why resultset is used in java?
How many locking systems are there in jdbc?
Why jdbc is used in java?
What are the packages are used in jdbc?
What is the use of statement in jdbc?