Sitemap

Amicuk Programming Answers

[Bug] Or feature? Database connection closed if given a name after first op

-0001-11-30   Views:0

Advertisement

I am not sure if this is a bug or a feature. oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase("sample", conn); If I supply a name for the database as the above line using "sample", the database

I am not sure if this is a bug or a feature.
oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase("sample", conn);
If I supply a name for the database as the above line using "sample", the database connection is closed after the first op, i.e., you can call
db.listObjects once, but the second time, it will fail with StackOverFlowException. But the culprit is the database connection is closed after the first op.
However, if I don't give it a name, using null,
oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase(null, conn);
There's no problem at all.
Is this a bug or a feature?
If a feature, the JavaDoc made it worse, by using the following example:
http://www.oracle.com/technology/products/jdev/esdk/api1013/oracle/javatools/db/DatabaseFactory.html
The DatabaseFactory should be used over the DBObjectProviderFactory when a Database specifically is required, and the name and Connection of that Database are available.
e.g.
java.sql.Connection conn = // the Connection to the db
DatabaseFactory.findOrCreateDatabase( "ora10g", conn );
The example sure sounds like a name is mandatory. Or perhaps the name is not some random name, but TNSName? If so, the Doc should certainly mention that.

The replay answer
Advertisement
I am not sure if this is a bug or a feature.
oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase("sample", conn);
If I supply a name for the database as the above line using "sample", the database connection is closed after the first op, i.e., you can call
db.listObjects once, but the second time, it will fail with StackOverFlowException. But the culprit is the database connection is closed after the first op.
However, if I don't give it a name, using null,
oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase(null, conn);
There's no problem at all.
Is this a bug or a feature?
If a feature, the JavaDoc made it worse, by using the following example:
http://www.oracle.com/technology/products/jdev/esdk/api1013/oracle/javatools/db/DatabaseFactory.html
The DatabaseFactory should be used over the DBObjectProviderFactory when a Database specifically is required, and the name and Connection of that Database are available.
e.g.
java.sql.Connection conn = // the Connection to the db
DatabaseFactory.findOrCreateDatabase( "ora10g", conn );
The example sure sounds like a name is mandatory. Or perhaps the name is not some random name, but TNSName? If so, the Doc should certainly mention that.

Go to See the other 7 answers

Database connection closing in JSF

Category:DefaultRelease time:-0001-11-30Views:130

This is regarding Database connection closing in JSF. in servlets we have destroy method where we will be closing the database connections, similarly in JSF where should we close the database connections? is it taken care by the framework? is there a[More]

[Bug] Or feature? Database connection closed if given a name after first op

Category:DefaultRelease time:-0001-11-30Views:130

I am not sure if this is a bug or a feature. oracle.javatools.db.Database db = oracle.javatools.db.DatabaseFactory.findOrCreateDatabase("sample", conn); If I supply a name for the database as the above line using "sample", the database[More]

When are database connections closed?

Category:DefaultRelease time:-0001-11-30Views:130

Hello. This post is related to the post that I made the earlier today. If I am using an external connection pool with TopLink at what point is a connection returned to the pool? If I have a ClientSession does it happen when I call release? Similarly,[More]

JDeveloper: not retaining database connections when starting

Category:DefaultRelease time:-0001-11-30Views:130

Hello, I've just had a machine rebuild, and after installing JDeveloper, importing my previous JDeveloper database connections, closing JDeveloper, and then restarting it, the connections have all been lost. I then have to import again, which works u[More]

Database connection not closing on time out

Category:DefaultRelease time:2015-10-11Views:130

Hi All, Not sure if this is the right place for this question but.. I've moved my app (built using jdev10.1.2., adf bc's and jsp's) to an app server. For some reason, the database connection is not closing. I have 46 connections to the database and I[More]

Closed database connection in olap worksheet

Category:DefaultRelease time:2015-10-11Views:130

