How to clean Database Connections when...

Hi...
We are writing a application where I am using a pool of DB connections to use in all my classes.
We use IPlanet Web Server to serve Servlets...
When the IPlanet Web Server is closing down I need a way to clean (close) the connections to the DB...
I tried to write code inside the finalize() methord of the connection Manger class thinking that it might be called when the Server is going down but it seems that it is never called....
Any ideas folks...

>
Try this out....
When the Web server is going down it would call the
destroy() method of the servlets you have. Inside one
of those you could put your cleanup code to call the
connection manager and close the connections...Just curious, what happens when I use the task manager to kill Internet Explorer (or kill -9 Netscape.) Does the destroy method still get called? Or what about if I kick out the power cord?

Similar Messages

  • 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

  • How to get database connection in applet

    Hi,
    I am trying to prepare database connection in applet. After preparing connection with database it'll read same values from table.
    At the time of development it works fine. I have used esclipse IDE for coding and testing.
    But when I try to call that applet from browser. It is giving ClassNotFound exception.
    Does anybody know How to get database connection in applet ?
    Please help me if anybody know solution for this.
    Thanks,
    Rajesh

    As per my knowledge is conserned
    1 u can get the database connection in a jsp page and u send the result set as param to the applet and u can use retrieved values as if they were of the same applet if u r interested i can send the db connetion coding for jsp my id [email protected]

  • 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

  • How to get database connection in common java class

    hi friendz,
    plz help me...
    I am using JDEV 11.1.2.2.0 version.
    my problem is I'm writing common java class which can reuse any application.
    in this case when im create database connection like this,
    String username = "a";
    String password = "b";
    String thinConn = "jdbc:oracle:thin:@IP:1521:database";
    DriverManager.registerDriver(new OracleDriver());
    Connection conn =
    DriverManager.getConnection(thinConn, username, password);
    conn.setAutoCommit(false);
    return conn;
    but this statement not working in java class.its working only backing bean.
    import oracle.jdbc.OracleDriver;
    DriverManager.registerDriver(new OracleDriver());
    how can i do that??
    hope your help
    -Harsh-

    What is the error message in Java class?
    With JDBC 4.0 driver the DriverManager class has added support for the Java SE Service Provider mechanism to the getConnection() and getDrivers() methods using which JDBC drivers may be loaded automatically. The following Class.forName() method is not required to be invoked.
    Class.forName(“oracle.jdbc.OracleDriver”);
    Only the following is required to obtain a connection.
    String url="jdbc:oracle:thin:@localhost:1521:ORCL";
    Connection connection = DriverManager.getConnection(url,"oe", "pw");

  • How create a database connection only one for lot of AM

    Hi ,
    In My Application am having lot of Application module its containing database connection per AM its connecting to same database only if i want to make it unique connction how i can proceed. which is correct way any one can help me
    Thanks
    Prabeethsoy

    The source trace show how the JUApplication was created and saved to BindingContext.
    1. private static void invokeBeginRequest(
    BindingContext bindingCtx, HashMap requestCtx)
    Object obj;
    Iterator iter = bindingCtx.valuesIterator();
    while (iter.hasNext())
    obj = iter.next();
    if (obj instanceof DCDataControlManagement)
    2.First type is DCDataControlReference ====> ((DCDataControlManagement)obj).beginRequest(requestCtx);
    3. ADFBindingFilter chain.doFilter(request, response);
    4. DCDataControl control = actionBinding.getDataControl();
    5. JUCtrlActionBinding
    public final DCDataControl getDataControl()
    if (mDataControl == null)
    if (getDef() instanceof JUCtrlActionDef )
    String name = ((JUCtrlActionDef)getDef()).getDataControlName();
    if (name != null && getBindingContainer() != null)
    BindingContext ctx = getBindingContainer().getBindingContext();
    if (ctx != null)
    6. ========>mDataControl = ctx.findDataControl(name);
    if (mDataControl == null)
    if (getIteratorBinding() != null)
    mDataControl = getIteratorBinding().getDataControl();
    else if (getBindingContainer() != null)
    mDataControl = getBindingContainer().getDataControl();
    return mDataControl;
    7. BindingContext
    public DCDataControl findDataControl(String name)
    return (DCDataControl)get(name);
    public Object get(Object key)
    Object rtn = mDCMap.get(key);
    if (rtn == null)
    rtn = mBCMap.get(key);
    else
    if (rtn instanceof DCDataControlReference)
    // remove the reference in order to prevent re-entrancy.
    remove(key);
    *8. Create JUApplicaion======> rtn = ((DCDataControlReference)rtn).getDataControl(this);*
    *9. save JUApplication with AM ======>  put(key, rtn);*
    return rtn;
    10. DCDataControlReference
    public DCDataControl getDataControl(BindingContext ctx)
    String name = getName();
    DataControlFactory factory;
    try
    Class factoryClass = JBOClass.forName(mDef.getFactoryClass());
    factory = (DataControlFactory)factoryClass.newInstance();
    catch(Exception e)
    throw new JboException(e);
    // JRS this is a backwards compatibility step. The generic
    // DataControlFactoryImpl used to perform this mapping such
    // that the bean class will be faulted back the definition class
    // if null. I am performing this mapping at RT only in order
    // to maintain the DT integrity (i.e. I don't want the DT to start
    // faulting the bean class as the definition class when writing the
    // DC def).
    if (mDef.getBeanClass() == null)
    mDef.setBeanClass(mDef.getDefinitionClass());
    *11. create JUApplicaion =====> DCDataControl dc = (DCDataControl)factory.createSession(*
    ctx, mDef.getName(), mUserParams, mDef);
    SessionContext sessionCtx = ctx.getSessionContext();
    if (sessionCtx != null)
    dc.setSessionContext(sessionCtx);
    // fire the deferred beginRequest notication on the new datacontrol
    if (mRequestContext != null)
    12.======>dc.beginRequest(mRequestContext);
    mRequestContext = null;
    return dc;
    }

  • How to manage database connections

    Hi, I have been trying to find the best way of doing database connections, My application will not be used by many users since its an intranet application used by administrators only to change settings.
    I want to be able to connect to db from a servlet but not have to make the connection all the time, I was thinking of creating my own ContinuousConnection class which basically keeps the connection and all you do is getConnection which checks if the connection is "up" or not, if it is up then just give it as the return value else, just create a new connection since the driver class has already been loaded...if it is null then just load the driver and make the connection.
    this way in differenet functions that i have in the servlet dont have to make connections all the time.
    Is there a better way of doing this?
    I was thinking of putting the connection object in the data section of the servlet, but then it is more or less like static data amongst all threads created to run the servlet and I dont know what would happen if 2 querries are run from the same connection by different serving threads...can someone please explain me this..
    I know a good way of managing connections is using a pool..but i dont know how useful is that here...also i am not very familiar with a pool..can someone please explain me the idea behind it..and how it works...that would be just perfect.
    Thank you very much.
    Ankur

    IIRC to setup tomcat connection pooling when using an Oracle database (for example):
    Add something like this to the server.xml file:
            <Context path="/myProject" docBase="myProject" debug="0"
                     reloadable="true" crossContext="true">                
                    <Resource name="jdbc/ORAC" auth="Container" type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/ORAC">
                <parameter>
                  <name>factory</name>
                  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>
                <parameter>
                  <name>driverClassName</name>
                  <value>oracle.jdbc.driver.OracleDriver</value>
                  </parameter>
                <parameter>
                  <name>url</name>
                  <value>jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:XXXX</value>
                </parameter>
                <parameter>
                  <name>username</name>
                  <value>xxxxx</value>
                </parameter>
                <parameter>
                  <name>password</name>
                  <value>xxxxx</value>
                </parameter>
                <parameter>
                  <name>removeAbandoned</name>
                  <value>true</value>
                </parameter>
                <parameter>
                  <name>logAbandoned</name>
                  <value>true</value>
                </parameter>
                <parameter>
                  <name>maxActive</name>
                  <value>20</value>
                </parameter>
                <parameter>
                  <name>maxIdle</name>
                  <value>10</value>
                </parameter>
                <parameter>
                  <name>maxWait</name>
                  <value>-1</value>
                </parameter>
              </ResourceParams>                       
            </Context>  This needs to go in between the <Host> ... </Host> tags (probably at the bottom) in the server.xml file (${CATALINA_HOME}/conf). You must put this in the correct place in the xml file or you'll get errors.
    Then you need to add this to your web.xml file:
        <resource-ref>
             <description>Oracle Datasource</description>
             <res-ref-name>jdbc/ORAC</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
        </resource-ref>Again this needs to go in the correct place (as per the dtd)
    Then to get a connection:
    final Context initContext = new InitialContext();               
    final DataSource ds = (DataSource) initContext.lookup("java:/comp/env/jdbc/ORAC");                              
    final Connection conn = ds.getConnection();You probably want to wrap getting these connections in a class (i.e. with a getConnection method). And remember to close the connections when you've finished with them.

  • How to configure database connectivity in OC4J App server.

    Hi,
    I am working on Oracle ESB flows. I have the flow inserting rows into database table using database connection that I have defined. I havent set up connection settings in OC4J EM console.
    I dont wonder when JDeveloper is inserting rows into tables, as connection is explicitely defined in JDeveloper.
    Now I login to EM enviroment and click on Home, click on Web Services tab, and when I use this flow as a Web Service end point and feed values through the form that it provided, it also works. But since I havent defined any connection properties in App Server explicitely, I wonder where is it getting connection properties(JNDI name) from.
    I want to configure some settings in Testing Environment and am kind of stuck at this point.
    Thanks,

    Hi.
    When you don't have JNDI configured, OC4J uses the design time connection defined in the Adapter's WSDL. Look for the following description in your Adapter WSDL:
    <!-- Your runtime connection is declared in
    J2EE_HOME/application-deployments/default/DbAdapter/oc4j-ra.xml
    These 'mcf' properties here are from your design time connection and
    save you from having to edit that file and restart the application server
    if your JNDI is missing.
    These 'mcf' properties are safe to remove.
    -->
    Now, for JNDI configuration, you can use the SOA Suite tutorial as a reference:
    http://download.oracle.com/docs/cd/B31017_01/core.1013/b28937/setting_up.htm#CIHBHEFC
    There you can find the steps to create a connection pool, data source, etc.
    Denis

  • How to create database connection using DB2Driver in JDeveloper 10.1.2.1.0?

    I am trying to create a JDeveloper/Data Connection using com.oracle.ias.jdbc.db2.DB2Driver. The driver is registered from a User Libraries: DataDirect JDBC. I have the following class path for the library:
    E:\DataDirect\3.4\lib\YMdb2.jar;E:\DataDirect\3.4\lib\YMbase.jar;E:\DataDirect\3.4\lib\YMutil.jar
    I have no trouble configuring the connection but when I test it and I got ‘No suitable driver Vendor code 0’. What’s wrong? I have successfully created several database connections using Oracle thin driver. This is first time I am using a third party driver. Has any one successfully create a database connection using the com.oracle.ias.jdbc.db2.DB2Driver?

    Hi
    Since the error points to the unavailability of the driver class,can you double check your library claspath entries again.
    I just tried a DB2 connection using the following properties and the connection went through fine:
    Driver class name: com.oracle.ias.jdbc.db2.DB2Driver
    URL: jdbc:merant:db2://<host_name>:50000;DatabaseName=SAMPLE
    Thanks
    Prasanth

  • P6 8.3 Professional - how to backup database connections?

    Is there a way?

    Hello Daniel,
    this is how my Path=E:\instantclient_11_2;...... variable looks like. I have put tnsnames.ora and sqlnet.ora in E:\instantclient_11_2 and this is how
    TNS_ADMIN=E:\instantclient_11_2 looks like.
    Contents of tnsnames.ora
    # tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    ORACLR_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        (CONNECT_DATA =
          (SID = CLRExtProc)
          (PRESENTATION = RO)
    ORCL =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.3.27)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orcl)
    Contents of sqlnet.ora
    # sqlnet.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.
    # This file is actually generated by netca. But if customers choose to
    # install "Software Only", this file wont exist and without the native
    # authentication, they will not be able to connect to the database on NT.
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
    still the same error
    Database connection failed: Error Message:
    Bad public user name or password. Cannot load OCI DLL: oci.dll;
    I tried both ORCL and //172.16.3.27:1521/ORCL as connection strings.
    should instant client used be 32 bit as well?
    regards, Prasad

  • How to create database connection and how to call it using Java

    Hi,
    Good day! I'd like to know how I can create a db connection in JDev, then use this connection to retrieve data using a Java Class? I've seen using New Gallery > Database Connection. But I'm not sure how I can access this connection using Java and display some output from the retrieved records.
    Any steps/tutorial link is appreciated.
    Thanks in advance,
    Rian

    Hi,
    If you need to access the connection in the entity object then refer http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#BABEIFAI i.e in MODEL.
    But if you want to access connection in ViewController part of application then you need to do it manually.For this i am giving you my code for reference.------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.faces.context.FacesContext;
    import oracle.jdbc.pool.OracleDataSource;
    public class DataHandler {
    String jdbcUrl = null;
    String userid = null;
    String password = null;
    Connection conn;
    public static final String CONNECTION_STRING =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("connectionString");
    public static final String USER_NAME =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("userName");
    public static final String PASSWORD =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("password");
    public DataHandler(String jdbcUrl, String userid, String password,
    boolean shouldConnect) throws SQLException {
    this.jdbcUrl = jdbcUrl;
    this.userid = userid;
    this.password = password;
    if (shouldConnect) {
    connect();
    public void connect() throws SQLException {
    OracleDataSource ds;
    ds = new OracleDataSource();
    ds.setURL(jdbcUrl);
    conn = ds.getConnection(userid, password);
    public Connection getConnection() {
    return conn;
    public ResultSet executeQuery(String sql) throws SQLException {
    Statement s = conn.createStatement();
    return s.executeQuery(sql);
    public void closeConnection() throws SQLException {
    if (!conn.isClosed()) {
    conn.close();
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • How to access  database connection from datatsource in a standalone java ap

    My java standalone application wants connection to database with lookup to datasource name which is configured in the oc4j app server.
    Please guide me with some ideas to acheieve this.

    user510497,
    Following sample program requires access to classes in "oc4j.jar" file.
    Test environment:
    * Server:
    + OC4J stand-alone 10.1.2.0.2
    + Red Hat Enterprise Linux AS release 3
    + Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    + Oracle Database 10g Release 10.1.0.4.0 - 64bit Production
    * Client
    + Microsoft Windows XP Professional Version 2002 Service Pack 2
    + Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class DataSrc2 {
      public static void main(String[] args) {
        Connection conn = null;
        Properties l_props = new Properties();
        l_props.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.evermind.server.rmi.RMIInitialContextFactory");
        l_props.put(Context.PROVIDER_URL, "ormi://your_OC4J_host/");
        l_props.put(Context.SECURITY_PRINCIPAL, "your_OC4J_user");
        l_props.put(Context.SECURITY_CREDENTIALS, "your_OC4J_password");
        Context l_jndiContext = null;
        try {
          l_jndiContext = new InitialContext(l_props);
          Object l_obj = l_jndiContext.lookup("default-data-source");
          DataSource ds = (DataSource) l_obj;
          conn = ds.getConnection("scott","tiger");
          DatabaseMetaData dbmd = conn.getMetaData();
          System.out.println(dbmd.getDatabaseProductVersion());
        catch (NamingException x_naming) {
          x_naming.printStackTrace();
        catch (SQLException xSql) {
          xSql.printStackTrace();
        finally {
          if (l_jndiContext != null) {
            try {
              l_jndiContext.close();
            catch (NamingException x_naming) {
              System.err.println("Failed to close JNDI context.");
              x_naming.printStackTrace();
          if (conn != null) {
            try {
              conn.close();
            catch (SQLException xSql) {
              System.err.println("Failed to close [database] connection.");
              xSql.printStackTrace();
    }NOTES:
    1. Datasource lookup name is value of "default-data-source" attribute of "orion-application" element in file:
    <OC4J_HOME>/j2ee/home/config/application.xmlGood Luck,
    Avi.

  • How to obtain database connection via PL/SQL

    Dear friends,
    I need to obtain the database name where user is connected - using PL/SQL. That is, if I type "select user from dual" I obtain the connected user; is there some similar way for me to obtain database connection?
    Thanks, and best regards,
    Franklin

    SELECT sys_context('USERENV', 'DB_NAME') FROM dual;
    SELECT sys_context('USERENV', 'INSTANCE') FROM dual;
    You can choose whichever you want to use. :-)
    Instace parameter will give you INSTANCE_ID (matches with GV$INSTANCE) so not that much useful I guess.
    Edited by: Satish Kandi on Oct 6, 2008 9:32 PM

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

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

Maybe you are looking for

  • Can't upgrade MacBook Pro (15-inch, Late 2008) to snow leopard

    I have a MacBook Pro (15-inch, Late 2008) and a copy of snow leopard on DVD. When I try to upgrade it says that snow leopard cannot be installed on this computer The details are as follows: Model Name:    MacBook Pro   Model Identifier:    MacBookPro

  • Custom duty on iphones

    how much does a person have to custom when importing out iphone 3gs/iphone 4/ipad 2 from USA

  • Where can I buy a LEGAL copy of Acrobat X (10)

    I need a Legal copy of Acrobat X. Acrobat XI (11) does not function with my Automatic Document Feeder (ADF) Scanner. HP claims that the Scanner is 100% functional and tested with Acrobat XI. I had an download "Trial" version of Acrobat X, and it work

  • Converting CYMK document to PATONE

    My client has come back to me and said that some PDF's I sent him (over 40 individual) were CYMK and some were pantone. He needs them all in Pantone, how do I convert the CYMK files in InDesign cs6? Also, why would my indesign use different colour se

  • How can I be sure that changing from ADSL to Infin...

    Hi, I would like to upgrade from ADSL to Infinity, but I am not convinced there will be any real benefit to me and BT are not being helpful. I am currently with Talk Talk and consistently get between 19.5 and 20 meg sync speeds. I don't know where my