Hi, 1.) What is the difference between javax.sql.DataSource and javax.sql.ConnectionPoolDataSource. 2). I want to use the connection Pool, which one of the DataSource i'll choose. 3) What is the use of DataSource.getConnection(String user, String pwd) if i give ds.getConnection("test","test123"); where user id and pwd are Database related. It throws SQLException as getConnection(user,password) not implemented. I am using oracel thin driver. Regards, M.S.Raman.
1.) What is the difference between javax.sql.DataSource and javax.sql.ConnectionPoolDataSource.
The latter of the two does support connection pooling, whereas the first doesn't. This practically means that the ConnectionPoolDataSource can provide you with a PooledConnection. The answer to your second question now is obvious, I think.
3) What is the use of DataSource.getConnection(String user, String pwd)
Looks like a method for connection to different users after you have defined your database parameters with the DataSource.
if i give ds.getConnection("test","test123"); where user id and pwd are Database related. It throws SQLException as getConnection(user,password) not implemented.
There is no obligation on an implementor of the JDBC interfaces to actually implement all methods defined in the interface. At the moment I don't have the Oracle docuemntation at hand, so I wouldn't know whether they have (not) implemented the method you tried to use. I piece of unasked-for advize: you 'd probably do yourself a favour reading about the JDBC Standard Extensions (Sun has a specification and a tutorial covering this) and the Oracle Thin Driver (a very extensive manual has been published by Oracle). Good riding! Rudy.
Thanks for your information. But still I have a doubt about the dataSource, Because in JDBC tutorial in Sun Site and Weblogic docs for connection pool they are mentioned the javax.sql.DataSource only. Regards, M.S.Raman
Hi there Malli, That 's strange, at least at first glance. I went to a Sun page on JDBC, and indeed in their example they do use a simple DataSource object. On second thought this is not so strange, after all a ConnectionPoolDataSource inherits from a DataSource. Therefore we can call the ConnectionPoolDataSource as a DataSource. Apparently this is what the people at Sun want to show: the incredible flexibility of Java through the use in inheritance. :roll: Be that as it may (and of course this is a big advantage at coding time) they also add a warning to this page:
Deployment of a DataSource object that supports connection pooling involves the deployment of a ConnectionPoolDataSource object that is used by a connection pooling module in the middle tier of a three-tier architecture.
Hi, OfCourse I agree with u regarding the ConnectionPoolDataSource as the name itself indicates that it is Connection pool related DataSource. But Referring Sun JDBC Data Access API ---------------------------- Assuming that an application wants to connect to a data source represented by the DataSource object whose logical name is EmployeeDB , the code for getting a connection that uses connection pooling looks like this: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB"); Connection con = ds.getConnection("myUserName", "myPassword"); ----------------------------------- They are using DataSource Object only. DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB"); And if that the case the how to create ConnectionPoolDataSource in Weblogic6.1. Because weblogic provides interface for DataSource and TxDataSource Object in the onsole. And moreover i checked the with the JDBC Optional Package API where it hasn't mentioned the relation between javax.sql.DataSource and javax.sql.ConnectionPoolDataSource. Regards, M.S.Raman
Hi Malli, You seem to referr to the exact same document I was referring to (
Referring Sun JDBC Data Access API
). This means the quote I gave in my last post is still relevant. In this case the trick is not in calling the datasource, but in configuring it! Also, I clearly see your other quote
i checked the with the JDBC Optional Package API
ConnectionPoolDataSource A ConnectionPoolDataSource object is a factory for PooledConnection objects. DataSource A DataSource object is a factory for Connection objects.
This is also quite clear, I would think. I would like to write something to get rid of an obvious miscoimmunication, but I wouldn't know what Perhaps you can post the exact nature of your problem with these quotes, in order to get me to answer to it. Good riding, Rudy.
Thanks for replying me once again. Let I'll explain my query clearly: Since you mentioned that ConnectionPoolDataSource is related with the ConnectionPool. To get a connection from the connection Pool Object I expect the following Code
Context ctx= new InitialContext(); ConnectionPoolDataSource cpDS=(ConnectionPoolDataSource)ctx.lookup("ConnectionPoolDataSource); PooledConnection ps= cpDS.getPooledConnection(("myUserName", "myPassword");
Connection con= ps.getConnection();
That is in JNDI lookup we will search for ConnectionPoolDataSource for the ConnectionPoolDataSource Object for the ConnectionPool and get the pooledConneciton Object then we can get the connection OBject. But in Sun Doc or any other app server doc they are using the following Code:
Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB"); Connection con = ds.getConnection("myUserName", "myPassword");
Connection con = ds.getConnection("myUserName", "myPassword"); To get a connection Object from the connection Pool we are using DataSource Object and not Connection Pool DataSource. 2. I want to know how the Driver Class implements the Connection Pool Mechanism. Is it Driver Classes are internally using the Connection Pool DataSource Object. 3. In many documents it has mentioned that ConnectionPoolDataSource is used to get the Connection Object for the Connection POOL. But in nowhere they are using the ConnectionPoolDataSource. Regards, M.S.Raman
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop