You'll need to define 'the same'. In theory you can usem both the same and they will behave the same, but only if they are using the same Driver library to provide Connections. They might not be. Also, a DataSource usually hides a Connection Pool as well, where you get a new Connection each time from the DriverManager.
From a quick search, DataSource is a common J2EE thing, TXDataSource is a Weblogic thing. For more info on using TXDataSource, see this link It's specific to Weblogic 5.1, but should define the difference. Weblogic uses them as properties to distinguish between DataSources that do and do not support Transactions. From what I see, TXDataSource is a property and not a Class or Interface. javax.sql.DataSource is an Interface used to describe interaction 'something that will give you a Connection to the databse' Dave
Karan V Praba
Joined: Oct 31, 2002
Hai David O'Meara, Thanks a lot for your explaination. Still I have one more doubt.Instead of getting the connection from DataSoruce We could get it from JNDi name of connectionPool ,isn't it.? What is primary goal of to using DataSoruce..? Please clear me with some example.
Not quite right. You get the DataSource from JNDI, then you get a Connection from the DataSource. J2EE is based on the idea of having services that are supplied by an application server that applications can make use of. This also includes the requrement to create scaleable and distributable applications. If you have applications obtaining their own database connections, there is no maintain dtabase resources, and there are other problems like how much code do you have to rewrite if you swap database vendors, how do you configure other things that need database support (like session persistence) etc A DataSource is a generic 'applications that run on an application servers can get Connections from here' place. Then any extra responsibility that the The DataSource needs to do (like pooling, keeping Connections alive, sharing between multiple applications) can all be done invisibly to the individual applications. All you know is that you can get Connections easily, efficiently and safely, and so can any other application running on the server. Dave