Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how do we get the connection from connection pool

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


Please Help Members By Posting Answers For Below Questions

What are the common JDBC problems that you got and how do you solved them?

2436


What is layer in communication?

883


Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

1127


What are the common jdbc exceptions?

949


How do I set properties for a JDBC driver and where are the properties stored?

966


Does sql allow null values ?

976


What is meant by connection string?

995


What is a jdbc driver and how many jdbc drivers are available?

1055


How to get the Database server details in java program?

1076


What is namedparameterjdbctemplate?

987


Expalin the method of calling a stored procedure from jdbc.

974


How to make updates to updatable result sets in jdbc?

908


What is an SQL Locator?

1135


What is the return type of class.forname() method?

946


What is meant by dao?

939