[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.

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].

  • Help! My database connection from BMP Entity bean dies after a while!!!

    Hi all!
    I posted a related post about this lately How do I use connection pooling from BMP Entity Beans in OC4J 10.1.2? but it didn't solve my problems.
    I have some entity beans coded with BMP, so I handle all database stuff myself. I have set up datasources.xml like this:
        <data-source
            class="com.evermind.sql.DriverManagerDataSource"
            name="OracleDS"
            location="jdbc/OracleCoreDS"
            xa-location="jdbc/xa/OracleXADS"
            ejb-location="jdbc/OracleDS"
            connection-driver="oracle.jdbc.driver.OracleDriver"
            username="scott"
            password="tiger"
            url="jdbc:oracle:thin:@//URL TO DB:SID"
            inactivity-timeout="30"
            min-connections="10"
            max-connections="50"
        />All JNDI connection lookup is done through the ejb-location as I should. I have been through all my try {} catch {} finally {} blocks, so ensure that I close all objects after use.
    After a few hours of inactivity, my program dies. I have inserted a lot of debug statements (System.out.println()), and it seems like the program hangs when it's trying to execute a PreparedStatement.
    I.e. it dies when I do ps.ExecuteQuery in the code below (NOTE: to make things easier to read, I have stripped out all error handling here):
        Context ic = new InitialContext();
        DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
        c = ds.getConnection();
        System.out.println("DEBUG: Got database connection.");
        PreparedStatement ps = c.prepareStatement("SELECT foobar FROM footable WHERE foo=?");
        System.out.println("DEBUG: Prepared SQL statement.");
        ps.setString(1,"foo");
        ResultSet rs = ps.executeQuery();
        // Close all objects (rs, ps, c) here.My database is on another physical server, so I wonder if this is caused by an unstable network, or?
    Please help!
    ~Morten

    Hi again!
    Sorry for the delay, but I have been busy lately.
    Anyway: Our application server is 10.1.2, so I don't think patch 4307303 is relevant here. Database server is Oracle 9.2.0.6. Everything runs on Linux (of course) ;-).
    Here's a thread dump:
    Full thread dump Java HotSpot(TM) Server VM (1.4.2_04-b05 mixed mode):
    "ApplicationServerThread-8" prio=1 tid=0x089a9448 nid=0x5902 in Object.wait() [885e6000..885e687c]
         at java.lang.Object.wait(Native Method)
         at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:353)
         - locked <0x91a31e60> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:767)
         at com.evermind.util.ReleasableResourcePooledExecutor.myGetTask(ReleasableResourcePooledExecutor.java:151)
         at com.evermind.util.ReleasableResourcePooledExecutor.access$000(ReleasableResourcePooledExecutor.java:33)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:190)
         at java.lang.Thread.run(Thread.java:534)
    "AJPRequestHandler-ApplicationServerThread-7" prio=1 tid=0x08d78a58 nid=0x5902 runnable [8b2f4000..8b2f587c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.net.ns.Packet.receive(Unknown Source)
         at oracle.net.ns.DataPacket.receive(Unknown Source)
         at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.net.ns.NetInputStream.read(Unknown Source)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:978)
         at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:950)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:434)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:661)
         at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:959)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:693)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1065)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2901)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2942)
         - locked <0x914cad08> (a oracle.jdbc.driver.T4CPreparedStatement)
         - locked <0x920256c0> (a oracle.jdbc.driver.T4CConnection)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:270)
         at com.evermind.sql.PreparedStatementBCELProxy.executeQuery(PreparedStatementBCELProxy.java:31)
         at com.brunata.servicerapport.ejb.CustomerBean.ejbCreate(Unknown Source)
         at CustomerLocalHome_EntityHomeWrapper2.create(CustomerLocalHome_EntityHomeWrapper2.java:420)
         at com.brunata.servicerapport.BeanFactory.getCustomerBean(Unknown Source)
         at com.brunata.servicerapport.CustomerOpenAction.execute(Unknown Source)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at com.brunata.servicerapport.CustomerAuthorizationFilter.doFilter(Unknown Source)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-23" daemon prio=1 tid=0x092ebb18 nid=0x5902 in Object.wait() [88565000..8856587c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x920000f0> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "Thread-22" daemon prio=1 tid=0x092eb988 nid=0x5902 in Object.wait() [8dfa0000..8dfa087c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92000188> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPRequestHandler-ApplicationServerThread-6" prio=1 tid=0x08c03240 nid=0x5902 runnable [8b0f1000..8b0f187c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.evermind.io.SingleReadBufferInputStream.readChunk(SingleReadBufferInputStream.java:116)
         at com.evermind.io.SingleReadBufferInputStream.read(SingleReadBufferInputStream.java:35)
         at com.evermind.server.http.AJPRequestHandler.readAJPPackets(AJPRequestHandler.java:462)
         at com.evermind.server.http.AJPRequestHandler.initRequest(AJPRequestHandler.java:396)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:185)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    "DestroyJavaVM" prio=1 tid=0x08053278 nid=0x5902 waiting on condition [0..bfffcac4]
    "OC4JMonitorThread" daemon prio=1 tid=0x08d7a5a0 nid=0x5902 in Object.wait() [88667000..8866787c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:253)
         - locked <0x92aed1f8> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:226)
         at oracle.ons.Subscriber.receive(Subscriber.java:136)
         at com.evermind.server.OC4JMonitorThread.run(OC4JMonitorThread.java:315)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-6" daemon prio=1 tid=0x087f9f98 nid=0x5902 in Object.wait() [886e8000..886e887c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aed368> (a java.lang.Object)
         at java.lang.Object.wait(Object.java:429)
         at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:255)
         - locked <0x92aed368> (a java.lang.Object)
         at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:215)
         at oracle.ons.SenderThread.run(SenderThread.java:81)
    "Thread-5" daemon prio=1 tid=0x087f9d10 nid=0x5902 runnable [88769000..8876987c]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at oracle.ons.InputBuffer.readMoreData(InputBuffer.java:267)
         at oracle.ons.InputBuffer.getNextString(InputBuffer.java:222)
         at oracle.ons.ReceiverThread.run(ReceiverThread.java:228)
    "TaskManager" prio=1 tid=0x087f9b30 nid=0x5902 waiting on condition [887ea000..887ea87c]
         at java.lang.Thread.sleep(Native Method)
         at com.evermind.util.TaskManager.run(TaskManager.java:247)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "Thread-4" prio=1 tid=0x08ca2fb8 nid=0x5902 in Object.wait() [891e2000..891e287c]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.mainLoop(Timer.java:429)
         - locked <0x92aee258> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:382)
    "AJPConnectionListener [0.0.0.0/0.0.0.0:3302]" prio=1 tid=0x086f1668 nid=0x5902 runnable [8a7ca000..8a7ca87c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0390> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.http.AJPConnectionListener.run(AJPConnectionListener.java:60)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "RMIServer [0.0.0.0:3202] count:2" prio=1 tid=0x086cbff0 nid=0x5902 runnable [8b172000..8b17287c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x927a0850> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.rmi.RMIServer.run(RMIServer.java:464)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "JMSServer[webprod:3702]" prio=1 tid=0x0879aff0 nid=0x5902 runnable [8b1f3000..8b1f387c]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)
         - locked <0x92746aa0> (a java.net.PlainSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:448)
         at java.net.ServerSocket.accept(ServerSocket.java:419)
         at com.evermind.server.jms.JMSServer.run(JMSServer.java:516)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    "LogFlusher" daemon prio=1 tid=0x081b91a0 nid=0x5902 waiting on condition [8b274000..8b27487c]
         at java.lang.Thread.sleep(Native Method)
         at oracle.core.ojdl.BufferedLogWriter$Flusher.run(BufferedLogWriter.java:354)
    "Signal Dispatcher" daemon prio=1 tid=0x080ba9e0 nid=0x5902 waiting on condition [0..0]
    "Finalizer" daemon prio=1 tid=0x080b61a8 nid=0x5902 in Object.wait() [8e9a7000..8e9a787c]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
         - locked <0x925b0378> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=1 tid=0x080b5dc8 nid=0x5902 in Object.wait() [8ea28000..8ea2887c]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:429)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
         - locked <0x925b02a0> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=1 tid=0x080b52e0 nid=0x5902 runnable
    "VM Periodic Task Thread" prio=1 tid=0x080bee08 nid=0x5902 waiting on condition
    "Suspend Checker Thread" prio=1 tid=0x080b9fc8 nid=0x5902 runnable As far as I can see, my PreparedStatement (or connection) is locked.... Any ideas?
    ~Morten ;-)

  • 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

  • How database connection pooling works in a application

    Hi Guys,
    I am new to Java and looking into best way of doing J2ee database conectivity. I am using Eclipse galileo3.5 J2EE with Mysql database and Tomcate 6.0.
    I am developing an email application where I need to implement MVC model for my webapplication, using jsp for presentation, servlet for control and java beans for model.
    I came across two tutorial for database connection pooling as given below.
    Eclipse Corner Article: Creating Database Web Applications with Eclipse - In this tutorial connection pooling is configure in Tomcate 6.0
    It says Copy and paste the following into your context.xml file (you may have to click on the Source tab at the bottom of the editor to be able to paste). This defines a DataSource with the name "jdbc/SampleDB". Our application will retrieve database connections from the pool using this name.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
    <Resource name="jdbc/SampleDB" auth="Container"
    type="javax.sql.DataSource"
    username="app" password="app"
    driverClassName="org.apache.derby.jdbc.ClientDrive r"
    url="jdbc:derby://localhost:1527/sample"
    maxActive="8" />
    </Context>
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    It uses java bean for connection pooling and then use straight way in JSP and no Servlet used.
    conpool.jsp
    <%@page import="java.sql.Connection"%>
    <jsp:useBean id="pl" class="com.CoreJava.ConnectionPooling"/>
    <% Connection con = pl.getConnection(); %>
    //do something using con
    connectionPooling.java
    import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolD ataSource;
    public class ConnectionPooling
    static Connection con=null;
    public static Connection getConnection()
    try
    MysqlConnectionPoolDataSource po=new MysqlConnectionPoolDataSource();
    po.setServerName("localhost");
    po.setPortNumber(3306);
    po.setDatabaseName("mydatabase"); //changeur database name
    po.setUser("root");//ur username
    po.setPassword("");//ur password
    con = po.getConnection();
    catch(Exception e)
    System.out.println("Exception Connection :"+e);
    return con;
    Please some one explain which is the best way of doing connection pooling to the database by using MVC pattern
    Please if some one advise me how to use MVC architecture for simple email application and database connectivty.
    Thanks

    >
    >
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    Never EVER use roseindia. It is terrible shit.
    [http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html]
    The correct answer is what you found in the eclipse article. And you can read the Tomcat docs for more.
    As per usual the code you have posted from Roseindia is a big pile of rubbish that was written by a complete idiot. I mean the person who wrote it apparently doesn't know much Java at all. Let alone JDBC. Or Connection pools. Or J2EE. It's not the worst I've seen from them but it's pretty bad.

  • Killing a Database connection..!

    Hi,
    Iam using Java1.3.1 and Oracle8.1.7 as my database.I used Connectionpooling in my JSP application,It worked fine.I did some mistake(changed min_dbconnections value)and found the Database connection is still active in my Oracle database even after i closed my JSP application.
    My question is.,
    1)How can i close that connection?
    2)Is it possible to close without doing anything directly on Oracle?
    3)Can i close the connection,if i restart my Tomcat?
    4)Is there anything todo on Tomcat to implement Connectionpooling?
    There is noting wrong in the Connectionpooling program(Iam using DbConnectionBroker program to implement my pooling)
    Any help will be appreciated..
    Regards
    Rao

    Hi vidya,
    Iam using the same program.So,you can use that.After running the servlet program for 4 to 5 times,Can you please also see on your Oracle database(SQL prompt)whether is there there any connection in active state.
    Pls check your number of database connections opened(or Active)before and after executing your servlet.
    In my case,I got my database connections(2) are still in active state(opened/not killed) even when i terminate the Servlet program.
    pls let me know if you didnt understand....,
    regards
    Rao

  • Dynamic Parameter Prompting for Database Connection Password

    Post Author: rsharp
    CA Forum: Publishing
    Hi
    I've been finding recently that reports using dynamic parameters and published into Crystal Server prompt for the database connection password when the dynamic parameter is accessed.  Thing is, this only started happening recently for new and already existing reports with dynamic parameters and I don't know why.  In Crystal Reports the dynamic parameter can be accessed without a database connection prompt being displayed but not after publishing.  (Maybe there's a problem with the Publishing Wizard?)  Static parameters work just fine just as they always have, but I'm a bit mystified by the fact that dynamic parameters used to work (without prompting) but now they don't.  Any advice or opinion would be much appreciated.

    Post Author: amr_foci
    CA Forum: Publishing
    from the CMC you have to set the default connection or wat connection should this report use,
    go to this report in CMC, click process tab, and check the connection

  • Jsp JST MySQL - database connection

    Hello
    I am facing a database connection problem. I want to connect to mysql database fro a jsp page that uses JSTL taglibs.
    I am using Tomcat 5.x, JSTL 1.1. MySQL 5x
    I have copied jstl.jar, standard.jar and mysql driver in the \WEB-INF\lib dir of my application.
    If I connect to the database using scriptlet it works. But If I connect using the sql taglib, it gives me the error
    2008-01-22 14:20:12 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
    my jsp file is as follows
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <c:set var="firstName">request.getParameter("name")</c:set>;
    <%= request.getParameter("name") %>
    <sql:setDataSource
    var="myDS"
    scope="request"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/contact_db"
    user="root"
    password=""
    />
    <sql:query var="phone_book" dataSource="$(myDS)">
    Select last_name, home, cell, office from phone_book where first_name = ?
    <sql:param value="firstName"/>
    </sql:query>
    <HTML>

    hi thanks
    please let me know whats the better approach for getting an database connection if this is not recommended.
    after some modifications i am not getting the no suitable driver error. I also updated the code as per your comments. ...yet am not seeing any results.
    I have modified the file as follows.
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
    String firstName = request.getParameter("name");
    %>
    <%= firstName %>
    <sql:setDataSource
    var = "firstDS"
    scope="request"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/contact_db"
    user="root"
    password=""
    />
    <sql:query var="phone_book" dataSource="${firstDS}">
         Select * from phone_book where first_name = ?
         <sql:param value="${firstName}"/>
    </sql:query>
    <c:forEach var="phone_book" items="${user.rows}">
         <tr>
    <td><c:out value="${row.no}"/></td>
    <td><c:out value="${row.first_name}"/></td>
    <td><c:out value="${row.last_title}"/></td>
    <td><c:out value="${row.home}"/></td>
    <td><c:out value="${row.cell}"/></td>
    <td><c:out value="${row.office}"/></td>
    </tr>
    </c:forEach>
    <HTML>
    <BODY>
         Hello
    </BODY>
    </HTML>

  • Ssh_exchange_identification: Connection closed by remote host

    Hello, I'm running OSX 10.8.4 and I'm trying to SSH to my University server and I'm getting this :
    Ahmads-MacBook-Pro:ahmad716 Ahmad716$ ssh -vvv
    OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
    debug1: Reading configuration data /etc/ssh_config
    debug1: /etc/ssh_config line 20: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to t2.technion.ac.il [132.68.1.134] port 22.
    debug1: Connection established.
    debug1: identity file /Users/Ahmad716/.ssh/id_rsa type -1
    debug1: identity file /Users/Ahmad716/.ssh/id_rsa-cert type -1
    debug1: identity file /Users/Ahmad716/.ssh/id_dsa type -1
    debug1: identity file /Users/Ahmad716/.ssh/id_dsa-cert type -1
    ssh_exchange_identification: Connection closed by remote host
    Please help
    <Email Edited by Host>

    I had exactly similar problem.
    i was getting this error:
    ssh -vv eagle
    OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
    debug1: Reading configuration data /etc/ssh_config
    debug1: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to eagle [192.168.0.194] port 22.
    debug1: Connection established.
    debug1: identity file /Users/yerbol/.ssh/identity type -1
    debug1: identity file /Users/yerbol/.ssh/id_rsa type -1
    debug1: identity file /Users/yerbol/.ssh/id_dsa type -1
    ssh_exchange_identification: Connection closed by remote host
    but after trying your suggestion:
    sudo sshd -t
    i got
    /etc/sshd_config: line 112: Bad configuration option: ServerAliveInterval
    /etc/sshd_config: terminating, 1 bad configuration options
    this reminded me that i  had set ServerAliveInterval 20 for avoiding timeout issues with ssh.
    then i changed it back and it worked.

  • Database connection not closing on time out

    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''m the only one with the URL, not good.
    So can anyone shed any light on this? I thought it should disconnect after a time out but its not.
    Any ideas would be gratfully received.
    Thanks in advance

    or try this one..
    Go to the bottom of the tutorial, you will find the configuration...
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bc9baf90-0201-0010-479a-b49b25598ebf

  • Closed database connection in olap worksheet

    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 did not give me any error and my database is also working properly.could anyone help me out with this problem.

    I had the same problem. Follow this link for the solution
    Re: Cannot connect to AWM

  • Database Connections Not Closing

    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" ?>
    <!DOCTYPE sqlMapConfig
    PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
    <sqlMapConfig>
    <properties resource="ibatis.properties" />
    <settings
    lazyLoadingEnabled="true"
    cacheModelsEnabled="true"
    enhancementEnabled="false"
    useStatementNamespaces="false"
    />
    <transactionManager type="JDBC" commitRequired="true">
    <dataSource type="DBCP">
    <property name="driverClassName" value="${driver}" />
    <property name="url" value="${url}" />
    <property name="username" value="${username}" />
    <property name="password" value="${password}" />
    <property name="maxActive" value="10"/>
    <property name="maxIdle" value="5"/>
    <property name="maxWait" value="5000"/>
    <property name="logAbandoned" value="true"/>
    <property name="removeAbandoned" value="true"/>
    <property name="removeAbandonedTimeout" value="1"/>
    <property name="Driver.logUnclosedConnections" value="true"/>
    </dataSource>
    </transactionManager>
    <sqlMap resource="job-sqlMap.xml" />
    </sqlMapConfig>
    ============================
    Due to the logAbandoned and removeAbandoned settings, I get a report in my log file whenever there is a connection that was not properly closed. Here is one of those log entries:
    23:22:51.483 (10) Finalizing a Connection that was never closed:
    java.lang.Throwable: Connection was created at this point:
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:175)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:393)
    at org.postgresql.Driver.connect(Driver.java:267)
    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1148)
    at org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:84)
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.init(JdbcTransaction.java:48)
    at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:89)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:94)
    at edu.calpoly.lib.multimedia.big.db.AutomaticPeriodUpdateIBatisImplDBHandler.getGamesWithAutomaticUpdatePolicy(AutomaticPeriodUpdateIBatisImplDBHandler.java:154)
    at edu.calpoly.lib.multimedia.big.game.AutoUpdateThread.run(AutoUpdateThread.java:155)
    The file: AutomaticPeriodUpdateIBatisImplDBHandler.java contains an iBatis call on line # 154:
    --> list = sqlMap.queryForList("getGamesWithAutoPolicy", null);
    from the map file:
    <select id="getGamesWithAutoPolicy" resultClass="java.util.HashMap">
    <![CDATA[
    SELECT gameid, policy
    FROM update_policy
    ]]>
    </select>
    Here is the code for the entire method that uses this transaction:
    ============================
    public List getGamesWithAutomaticUpdatePolicy() throws BIGDatabaseFacadeException
    List list = new ArrayList();
    try
    sqlMap.startTransaction();
    list = sqlMap.queryForList("getGamesWithAutoPolicy", null);
    sqlMap.commitTransaction();
    catch(SQLException sqle)
    throw new BIGDatabaseFacadeException(sqle);
    finally
    try
    sqlMap.endTransaction();
    catch(SQLException sqle)
    throw new BIGDatabaseFacadeException(sqle);
    return list;
    ============================
    I know that this should be handled as an automatic transaction, but I tried adding the start, commit and end transaction commands in my desperate attempt to fix this problem (but it still didn't help).
    Here is my code for creation of sqlMap -
    --> sqlMap = SqlMapClientBuilder.buildSqlMapClient(Resources.getResourceAsReader("sqlMaps.xml"));
    Except for the fact that occasionally connections are not closed, overall my database access using iBatis works very well.
    In the course of trying to fix this problem I've worked to update all my lib files to the latest versions, and here is current status:
    My iBatis lib file: ibatis-2.3.4.726.jar
    My JDBC driver: postgresql-8.4-701.jdbc3.jar
    Required commons files:
    commons-dbcp-1.2.2.jar
    commons-pool-1.5.3.jar
    Note that I tried adding --> commitRequired="true" to the transactionManager in sqlMaps.xml, hoping it might help, but no joy.
    Please help me figure out why my database connections often do not close. Thank you very much!

    I'm sorry, but I don't understand what you mean by "close the session." I believe iBatis is supposed to take care of all that automatically. My understanding is that all the user does is create the sqlMapClient and then use it along with various map files to query and update the database. iBatis does the rest.

  • 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

  • ORCL Failed to connect to database instance: Closed Connection.

    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 clue what to do in this case please any one help me on this why it is giving this kind of error
    (ORCL Failed to connect to database instance: Closed Connection.)
    Thanks
    venkat
    Edited by: madala03 on Apr 10, 2013 3:32 AM

    Hi ,
    thanks for the reply i checked in listener log , havent got any connection errors but in sqlnet.log
    i got this
    VERSION INFORMATION:
    TNS for Linux: Version 10.2.0.4.0 - Production
    TCP/IP NT Protocol Adapter for Linux: Version 10.2.0.4.0 - Production
    Time: 10-JAN-2011 12:08:29
    Tracing not turned on.
    Tns error struct:
    ns main err code: 12564
    TNS-12564: TNS:connection refused
    ns secondary err code: 0
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0

  • Closing the database connection after report in a server application

    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 application, built upon the Spring framework, for the past two years.  It works well, especially if you prepare views in the database for your reports.
    From what I can tell once you have used ReportClientDocument to create your report you all the close() method to release resources associated with report generation, but this does not close the jdbc database connection.
    Further research states that if you are using the CrystalReportViewer you can call the dispose method to close the database connection.  We are not using JSP nor this class, so that does us little good.
    Finally I found a post that one could call ((AdvancedReportDocument)reportClientDocument.getReportSource()).dispose().  This doesn't drop the connection either.
    Each report actually opens 3 connections according to SQL Server.  Each report will reuse the connections it has open, so for 50 reports, theoretically, we could have up to 150 connections.  We explained to our client those connections  remain inactive, however this is unacceptable to our client as they would like to minimize the number of connections left open to their database.
    If anyone can post any further information on this issue, it is much appreciated.

    Yes, another team member found the issue.  Quite embarrassing really I didn't see it.  I was looking for the answer within Crystal's libraries.  It had nothing to do with Crystal.
    The developer who wrote the helper code for using Crystal first opened a connection to the datasource for the live production database and read that connection information for the report. Next he set that connection information in the report template's PropertyBag, then ran the report. The developer however forgot to close the connection he used to look up the connection info, leaving a memory leak and using up all the connections.
    I'm glad you inquired.  I forgot to post the resolution here.

Maybe you are looking for

  • Satellite A - DVD drive not seen by Windows Explorer

    THe DVD deive on D is not seen by windows explorer. It used to work but has now disappeared. The dvd hardwars starts up at boot then ceases. Any ideas anyone?

  • TS4127 Magsafe 85w unit fails. Different USA - UK policy by Apple

    I have the same issue - clearly a poorly designed/ assembled product that should last at least 3 years.  My powersafe - 85w T connector - for Macbook pro developed a split cable with very light use. But in UK Apple just wash their hands of any respon

  • Airport problem with WEP

    Hi, I started having problem connecting to WEP 40/128-bit ASCII access point after installing the following updates. http://www.info.apple.com/kbnum/n305031 I always get an error something like.. "There was an error connecting on the airport network

  • Represinting my data and relations between records in diagram " not by the hierarchic

    hi all , if there is a group of people in one table and the other table contains another group of people, and there is a relation between those groups, how to create a form or a report representing diagram for this relation. This diagram should be dy

  • Not all the fonts get smoothed

    http://www.associatedcontent.com/articl - power.html The headline of the article is not smoothed in my system, other text is smoothed. Why? My .fonts.conf: <?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <match target="font