How to correct close database connection after report generation

Hello
I have problem a with alive database connection after report creation and report  closing. How to properly to close connection to database?
Best regards
Edited by: punkers84 on Jun 17, 2011 10:38 AM

that's what I am doing... after viewing the report, I call the close method on the window closing event of the container window. but the connection is still open. I had a lot of other issues with my jdbc driver but after downgrading to an older version those issues are resolved.Only this one is still there! Is there any other way to close the connection (like using dbcontroller or etc.)?

Similar Messages

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

  • How I can close Database connection?

    I am using the following to open Database connections in Java class.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("URL","user","password");
    But I do not know how I can have it closed.
    This cause an SQL error: Maximum open cursors exceeded.

    Thanks so much. Your explanation is so clear.
    Here is the whole code. Thanks for your help.
    package xxx.xx.xxx;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class Format_BaseTable {
    Connection con = null;
    Statement stmt = null;
    Statement stmt1 = null;
    ResultSet rs = null;
    ResultSet rs1 = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    public Format_BaseTable() {}
    public static String valueOf(String oldStr)
    StringTokenizer st = new StringTokenizer(oldStr.trim(), "-");
    char zero = '0';
    String dem_zero = ".0";
    String newStr = "";
    while(st.hasMoreTokens()) {
    String degree = st.nextToken();
    String minute = st.nextToken();
    String second = st.nextToken();     
    if (minute.length() == 1) {
    minute = zero + minute;
    if (second.length() == 1) {
    second = zero + second;
    if (second.length() == 2) {
    second = second + dem_zero;
    if (second.length() == 3) {
    second = zero + second;
    if (second.length() == 5) {
    double d = Double.parseDouble(second);
    second = String.valueOf(Math.round(d));
    newStr = degree + " " + minute + " " + second;
    return newStr;
    public static double feetToMeter(int ft)
    double mt = ft * 0.305;
    return mt;
    public void doConvert() { 
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("url","user","password");
    stmt = con.createStatement();
    stmt1 = con.createStatement();
    rs = stmt.executeQuery("SELECT cla_seqnum, str_leased, nad27_lat, nad27_lon, nad83_lat, nad83_lon, ge_ft, sh_ft, osh_ft, ov_faa_approv_ft, ant_tip_ft, ant_ctr_line_ft FROM cl_antenna_base WHERE application_user_id = 'SQL LOADER'");
    rs1 = stmt1.executeQuery("SELECT mwa_seqnum, nad27_lat, nad27_lon, nad83_lat, nad83_lon, ge_ft, osh_ft, cl_ft FROM mw_antenna_base WHERE application_user_id = 'SQL LOADER'");
    int cl_seqnum = 0;
    String leased = "";
    String ownership = "";
    String str_code = "";
    String cl_nad27_lat = "";
    String cl_nad27_lon = "";
    String cl_nad83_lat = "";
    String cl_nad83_lon = "";
    int cl_ge_ft = 0;
    int cl_ge_mt = 0;
    int cl_sh_ft = 0;
    int cl_sh_mt = 0;
    int cl_osh_ft = 0;
    int cl_osh_mt = 0;
    int cl_ov_faa_approv_ft = 0;
    int cl_ov_faa_approv_mt = 0;
    int cl_ant_tip_ft = 0;
    int cl_ant_tip_mt = 0;
    int cl_ant_ctr_line_ft = 0;
    int cl_ant_ctr_line_mt = 0;
    int i = 1;
    int mw_seqnum = 0;
    String mw_nad27_lat = "";
    String mw_nad27_lon = "";
    String mw_nad83_lat = "";
    String mw_nad83_lon = "";
    int mw_ge_ft = 0;
    int mw_ge_mt = 0;
    int mw_osh_ft = 0;
    int mw_osh_mt = 0;
    int mw_cl_ft = 0;
    int mw_cl_mt = 0;
    int j = 1;
    while(rs.next())                    // For Cellular/PCS
    System.out.println("\n\nCellular/PCS Record #" + i);
    cl_seqnum = rs.getInt("cla_seqnum");
    System.out.println("cla_seqnum =" + cl_seqnum);
    if (rs.getString("str_leased") != null) {
    leased = rs.getString("str_leased");
    } else {
    leased = "";
         StringTokenizer st = new StringTokenizer(leased, "/");
    while(st.hasMoreTokens()) {
         ownership = st.nextToken();
         str_code = st.nextToken();
    if (rs.getString("nad27_lat") != null) {
    cl_nad27_lat = valueOf(rs.getString("nad27_lat"));
    } else {
    cl_nad27_lat = "";
         System.out.println("cl_nad27_lat = " + cl_nad27_lat);
    if (rs.getString("nad27_lon") != null) {
    cl_nad27_lon = valueOf(rs.getString("nad27_lon"));
    } else {
    cl_nad27_lon = "";
    System.out.println("cl_nad27_lon = " + cl_nad27_lon);
    if (rs.getString("nad83_lat") != null) {
    cl_nad83_lat = valueOf(rs.getString("nad83_lat"));
    } else {
    cl_nad83_lat = "";
    System.out.println("cl_nad83_lat = " + cl_nad83_lat);
    if (rs.getString("nad83_lon") != null) {
    cl_nad83_lon = valueOf(rs.getString("nad83_lon"));
    } else {
    cl_nad83_lon = "";
    System.out.println("cl_nad83_lon = " + cl_nad83_lon);
    cl_ge_mt = (int)feetToMeter(rs.getInt("ge_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_ge_mt = " + cl_ge_mt);
    cl_sh_mt = (int)feetToMeter(rs.getInt("sh_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_sh_mt = " + cl_sh_mt);
    cl_osh_mt = (int)feetToMeter(rs.getInt("osh_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_osh_mt = " + cl_osh_mt);
    cl_ov_faa_approv_mt = (int)feetToMeter(rs.getInt("ov_faa_approv_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_ov_faa_approv_mt = " + cl_ov_faa_approv_mt);
    cl_ant_tip_mt = (int)feetToMeter(rs.getInt("ant_tip_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_ant_tip_mt = " + cl_ant_tip_mt);
    cl_ant_ctr_line_mt = (int)feetToMeter(rs.getInt("ant_ctr_line_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&cl_ant_ctr_line_mt = " + cl_ant_ctr_line_mt);
         // update NAD27 and NAD83 data in CL_ANTENNA table
    ps = con.prepareStatement("UPDATE cl_antenna_base SET str_leased = ?, structure_code = ?, nad27_lat = ?, nad27_lon =?, nad83_lat = ?, nad83_lon = ?, ge_mt = ?, sh_mt = ?, osh_mt = ?, ov_faa_approv_mt = ?, ant_tip_mt = ?, ant_ctr_line_mt = ? WHERE cla_seqnum = " + cl_seqnum);
    ps.setString(1, ownership);
    ps.setString(2, str_code);
    ps.setString(3, cl_nad27_lat);
    ps.setString(4, cl_nad27_lon);
    ps.setString(5, cl_nad83_lat);
    ps.setString(6, cl_nad83_lon);
    ps.setInt(7, cl_ge_mt);
    ps.setInt(8, cl_sh_mt);
    ps.setInt(9, cl_osh_mt);
    ps.setInt(10, cl_ov_faa_approv_mt);
    ps.setInt(11, cl_ant_tip_mt);
    ps.setInt(12, cl_ant_ctr_line_mt);
         ps.executeUpdate();          
         i++;
    } // end of while
    while(rs1.next())                    // For Microwave
    System.out.println("\n\nMicrowave Record #" + j);
    mw_seqnum = rs1.getInt("mwa_seqnum");
    System.out.println("mw_seqnum =" + mw_seqnum);
    if (rs1.getString("nad27_lat") != null) {
    mw_nad27_lat = valueOf(rs1.getString("nad27_lat"));
    } else {
    mw_nad27_lat = "";
    System.out.println("mw_nad27_lat = " + mw_nad27_lat);
    if (rs1.getString("nad27_lon") != null) {
    mw_nad27_lon = valueOf(rs1.getString("nad27_lon"));
    } else {
    mw_nad27_lon = "";
    System.out.println("mw_nad27_lon = " + mw_nad27_lon);
    if (rs1.getString("nad83_lat") != null) {
    mw_nad83_lat = valueOf(rs1.getString("nad83_lat"));
    } else {
    mw_nad83_lat = "";
    System.out.println("mw_nad83_lat = " + mw_nad83_lat);
    if (rs1.getString("nad83_lon") != null) {
    mw_nad83_lon = valueOf(rs1.getString("nad83_lon"));
    } else {
    mw_nad83_lon = "";
    System.out.println("mw_nad83_lon = " + mw_nad83_lon);
    mw_ge_mt = (int)feetToMeter(rs1.getInt("ge_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&mw_ge_mt = " + mw_ge_mt);
    mw_osh_mt = (int)feetToMeter(rs1.getInt("osh_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&mw_osh_mt = " + mw_osh_mt);
    mw_cl_mt = (int)feetToMeter(rs1.getInt("cl_ft"));
    System.out.println("&&&&&&&&&&&&&&&&&&&mw_cl_mt = " + mw_cl_mt);
    // update NAD27 and NAD83 data in MW_ANTENNA table
    ps1 = con.prepareStatement("UPDATE mw_antenna_base SET nad27_lat = ?, nad27_lon =?, nad83_lat = ?, nad83_lon = ?, ge_mt = ?, osh_mt = ?, cl_mt = ? WHERE mwa_seqnum = " + mw_seqnum);
    ps1.setString(1, mw_nad27_lat);
    ps1.setString(2, mw_nad27_lon);
    ps1.setString(3, mw_nad83_lat);
    ps1.setString(4, mw_nad83_lon);
    ps1.setInt(5, mw_ge_mt);
    ps1.setInt(6, mw_osh_mt);
    ps1.setInt(7, mw_cl_mt);
    ps1.executeUpdate();
    j++;
    } // end of while
    } catch(SQLException se) {
         System.out.println("SQL Exc" + se.getMessage());
    se.printStackTrace();
    } catch(Exception e) {
    System.out.println(" Exc" + e.getMessage());
    e.printStackTrace();
    finally
              try
                   rs.close();
                   stmt.close();
                   dbConn.freeConnection("system", conn);
                   conn.close();
              } catch (SQLException e)
    } // end of doConvert
    public static void main(String args[]) {
    Format_BaseTable old_nad = new Format_BaseTable();
    old_nad.doConvert();
    } // end of class

  • How to close database connections in Crystal Reports

    I am using the following code to connect to database. I can either pass JNDIName or I can provide values for others by leaving JNDI name empty.
    If i use JNDI name, it will use a connection from the connection pool of App Server (in my case Weblogic), but it is not releasing the connection after use. Connection remains even if I logoff from the application. If i keep my max connections as 15 in weblogic, after clicking the page with crystal report 15 times all will remain active and users will not be able to login to the application.
    If i use connectionString and others without using JNDI Name, it directly connects to database. So it creates a connection in database server directly without using connection pool of weblogic. If i check weblogic, it shows no connection in use as expected, but if i check database, i can see the no. of connections increasing everytime a user clicks a crystal report page.
    When the connection touches the maximum allowed connection in server, every application using the same server goes down
    How can I close the connection which was created for the viewing the report?
    String reportName = "/reports/BankBalance.rpt";
    ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
    if (clientDoc == null)
             clientDoc = new ReportClientDocument();
             clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
            // Open report
            clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
           String connectString = ""; // jdbc:sybase:Tds:DBSERVERNAME:9812/DBNAME?ServiceName=DBNAME
           String driverName = "";    // com.sybase.jdbc3.jdbc.SybDriver
           String JNDIName = "DS_APP";
           String userName = "";
           String password = "";
           // Switch all tables on the main report and sub reports
           CRJavaHelper.changeDataSource(clientDoc, userName, password, connectString, driverName, JNDIName);
         // logon to database
          CRJavaHelper.logonDataSource(clientDoc, userName, password);
    // Store the report document in session
    session.setAttribute(reportName, clientDoc);
                   // Create the CrystalReportViewer object
                          CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
         String reportSourceSessionKey = reportName+"ReportSource";
         Object reportSource = session.getAttribute(reportSourceSessionKey);
         if (reportSource == null)
              reportSource = clientDoc.getReportSource();
              session.setAttribute(reportSourceSessionKey, reportSource);
         //     set the reportsource property of the viewer
         crystalReportPageViewer.setReportSource(reportSource);
         crystalReportPageViewer.setHasRefreshButton(true);
         crystalReportPageViewer.setToolPanelViewType(CrToolPanelViewTypeEnum.none);
         // Process the report
         crystalReportPageViewer.processHttpRequest(request, response, application, null);

    the sample shows how to clear RAS and Enterprise resources after viewing report.
    1. If you use unmanaged RAS - as I can see you using setReportAppServer, then remove the enterprise related stuff : instantiating and cleaning code.
    The sample code is meant to give you an idea on how you can release the resources after done with viewing report. In your case all you need to do for cleaning is call close() on ReportDocumentObject. The sample will need to be modified for your requirements.

  • When and How to close database connection in JSP?

    Hi there,
    I am using MySQL and JDBC 3.0, in my system, When and How to close database connection in JSP?
    Thanks in advance.
    Lonely Wolf
    <%@ page session="true" language="java" %>
    <jsp:include page="checkauthorization.jsp" />
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%--
    Execute query, with wildcard characters added to the
    parameter values used in the search criteria
    --%>
    <sql:query var="availablecomputerList" dataSource="jdbc/Bookingcomputer" scope="request">
    SELECT * FROM computer where status=0
    order by s_code
    </sql:query>
    <html>
    <head>
    <title>Search Result</title>
    </head>
    <body bgcolor="white">
    <center>
    <form action="checkin.jsp" method="post">
    <input type="submit" value="Back to Check-in Page">
    </form>
    <c:choose>
    <c:when test="${availablecomputerList.rowCount == 0}">
    Sorry, no available computer found.
    </c:when>
    <c:otherwise>
    The following available computers were found:
    <table border="1">
    <th>Computer</th>
    <th>Description</th>
    <th>Status</th>
    <c:forEach items="${availablecomputerList.rows}" var="row">
    <tr>
    <td><c:out value="${row.s_code}" /></td>
    <td><c:out value="${row.description}" /></td>
    <td><c:out value="${row.status}" /></td>
    </tr>
    </c:forEach>
    </table>
    </c:otherwise>
    </c:choose>
    </center>
    </body>
    </html>

    when should you close the connection? when you're done with it.
    how should you close the connection? like this: conn.close();
    that said, doing this in a JSP page is bad form and not recommended
    JSP's typically don't contain ANY business or data logic

  • Opening multiple reports in Crystal Reports for VS causes database connect limit to be reached.  Seems to be no way to force Crystal Reports to close database connection (other than exiting application)

    I am working on upgrading an application that has been in use for many years.  The application is written in VB6 and I have been tasked with upgrading the current application to Crystal Reports for Visual Studio.  I am using Crystal Reports for VS Version 13.0.12.1494.  The system's database is a Sybase SQL Anywhere 16 database with an ODBC connection using integrated login.  Each of the reports has the database connection set up from within the report.  There is only once database server, so each of the reports are pointing to the same DB.  The database server is currently installed as a "Personal Server" with a limit of 10 connections. 
    I have implemented the CR viewer as part of a COM-callable wrapper that exposes a COM interface for VB6 to interact with.  Inside of my viewer component is a Winform that embeds the Crystal's Report viewer.  The COM interface basically maps the basic Crystal apis to methods that the VB6 can call (i.e., Load Report, Set Field Text, Update SQL Query, etc).  This architecture is working as designed and the reports are displaying correctly and responding correctly to changes in queries, etc.
    The issue is that after I open 9 reports, the tenth one will respond with an error indicating that the database connection limit has been reached.  The database connections used by the reports aren't released until after the application is closed.  The application is designed for a secure environment that prohibits the non-administrative user from accessing the systems desktop, so asking the user tor restart the application after 10 reports isn't a viable option.
    I have checked and database connection pooling is turned off for the SQL Anywhere 16 driver.
    I have been digging on this for a few days and have tried adding code in the FormClosed event to close and dispose of the Report Document as follows:
    ReportDocument reportDoc= (ReportDocument) crystalReportViewer1.ReportSource;
    reportDoc.Close();
    reportDoc.Dispose();
    GC.Collect();       // Force garbage collection on disposed items
    I have also tried the following (as well as maybe 20 or so other permutations) trying to fix the issue with no success.  
    ReportDocument reportDoc= (ReportDocument) crystalReportViewer1.ReportSource;
    foreach (Table table in reportDoc.Database.Tables)
         table.Dispose();
    crystalReportViewer1.ReportSource = null;
    reportDoc.Database.Dispose();
    reportDoc.Close();
    reportDoc.Dispose();
    reportDoc = (ReportDocument)crystalReportViewer1.ReportSource;
    GC.Collect();       // Force garabe collection on disposed items
    Any ideas or suggestions would be greatly appreciated.  I have been pulling my hair out on this one!

    Hi Ludek,
    Thanks so much for the quick reply.  Unfortunately I did not have time to work on the reporting project Friday afternoon, but did a quick test this morning with some interesting results.  I'm hoping if I describe what I'm doing, you can show me the error of my ways.  This is really my first major undertaking with Crystal Reports.
    If I simply load the report, then close and dispose, I don't hit the limit of 10 files.  Note that I do not logon manually in my code as the logon parameters are all defined within the reports themselves.  The logon happens when you actually view the report.  Loading the report doesn't seem to actually log in to the DB.
    What I did was create a very simple form with a single button that creates the WinForm class which contains the Crystal Viewer.  It then loads the report, sets the ReportSource property on the CrystalReportsViewer object contained in the WInForm and shows the report. The report does show correctly, until the 10 reports limit is reached.
    The relevant code is shown below. More than I wanted to post, but i want to be as complete and unambiguous as possible. 
    This code displays the same behavior as my earlier post (after 10 reports we are unable to create another connection to the DB).
    // Initial Form that simply has a button
      public partial class SlectReport : form
            public SelectReport()
                InitializeComponent();
            private void button1_Click(object sender, EventArgs e)
                ReportDocument rd = new ReportDocument();
                ReportForm report = new ReportForm();
                try
                    rd.Load(@"Test.rpt");
                    report.ReportSource = rd;
                    report.Show();
             catch (Exception ex)
                  MessageBox.Show(ex.Message);
    // The WinForm containing the Crystal Reports Viewer
        public partial class ReportForm : Form
            public ReportForm()
                InitializeComponent();
            private void Form1_Load(object sender, EventArgs e)
                this.crystalReportViewer1.RefreshReport();
                this.FormClosed += new FormClosedEventHandler(ReportForm_FormClosed);
            void ReportForm_FormClosed(object sender, FormClosedEventArgs e)
                ReportDocument rd;
                rd = (ReportDocument)crystalReportViewer1.ReportSource;
                rd.Close();
                rd.Dispose();
            public object ReportSource
                set { crystalReportViewer1.ReportSource = value; }
    Again, any guidance would be greatly appreciated. 

  • How to close database connections

    I am using the following code to connect to database. I can either pass JNDIName or I can provide values for others by leaving JNDI name empty.
    If i use JNDI name, it will use a connection from the connection pool of App Server (in my case Weblogic), but it is not releasing the connection after use. Connection remains even if I logoff from the application
    String reportName = "/reports/BankBalance.rpt";
    ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
    if (clientDoc == null)
    clientDoc = new ReportClientDocument();
                   clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
    // Store the report document in session
    session.setAttribute(reportName, clientDoc);
    String connectString = ""; // jdbc:sybase:Tds:DBSERVERNAME:9812/DBNAME?ServiceName=DBNAME
    String driverName = "";    // com.sybase.jdbc3.jdbc.SybDriver
    String JNDIName = "DS_APP";
    String userName = "";
    String password = "";
    CRJavaHelper.changeDataSource(clientDoc, userName, password, connectString, driverName, JNDIName);
    CRJavaHelper.logonDataSource(clientDoc, userName, password);
    // Store the report document in session
    session.setAttribute(reportName, clientDoc);
    // Process the report
    crystalReportPageViewer.processHttpRequest(request, response, application, null);

    the sample shows how to clear RAS and Enterprise resources after viewing report.
    1. If you use unmanaged RAS - as I can see you using setReportAppServer, then remove the enterprise related stuff : instantiating and cleaning code.
    The sample code is meant to give you an idea on how you can release the resources after done with viewing report. In your case all you need to do for cleaning is call close() on ReportDocumentObject. The sample will need to be modified for your requirements.

  • How to close ORMI connections after EJB lookup?

    I am using an InitialContext to look up my EJBs, like this:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23891/current-workspace-app");
    env.put(Context.SECURITY_PRINCIPAL, username);
    env.put(Context.SECURITY_CREDENTIALS, password);
    ic = new InitialContext(env);
    beanHome = (EJBHome)ic.lookup(beanHomeName);
    ic.close();I have been testing this on JDeveloper 10.1.3 and the embedded OC4J.
    This code gave me the problem that the user's credentials were only retireved once while the OC4J instance was alive. So if a user's permissions were changed, they would not be updated for EJB access.
    I then found this document: Excessive ORMI Connections Created, which gave me a clue to use env.put("oracle.j2ee.rmi.loadBalance", "context");
    However, I am concerned with the other part of that release note which states:
    "Closing the context does not cause the connection to be closed. Doing this repeatedly will result in performance degredation."
    Does anyone know how to forcibly close the ORMI connection that is created, or whether it will be released automatically?

    the sample shows how to clear RAS and Enterprise resources after viewing report.
    1. If you use unmanaged RAS - as I can see you using setReportAppServer, then remove the enterprise related stuff : instantiating and cleaning code.
    The sample code is meant to give you an idea on how you can release the resources after done with viewing report. In your case all you need to do for cleaning is call close() on ReportDocumentObject. The sample will need to be modified for your requirements.

  • Unable to open database connection after applicaiton is running for several days.

    Has anyone experienced a similar error to this:
    After about 3 days of use our application starts to report errors opening
    the database connection. By that time we've had thousands of transactions
    happen. Oracle is only showing a few open connections to our iAS host so
    the error seems to indicate the connection pool. I'm configured for 64
    connections (the default). We are using the Oracle native driver on iAS
    SP3, Solaris.
    The iAS ksvradmin monitor gives errors when trying to see how many open
    connections it has (verified bug in SP3), so I can't get any info from iAS
    on the connection pool.
    Thanks in advance,
    Rodger Ball
    Sr. Engineer
    Business Wire

    iAS6 SP3 and earlier cannot detect dead connections. If connections become
    stale, iAS does not detect this and will hand out these stale connections.
    I don't know enough about your problem, but you can check for this.
    hope this helps,
    -James
    "Rodger Ball" <[email protected]> wrote in message
    news:9suucb$[email protected]..
    Has anyone experienced a similar error to this:
    After about 3 days of use our application starts to report errors opening
    the database connection. By that time we've had thousands of transactions
    happen. Oracle is only showing a few open connections to our iAS host so
    the error seems to indicate the connection pool. I'm configured for 64
    connections (the default). We are using the Oracle native driver on iAS
    SP3, Solaris.
    The iAS ksvradmin monitor gives errors when trying to see how many open
    connections it has (verified bug in SP3), so I can't get any info from iAS
    on the connection pool.
    Thanks in advance,
    Rodger Ball
    Sr. Engineer
    Business Wire

  • How can I kill database connections

    I would like to know how can I kill all the database connexion at the end of an application. I'm using acces
    thx

    use con.close() in a finally statement after your catch blocks that tests whether con equals null. If con != null, then con.close();
    example:
    finally {
              //close the database connection.
              try {
                      if (con != null) con.close();
              catch (SQLException e) {
    }

  • Properly close database connection - Oracle

    I have an unusuall application that has a main in it and runs off of a cron job.
    We have orders that have to be filled, and if the approver of that order does not reject it after 30 minutes its automatically filled.
    The weird thing is that alot of these stored procedures were already in place before I got there so I just went ahead and called them to get the data that I needed.
    So, we have a shell script that just calls my class. The main kicks off and gets the time of the orders placed on that day. If the current time minus the time the order was placed is greater than 30 minutes approve the order.
    Now, I have about 3 - stored procedures that I call in one method. Actually I have about 3 or 4 methods that in turns calls these stored procedures. I have callable statements for each method. and I do a try - catch in each of the other methods, but not a connection close. In the one method that does all the work and calls the other methods, I have a try - catch - and a then a finally. I then do a conn.close() in the finally of this method.
    My question is? Is this correct. Should I do a try catch finally in my main() method.
    So, this is sort of what it looks like.
    class DoSomething
       Connection conn;
       method1()
          try
             CallableStatement cs;
             ResultSet rs;
             rs.close;
             cs.close;
          catch
          return something1;
       method2()
          try
             CallableStatement cs;
             ResultSet rs;
             rs.close;
             cs.close;
          catch
          return Something2;
       method3()
          try
             CallableStatement cs;
             ResultSet rs;
             rs.close;
             cs.close;
          catch
          return Something3;
       doSomethingMethod()
          try
             CallableStatement cs;
             ResultSet rs;
            // call the other methods to get all data needed.
            ds.method1;
            ds.method2;
            ds.method3;
             rs.close;
             cs.close;
          catch
          finally
              conn.close();
       main()
          DoSomething ds = new DoSomething();
          ds.doSomethingMethod();
    }orozcom

    Well, The catch blocks are not empty. I assure you. I
    just didn't feel like writing down all of my code.
    plus I did not want to cloud the example with to much
    code. Very good.
    All I wanted to know is when and where to close
    my resultset, callable statements, and connection.OK, you should close each one in its own individual try/catch block in a finally block inside the method in which they were called.
    If the stored procs are a unit of work, you'll have to share the Connection.
    Please also realize that this is a web based
    application as well. I take in parameters from a URL.
    I pass those parameters to the stored procs (which
    are already there). If you're doing that in a JSP, I'd say you've got a bad design.
    Now sometimes one method needs
    information from another method. So, I run that
    method. pass the info to another method or stored
    proc which gives me my info. All this should be happening in a service layer.
    I was told that a finally block always runs. So, I
    thought if I atleast put my conn.close in the
    finally. then it will always close the connection.As long as it doesn't throw an exception. And you should close ResultSets and Statements, regardless of what the javadocs say.
    Also, there is only one database that I call. Now the
    stored procs are all on the same database, but they
    are in different packages. which is why I use the
    callable statements.That's fine.
    Also, I do not only call stored procs. I usually only
    call a stored proc to get information back, and then
    give it to a class to manipulate the data.Sounds inefficient. Would a JOIN do as well? You might fall into the (n+1) query trap, where you run a query to get a ResultSet and then iterate through it and run another query per iteration. This is inefficient as n gets large.
    %

  • Open and close database connection jsp page

    hi there, i wanna know about how to open database connection to Mysql at the beginning of the page and close the connection at the end of the page. The jsp page contain all processing code.
    plz help me...thx thx

    <html>
    <head>
    <basefont face="Arial">
    </head>
    <body>
    <%@ page language="java" import="java.sql.*" %>
    <%!
    // define variables
    String id;
    String firstName;
    String lastName;
    // define database parameters, change this according to your needs
    String host="localhost";
    String user="root";
    String pass="";
    String db="test";
    String conn;
    %>
    <table border="1" cellspacing="1" cellpadding="5">
    <tr>
    <td><b>id</b></td>
    <td><b>first name</b></td>
    <td><b>last name</b></td>
    </tr>
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    // create connection string
    conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user 
    + "&password=" + pass;
    // pass database parameters to JDBC driver
    Connection Conn = DriverManager.getConnection(conn);
    // query statement
    Statement SQLStatement = Conn.createStatement();
    // generate query
    // change this query according to your needs
    String Query = "SELECT id, firstname, lastname FROM abook";
    // get result
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
    while(SQLResult.next())
       id = SQLResult.getString("id");
       firstName = SQLResult.getString("firstname");
       lastName = SQLResult.getString("lastname");
            out.println("<tr><td>" + id + "</td><td>" + 
         firstName + "</td><td>" + lastName + "</td></tr>");
    // close connection
    SQLResult.close();
    SQLStatement.close();
    Conn.close();
    %>
    </table>
    </body>
    </html>hi :-)
    i've got that on the net as part of the tutorial on jsp (long long time ago)
    you just have to be resourceful in finding solutions :-)
    try google :-) there are lot's of tutorial available in there ;-)
    goodluck ;-)
    regards,

  • How to use the database connection bean??

    hi,
    i was created a database connection class. can teach me how to call the class at JSP.
    thanx...
    <jsp:useBean id ="dat" class ="Database" scope ="request"/>
         String sql = "INSERT INTO  table"
               "(standard,col )" +
               " VALUES " +
                                                "('a','kk')";
         public static Connection getConnection()
             throws ClassNotFoundException, SQLException
              // Load Sun's JDBC-ODBC Bridge
              Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
              // Make a connection to JDBC-ODBC Bridge drive with
              // the connection URL, jdbc:odbc:DSN
              String url =  "jdbc:odbc:miniproj";
              return(DriverManager.getConnection(url, "anonymous", "guest"));
         public static int executeUpdate(String nonSelectQuery)
             throws ClassNotFoundException, SQLException
              return(executeUpdate(getConnection(), nonSelectQuery));
         public static int executeUpdate(Connection conn, String nonSelectQuery)
             throws ClassNotFoundException, SQLException
              return(conn.createStatement().executeUpdate(nonSelectQuery));
         }

    NOTE that you should always have your classes inside packages. Some versions of Tomcat won't use them correctly otherwise.

  • How to change the database in Crystal reports

    To give an overview there is one project going on where the oracle database is getting migrated from 10g to 11g.
    All the details of database like IP, port etc are changing as part of this.
    I can see the driver name configured as crdb_ado (Custom driver).
    We have an test environment for 11g against which we have to point all the reports and test it.
    Could you please let me know the below queries
    Where and how to change the IP details in the crystal reports to point to new test and prod databases.
    Overview on this crdb_ado driver
      Basically the database is getting changed and we want the reports to point and run from the new database.
    Thanks

    Hi Vissu,
    Thanks for your reply.
    We need to change the database from the reports which are already running from central management console.
    I can see a custom driver crdb_ado is being used and it connects to a database.
    Could you please let me know where the database configuration is done.
    Ideally we need to add one more database to a config file which i am not able to find.
    I guess it should be similar to tnsnames.ora file in oracle where the different databases are stored.
    From the above image I would like to know where the server details (NECTAR_Prod) would be configured.
    Thanks in advance

  • Clean-up code - Close Database Connection

    I have a Stateless Session Bean that implements a Web Service. This bean opens a database connection. I need to close it before the application is undeployed or the Application Server (Glassfish) is restarted, etc. I have tried shutdown hooks, predestroy and preremove annotations but none of it works.
    In a few words, I want to release resources when they are not needed, but not before that.
    I have used Google in every way I can imagine but I haven't turned up with anything.
    Any ideas?

    Duffy, I appreciate your reponse on this issue. But what is the difference, seeing that a stateless bean is response-oriented afterwhich it is returned to the pool. Not sure I know what you mean here.
    A pool of connections is not the same as a pool of stateless session beans. And I don't think that returning an instance of one to its pool necessarily means that the other is automagically cleaned up as well.
    I will admit now that I'm not an EJB expert.
    It almost seemed to me that you were saying you'd recommend making the size of the connection and SLSB pools identical. You'd dedicate one connection to each SLSB, marrying the two together for as long as ye both shall live.
    I think the design will make acquiring a connection littered all over code body. If the connection will be reused in at least 2 method it is better to create the connection in the postConstruct annotated method and remember after the bean services the client request, it is in itself placed in a pool. So nothing is lost.Maybe you're right. I'm not much with EJBs. I use Spring exclusively.
    %

Maybe you are looking for

  • IMessage and Facetime "waiting for activation" on iPhone4s (Brazil)

    I've had an iPhone 3GS for 3 years, had iMessage working perfectly. On march 16th, i bought an iPhone 4S from my supported carrier, TIM. Since then, I cannot activate my phone number neither in iMessage nor in Facetime. If I log in my Apple ID, both

  • FBL5N - disable the modify document button

    Hi All! I have to perform the following task: When a user use the TCode FBL5N (Customer Line Item Display) there is a Modify button (which allows to modify the document). I have to disable this functionality. OR, in the Change Document screen, I have

  • Open pdf files in Adobe not Preview

    I just got my MacBook and all my files transferred from my old iBook. However, somehow all my pdf files are opening in Preview and not in Adobe Reader. I've had to adjust this before on my iBook, but I've forgotten how to set it so Adobe Reader is us

  • NJawin: User32 and property problems

    Hi everybody, especially Vitaly Shelest ;) I'm using latest NJawin (1.1.31) and jsdk1.4.2 for wrapping some DLLs. It works, but there are several problems: 1) When null and "" (empty strings) are passes in IDispatch property put methods for String pr

  • SQL Express 2008 to 2012 express upgrade not working

    I'm trying to upgrade an older version of SQL Express 2008 to 2012 by first upgrading to (what I think is) 2008 SP3 (10.0.5500.0). The upgrade to 2008 SP3 says it has completed and the version of the browser and client etc are showing as 10.3.5500.0