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 do you mean by metadata and why we are using it?
What are the exceptions in jdbc?
Can we have foreign key reference to a non primary key column ?
Is jdbc a web technology?
What is the use of dialect?
How do I find jdbc version?
How the JDBC application works?
What is ODBC and JDBC? How do you connect the Database?
What are the utilities of the callablestatement?
Explain the process of creating tables using NetBeans IDE?
How can you make a connection?
What is jdbc and odbc in java?
What is jdbc explain?
Can I use JDBC to execute non-standard features that my DBMS provides?
What is two-phase commit in the database?