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 common JDBC problems that you got and how do you solved them?
What is layer in communication?
Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
What are the common jdbc exceptions?
How do I set properties for a JDBC driver and where are the properties stored?
Does sql allow null values ?
What is meant by connection string?
What is a jdbc driver and how many jdbc drivers are available?
How to get the Database server details in java program?
What is namedparameterjdbctemplate?
Expalin the method of calling a stored procedure from jdbc.
How to make updates to updatable result sets in jdbc?
What is an SQL Locator?
What is the return type of class.forname() method?
What is meant by dao?