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 test jdbc connection to sql server?
After creating conntinpool in weblogic how to write the code in programe where i can use that pool object in the programe connecting to the database and how to debug programe withou eclipse
Is jdbc and orm?
What is a merge field?
How to insert and delete a row programmatically? (new feature in JDBC 2.0)
What are the differences between statement and preparedstatement interface?
What is phantom read and which isolation level prevents it?
What is the execute method in java?
Write a program JDBCcode forfetching student database with SQL.
Where is jdbc used?
Why hibernate is better than jdbc?
What is db client?