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 do you mean by metadata and why we are using it?

1077


What are the exceptions in jdbc?

997


Can we have foreign key reference to a non primary key column ?

1026


Is jdbc a web technology?

942


What is the use of dialect?

1059


How do I find jdbc version?

1054


How the JDBC application works?

1002


What is ODBC and JDBC? How do you connect the Database?

1085


What are the utilities of the callablestatement?

1060


Explain the process of creating tables using NetBeans IDE?

1014


How can you make a connection?

1031


What is jdbc and odbc in java?

961


What is jdbc explain?

977


Can I use JDBC to execute non-standard features that my DBMS provides?

1065


What is two-phase commit in the database?

1099