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 are the different types of resultset?
How to set the attribute concurrency in resultset?
How do I disallow NULL values in a table?
Does jpa use jdbc?
How to connect multiple database in jdbc?
Where is jdbc url mysql?
Can I use JDBC to execute non-standard features that my DBMS provides?
What do you mean by odbc?
Explain creation of statement object with connection method create method with help of an example.
What is setautocommit in jdbc?
How to check jdbc driver version in websphere?
What is data source in java?
What do you understand by jdbc datasource?
What is dburl?
What is createstatement method in java?