When are database connections closed?

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, does it happen for a UnitOfWork when commit() is called? Or, is the connection returned to the pool via the finalize() method of ClientSession/UnitOfWork?
More information on this subject will be greatly appreciated.
Thanks,
Katie

Thanks for your reply.
We are pretty stuck because our application's external connection pool (via a WebSphere DataSource) is set to use a maximum of 10 connections, and all of the connections are used up when there is only one user on the system. Therefore we get an exception from WebSphere when we try to do an operation against the database when all of the connections are in use. We aren't spawning threads or anything. Our application does one query at a time.
It sounds like we are not responsible for releasing connections, so I guess that is not the problem. Is there anything that we could be doing that would cause us to use all of the connections? We could just allocate more connections, but it seems like we will probably just run in to the same problem later when there are more users of the system. I'd rather attack the problem at its core so that we have something that is scalable. Also, our application had been working fine for several months and now this problem has cropped up.
Thanks for all of your help.
Katie Kelly

Similar Messages

  • Database connection closing in JSF

    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 way where we could capture the end of session and then close the database connection?
    I am creating database connection in backing bean as I am not supposed to create a pool of connection objects(I am using tomcat 5.5)
    Thanks in advance for any suggestions about this.

    k_srinivas wrote:
    This is regarding Database connection closing in JSF.OK.
    in servlets we have destroy method where we will be closing the database connectionsThis is at its own already a very bad practice. All database resources like Connection, Statement and ResultSet must be acquired and closed in the shortest possible scope. You should never keep them open as an instance variable and for sure not in a servlet (which lives as long as the application lives). If you keep a connection open that long, it will timeout sooner or later and your application will crash.
    , similarly in JSF where should we close the database connections? is it taken care by the framework?
    is there a way where we could capture the end of session and then close the database connection?No, just acquire and close the resources in the shortest possible scope. To improve performance, introduce connection pooling. But this doesn't mean that you can write the JDBC code the other way. You still need to acquire and close the resources quickly. The connection pooling implementation will worry about actually closing the connection or releasing the connection to the pool.
    I am creating database connection in backing bean as I am not supposed to create a pool of connection objects(I am using tomcat 5.5)
    Thanks in advance for any suggestions about this.This makes no sense. Just make use of Tomcat's own connection pooling facility.
    For more about doing the database access logic the proper way, you may find this tutorial useful: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].

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

    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.

    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.

  • Error when changing database connection

    I changed my connections.properties file to a database other than the one I used to develop my application. I was able to connect to the new database successfully from the application but when I tried to insert a new row I received the following error:
    JBO-26041: Failed to post data to database during "Insert". SQL Statement "BEGIN INSERT INTO ITEMS (ITEM_ID, ITEM_STATUS, CATEGORY, SOURCE_TYPE, IMAGE_TYPE) VALUES (:1,:2,:3,:4,:5) RETURNING ITEM_ID INTO :6; END;".
    ORA-06550: line 1, column 102: PLS-00103: Encountered the symbol "RETURNING" when expecting one of the following...
    Does anyone know what is causing this problem?
    Thanks,
    Joanna.
    null

    Your new database connection must be pointing to an older database which doesn't support the returning clause. I believe this was added in the 8.x series.
    Rob
    null

  • When Are Pooled Connections Freed?

    Hi,
    If I get a connection from a connection-pool while in a transaction, and if I never
    explicitly free the connection via the connection.close() method, will the connection
    ever be returned to the pool?
    If I have a thread that starts a transaction, gets a pooled connection, and ends
    the transaction without closing the connection, will or can the same thread get the
    same connection when it again starts another transaction and starts the cycle all
    over?
    Thanks,
    Mark

    Mark Glatzer wrote:
    Joseph,
    We are inside a transaction, but the connection is from a non-transaction data
    source. It is our practice to always close the connection as soon as we are done
    with it. However, we forgot to close the connection in one place in the code.
    MarkOk. For non-transactional data sources you are on your own, and should
    definitely close them in a finally block so it gets back into the pool for sure.
    Depending on the server version, there may be an RMI-related reference
    to the connection which prevents it from being gc'ed and returned to the pool.
    If you use the pool driver directly, the gc stuff will work.
    >
    >
    Joseph Weinstein <[email protected]> wrote:
    Hi. How are you obtaining your connection? If it's from a TxDataSource,
    and if
    the transaction is in-progress, and maintained by our transaction manager,
    then
    we will close the connection and return it to the pool when the tx ends,
    whether
    you're done or not. It is good practice nevertheless, to close all JDBC
    objects
    as soon as possible.
    Mark Glatzer wrote:
    Hi,
    If I get a connection from a connection-pool while in a transaction,and if I never
    explicitly free the connection via the connection.close() method, willthe connection
    ever be returned to the pool?
    If I have a thread that starts a transaction, gets a pooled connection,and ends
    the transaction without closing the connection, will or can the same threadget the
    same connection when it again starts another transaction and starts thecycle all
    over?
    Thanks,
    Mark

  • Memory leak when using database connectivity toolset and ODBC driver for MySQL

    The "DB Tools Close Connection VI" does not free all the memory used when "DB Tools Open Connection VI" connects to "MySQL ODBC Driver 3.51".
    I have made a small program that only opens and close the connection that I run continously and it's slowly eating all my memory. No error is given from any of the VI's. (I'm using the "Simple Error Handler VI" to check for errors.)
    I've also tried different options in the DSN configuration without any results.
    Attachments:
    TestProgram.vi ‏16 KB
    DSNconfig1.jpg ‏36 KB
    DSNconfig2.jpg ‏49 KB

    Also,
    I've duplicated the OPs example: a simple VI that opens and closes a connection. I can say this definately causes a memory leak.
    Watching the memory:
    10:17AM - 19308K
    10:19AM - 19432K
    10:22AM - 19764K
    10:58AM - 22124K
    Regards,
    Ken
    Attachments:
    OpenCloseConnection.vi ‏13 KB

  • Error when testing database connection

    Hi,
    I've downloaded v 3.0 and when i enter the basic data and test conection, it gives me following error:
    nosuchmethoderror oracle.i18n.text.oraboot.getcharsetmaxcharlen (Ljava/lang/string;)Ljava/lang/string;
    What can i do?
    v2 worked well, but i deleted it...

    Try to create a batch file (datamodeler.bat) under Data Modeler installation folder and put the following two lines in it:
    set ORACLE_HOME=%CD%
    start datamodeler.exe
    Then double click on this file to start Data Modeler.
    Ivan

  • EJB Timer stops when database connection lost

    G'day.
    We use EJB Timers quite successfully in stateless session beans under Sun Java System Application Server 8.1 on Windows Server 2003.
    We start and stop the timers for specific session beans using public intefaces on their respective beans. This works fine.
    The problem we have is when the JDBC connection used by the EJBTimer service is dropped, such as when the remote database / machine falls over or (probably) when the network is lost. All the timers stop working at this point.
    The timers do not restart when the database connection is restored either, despite the entries still being in the ejb__timers__tbl table.
    If we stop and start the application server instance then they do restart.
    We've looked at the setup of the timers but this seems to be pretty straightforward with no options that seem to influence this.
    We've tried altering the JDBC connection validation settings but this doesn't seem to have made any difference.
    Anyone have any ideas?
    Robski!

    There are no special options to handle this case in the current timer service implementation. Please file an issue describing the scenario here :
    https://glassfish.dev.java.net/servlets/ProjectIssues
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Alert error when master database is down

    When the master database is down (server maintenance, offline back up) a lot of error messages appear in the alert.log of the slave database. Is possible to disable registration of error ORA 12012 and related when master database is closed ??

    No, errors reported by the SNP processes, like most background processes, are always recorded in the alert.log
    -- Anita
    Oracle Support Services
    null

  • Pooled database connections are not being closed properly

    We are using WLS 9.2 and Microsoft SQL Server 2005 (version 1.1 of the Microsoft JDBC driver), and we are experiencing some strange behavior with the lifecycle of the connections in our data source pools. The WLS console may report that the current capacity of a pool is 5, but the database monitoring tools report that we have more than 5 connections open. It almost seems as though connections are getting dropped somehow and WLS thinks it has closed them and created new ones, but the original connections are never actually closed in the database. Our application is the only thing connecting to the DBMS instance in question, so the connections we are seeing have definitely been created by WebLogic. Any suggestions for tracking down the source of this problem would be greatly appreciated.
    Regards,
    Sabrina

    SabrinaL wrote:
    Thank you for your help. Here is our pool configuration (NOTE: Even though we're not using Oracle, we actually did create our own empty "DUAL" table to use for testing connections):
    <jdbc-connection-pool-params>
    <initial-capacity>10</initial-capacity>
    <max-capacity>10</max-capacity>
    <shrink-frequency-seconds>0</shrink-frequency-seconds>
    <test-frequency-seconds>0</test-frequency-seconds>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <test-table-name>DUAL</test-table-name>
    </jdbc-connection-pool-params>
    I'm not sure exactly when the problem starts occurring because we only recently
    noticed it; as far as we can tell, it's pretty random. We have seen occasional
    application errors where it appears that the app cannot obtain a connection from
    the pool, but I'm not sure if that issue is directly related to this particular
    problem. We were careful to scale our pool size such that it should always have
    enough connections, so I'm not sure how this is possible. We are running a cluster.
    Regards,
    SabrinaOk, then for every server in the cluster, the server will make 10 connections.
    Because you are using SQLServer, your 'test table' (that is an overloaded
    field) should be set to actually define SQL that we can use for a quick test:
    <test-table-name>SQL select 1</test-table-name>
    That will be quicker than selecting from any real table.
    We would need more info about the problem. If you turn on
    JDBC logging, we might capture the exceptions that indicate
    problems with the pool, however, as configured, the pools
    will have only 10 connections, and will close and replace
    any that fail the test. Do you have a firewall between the
    DBMS and WebLogic?
    Joe

  • When using the Database Connectivity Toolset, reads and writes with long binary fields are incompatible.

    I am trying to write LabVIEW Variants to long binary fields in a .mdb file using the Database Connectivity Toolset. I get errors when trying to convert the field back to a variant after reading it back from the database.
    I next tried flattening the variant before writing it and ultimately wound up doing the following experiments:
    1) If I use DB Tools Insert Data to write an ordinary string and read it back using a DB Tools Select Data, the string is converted from ASCII to Unicode.
    2) If I use DB Tools Create Parameterized Query to do an INSERT INTO or an UPDATE operation, specifying that the data is BINARY, then read it back using a DB Tools Select Data,
    the length of the string is prepended to the string itself as a big-endian four-byte integer.
    I can't think of any way to do a parameterized read, although the mechanism exists to return data via parameters.
    Presuming that this same problem affects Variants when they are written to the database and read back, I could see why I get an error. At least with flattened strings I have the option of discarding the length bytes from the beginning of the string.
    Am I missing something here?

    David,
    You've missed the point. When a data item is flattened to a string, the first four bytes of the string are expected to be the total length of the string in big-endian binary format. What is happening here is that preceding this four-byte length code is another copy of the same four bytes. If an ordinary string, "abcdefg" is used in place of the flattened data item, it will come back as <00><00><00><07>abcdefg. Here I've used to represent a byte in hexadecimal notation. This problem has nothing to do with flattening and unflattening data items. It has only to do with the data channel consisting of writing to and reading from the database.
    I am attaching three files that you can use to demonstrate the problem. The VI file c
    ontains an explanation of the problem and instructions for installing and operating the demonstration.
    Ron Martin
    Attachments:
    TestLongBinaryFields.vi ‏132 KB
    Sample.UDL ‏1 KB
    Sample.mdb ‏120 KB

  • How to share the same Database Connection when using several Task Flows ?

    Hi All,
    I’m using JDev 11.1.1.3.0.
    I’m developing ADF Fusion Applications (ABC BC, ADF Faces…)
    These applications are deployed on a Weblogic server.
    Each application has only one Application Module.
    All Application Modules have the same connection type defined: JDBC DataSource : jdbc/GCCDS
    It is working fine.
    I’ve also developed Task Flow Applications for small thinks that are reused in multiple main applications.
    Each Task Flow Application has also one Application Module with the same connections type as main applications.
    All these task flows are deployed to JAR file (ADF Library JAR File) and are reused on my main applications. (drag and drop from the Resource Palette to ADF Regions….).
    There are some parameters passed to Task Flows, so that they can filter data depending on which main applications they are called from.
    Everything is working perfectly.
    All my main applications are using more and more task flows. Which is nice for the reusability etc…?
    Only ONE PROBLEM: DATABASE CONNECTIONS.
    Every Task Flows service made a database connection. So one user may have 10 database connections for the same adf page. And when there are 100 users that are working at the same time, it becomes a problem.
    How to share the same database connections for the main applications and all task flows which are used in the main application?
    Best Regards
    Nicolas

    Hi John,
    When I open a ADF Library JAR file of one of my task flow. (gcc_tf_recentSites.jar)
    I can see TF_RecentSitesService.xml and TF_RecentSitesServiceImpl.class in gcc_tf_recentSites.jar\mu\gcc\tf\recentSites\model\service folder
    + bc4j.xcfg in gcc_tf_recentSites.jar\mu\gcc\tf\recentSites\model\service\common folder.
    bc4j.xcfg details are
    +<?xml version = '1.0' encoding = 'UTF-8'?>+
    +<BC4JConfig version="11.1" xmlns="http://xmlns.oracle.com/bc4j/configuration">+
    +<AppModuleConfigBag ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService">+
    +<AppModuleConfig DeployPlatform="LOCAL" jbo.project="mu.gcc.tf.recentSites.model.TF_RecentSites_Model" name="TF_RecentSitesServiceLocal" ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService">+
    +<Security AppModuleJndiName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService"/>+
    +<Custom JDBCDataSource="jdbc/GCCDS"/>+
    +</AppModuleConfig>+
    +<AppModuleConfig name="TF_RecentSitesServiceShared" ApplicationName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService" DeployPlatform="LOCAL" JDBCName="gccdev" jbo.project="mu.gcc.tf.recentSites.model.TF_RecentSites_Model">+
    +<AM-Pooling jbo.ampool.maxpoolsize="1" jbo.ampool.isuseexclusive="false"/>+
    +<Security AppModuleJndiName="mu.gcc.tf.recentSites.model.service.TF_RecentSitesService"/>+
    +</AppModuleConfig>+
    +</AppModuleConfigBag>+
    +</BC4JConfig>+
    So, it seems that the Application Module is packaged with the task flow....
    Is it normal ?
    Regards
    Nicolas

  • When iPhone is connected to PC, it shows in itunes but Autoplay does not open for me to copy photos. I tried the Control Panel, changing Autoplay settings but no use. I use a Windows Vista. Please help! All my little ones' pictures are on my iPhone 3GS

    When iPhone is connected to PC, it shows in itunes but Autoplay does not open for me to copy photos. I tried the Control Panel, changing Autoplay settings but no use. I use a Windows Vista. Please help! All my little ones' pictures are on my iPhone 3GS.
    I tried hard reset on my iPhone. I tried restarting laptop and iPhone. I tried a different laptop. I tried removing driver and reinstalling from Device Manager but did not find a driver other than "Apple Mobile Device USB Driver" under "Universal Serial Bus controllers" which I heard shouldn't be uninstalled.
    Anything I haven't tried?
    HELP!

    A bit confused by your statement
    bcboarder wrote:
    . I do not understand why the music is clearly on the Ipod but wont reconize it anywhere.
    Are you seeing your music listed in the iPod screen, or in Win explorer as in your earlier post?
    I can see all the songs in my Edrive>al's Ipod> Ipod Control> Music folder.
    A corrupted iPod database, will report zero music used, and have your music size reported as others, so you wont see the music in the iPod screen. Sorry, I thought there was some hope for you with iPodAccess, in recovery of the corrupted iPod database with your ratings.
    You can try to borrow and  use the Mac Disk Utility ->First Aid ->Repair.
    Of course, if your iPod Hardisk is in a bad state, from the Disk Diagnostic report, then all my suggestion are futile.

  • TS1363 Ipod does not appear in my computer or recognized in itunes. When ipod is connected a window pos up aking to import photos off the device and when this is closed the ipod cannot be recognized. Any Help?

    Ipod does not appear in my computer or recognized in itunes. When ipod is connected a window pos up aking to import photos off the device and when this is closed the ipod cannot be recognized. Any Help?

    Which OS are you using? 
    In the meantime, research your problem in Knowledge Base. 

  • Getting Error when trying to connect to the Primavera database. PPM V7 SP3

    Hi Guys,
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService' defined in class path resource [com/primavera/bre//com/primavera/bre/integration/intgconf.xml]: Invalid destruction signature; nested exception is org.springframework.beans.factory.support.BeanDefinitionValidationException: Couldn't find a destroy method named 'destroy' on bean with name 'mailService'
    I have looked into the intgserver.jar under P6IntegrationAPI/lib and looked the com.primavera.infr.srvcs.MailServiceImpl.java and can see that there is no destroy method whereas it is defined in the com.primavera.bre.intergration.intgconf.xml as below
    <!-- provides mail services -->
    <bean id="mailService" class="com.primavera.infr.srvcs.MailServiceImpl" init-method="init" scope="singleton" destroy-method="destroy"*+>
    <property name="adminManager"><ref bean="adminManager"/></property>
    <property name="threadPool"><ref bean="threadPool"/></property>
    <property name="settingsManager"><ref bean="settingsManager"/></property>
    </bean>
    I get the above error when trying to connect to the Primavera database. I use PPMV7 SP3 and I have installed the Integration API from EPPMV7 bundle.
    My demo's are working fine.
    Any help would be appreciated.
    Thanks,
    Kajal.

    Hi Marc,
    I am using a userid (is an admin)
    Using global login method and provided userid & password in integration settings.
    In the machine profiles, provided userid, password and domin.
    Not providing domain in weblogin.
    With all the above I am still getting error "Could not authenticate the specified user. %0" for HFM application
    And with the same settings I am not getting any error to connect to essbase cube.
    Any suggestions?
    Thanks
    Krishna

Maybe you are looking for

  • Error message while trying to open mpeg file

    Hello, I'm new to the apple discussions, but not new to the Apple family. I recently downloaded a quicktime and got the following message: Error opening movie The movie could not be opened. Its a file from a bittorrent site. Any help in opening this

  • Process multi-record & multi-record-format files using ESB & File Adapter

    I am looking to process/parse an in-bound file with the following make-up and to load into a database table using the File Adapter, ESB and DB Adapter. File Make-Up: - each line in the file is a record - each record is made up of 12 fields - there ar

  • Crystal Report XI R2 Default Font Problems

    I have set the all the default font in all types to "Times New Roman" as requested by my supervisor (Although I dislike the font =.=) It works correctly for generated field, new text objects or drop a new database field. But whenever I type text in t

  • Client and GUI concurrently ?????

    hi everybody, i got a problem about gui and client. I have created a jframe and i want it to e client which connects to a server and gets the server's message. The problem is; when i created gui first, it starts to listen actions and client can't run

  • NetApp vs HP EVA

    I am looking for comments about both of these storage vendor for virtualization with VMware.    Both of these companies are key players in the storage market.    We plan to virtualize everything we can oracle, exchange, file services and various sing