File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Creating datasource  and Closing connection? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Creating datasource  and Closing connection?" Watch "Creating datasource  and Closing connection?" New topic
Author

Creating datasource and Closing connection?

scott miles
Ranch Hand

Joined: Jun 16, 2011
Posts: 70

1)When we get a connection using datasource say oracleDatasource .
Lets say during programming, some developer does not close the connection
explicity. Will that connection be returned to connection or will it
be considered as connection leak.

2) As it is said , datasource is created, deployed, and managed separately(by appserver) from the applications that use it. There are two ways in which we can create datasource
A) From appserver admin console. (I understand that datasource can be managed by appserver here)
B) Second way is to create datasource in your pragramme like Datasource ds = new OracleDataSource(); But how will datasource be managed by appserver asi n this case as we are creating it in our programme.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26155
    
  66

1) While the connection will eventually be returned to the pool, it is still a connection leak. It takes time for the connections to be returned and you can run out in the meantime.

2) A datasource created in the code will not be managed by the server. It's useful for testing, but better to define the datasource more globally in real code.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Creating datasource and Closing connection?
 
Similar Threads
Connection Pooling Problem
i am using orcale, mysql databases , if i use context.xml i can get datasource for only one db
Auditing for Oracle with EclipseLink JPA
connection pooling
what is connection pooling?