Answer Posted / 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 |
Post New Answer View All Answers
What is resultset?
How can we maintain the integrity of a database by using jdbc?
What is setautocommit in jdbc?
Give steps to connect to the db using jdbc?
Discuss the procedure of retrieving warnings?
What is a rollback in jdbc?
What are the three basic components of the odbc architecture?
How does a custom RowSetReader get called from a CachedRowSet?
What are the main steps in java to make JDBC connectivity?
Is jdbc open source?
What is batch processing and how to perform batch processing in jdbc?
What are the higher level apis under development on top of jdbc currently?
What is createstatement method in java?
What is JDBC ResultSet?
What is the fastest type of JDBC driver?