i have installed analytic workspace manager after applying the pathches ,i tried to log in analytic workspace manager and connect to olap worksheet it gives me an error as "closed database connection" .My patch installation was successful and it[More]

Database Connections Not Closing

Category:DefaultRelease time:-0001-11-30Views:130

I'm using iBatis for PostgreSQL database access and frequently have problems with connections not being closed. Here is a copy of my sqlMapConfig file: ============================ <?xml version="1.0" encoding="UTF-8" ?> <!DOC[More]

ORCL Failed to connect to database instance: Closed Connection.

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, i am getting ORCL Failed to connect to database instance: Closed Connection, on my work environment but when i look into the database it is ok more over this ticket is generated from GridControl , i checked in trace-file but i haven't got any[More]

Closing the database connection after report in a server application

Category:DefaultRelease time:2015-10-11Views:130

I searched these forums and the internet for a definitive answer on asking the Crystal SDK for java to close the jdbc connection after it has generated a report.  We have been using the Crystal Report SDK to generate reports within our JEE applicatio[More]

Database connection not closed in Destroy()  method of servlet

Category:DefaultRelease time:2015-10-11Views:130

Hi, I have a problem with my deployed web application. At first, I thought Glassfish was messing up on me, and after checking the log I could see plenty of null pointer exceptions being thrown at lines in my code where I generate prepared statements[More]

KIMYONG : Applications Database Connection Pool 관련 parameter 설명

Category:DefaultRelease time:-0001-11-30Views:130

Purpose JVM 이 과도한 CPU / Memory를 사용하게 되어 Application Performance에 영향을 미칠때가 있으며 이럴경우 Connection Pool 관련하여 Parameter Tunning을 해야 할때가 있습니다. 이때 사용되는 Parameter들의 의미를 설명하고자 합니다. The Applications Database Connection Pool is a pool of JDBC database connection[More]

Hot
I have two pages that call a shared "edit" page. When page 1 calls the edit page and the Update button is pressed I want to branch back to page1. When page 2 calls the edit page I want to branch back to page 2. I am using an edit button with the [More]
Hi, I have a program which creates a file from the master data in one system (Logistics), and I have another program in   another system (HR) which writes the contents from this file to a custom table. I want to the avoid manual movement of the file [More]
Dear Expert, My Portal has suddenly giving me a very strange error. When i am trying to click on a link in portal which is supposed to call a BPM application where the UI is designed in Webdynpro for Java, i am getting an error saying - Website can n [More]
hello i have a problem, i transfer my iphoto library from my brother account to my account, and when i try to open them i can't because my mac tell me that i don't have license and power to do that. I've tried to change sharing settings from my broth [More]
I downloaded and installed 10.2.1.537 using BB Link and 1st I had battery life issues which got solved after 1 day, but the 3rd day after installing the new update my phone died, and now it just doesn't turn on. If I connect it to the wall charger or [More]
Hi All, Doing IDOC to EDI scenario. Iam using AS2 adapter to send the messages to partner system and i need to receive the MDN from partner system. 1. what are configuration settings i need to provide in AS2 receiver adapter? 2. I need to put option [More]
Hi Experts, I am trying to create a agent in 11g. And deliver the report on to the phone/Handheld devices. Can some one help me with this? I would appreciate the help. Thanks, Kumar Edited by: 807167 on Nov 30, 2010 3:28 PMfollow the steps the send e [More]
Hi All,       I want to create F1 Help for radio button in my report program. Which function module should i call in <b>at selection screen on help-request</b>       Also do I need to define the texts somewhere or I can pass it directly to the [More]
How do you know what generation ipod you have?See if this helps; http://docs.info.apple.com/article.html?artnum=61688 Cheers! -BryanRead other 4 answers [More]
I have a puzzle. I have a listener.ora file which lists 4 services. (4 SIDS). when I start the service, I do a status command and it lists the 4 services as defined in the listener.ora, as expected, however a couple of minutes later it adds more serv [More]