Report Engine SDK - Rbean usage in standalone java application

Post Author: Berndb
CA Forum: JAVA
In BOXI the rebean sdk is available in the Report Engine SDK.
I remember that in the 6.5 world one could use RBEAN interface in a standalone java application.
Is this still possible in BOXI R2?
If yes can you supply a sample classpath which shows all libraries that needs to be assigned.
Thanks in advance.
bernd

Post Author: datahog
CA Forum: JAVA
Ted's right, but for fun, take what you need from:
<installation drive>:\Program Files\Business Objects\Tomcat\webapps\businessobjects\enterprise115\desktoplaunch\WEB-INF\lib
and de-reference what's not needed when your project's done, but be careful.
I've actually done some standalone Swing-based webi report renderers using https://xhtmlrenderer.dev.java.net/ + docHTMLView.getStringpart + TagSoup

Similar Messages

  • Is it possible to use the JAVA Report Engine SDK to modify DESKI reports?

    Post Author: Nadine
    CA Forum: JAVA
    Hi, is it possible to add a complex filter to a DESKI report using the JAVA report engine sdk?
    In the developer tutorials for this API, I've only found references to WEBI in terms of modifying reports, though it seems to be possible to view DESKI reports with this sdk.
    I am a bit confused in terms of the scope of this API and how I would use it in regard to DESKI.
    Many thanks for any suggestions!
    Nadine

    Post Author: Ted Ueda
    CA Forum: JAVA
    Current (XI R2) version of ReportEngine API only supports refreshing/viewing functionality for Desktop Intelligence documents.  Document modification/creation is only supported with Web Intelligence documents.  Queries aren't modifiable for Deski using ReportEngine API - you can only do so using Desktop Intelligence Reporter SDK, which is COM based.Sincerely,Ted Ueda

  • Report Engine SDK Performance

    What are the recommended settings for businessobjects xI (version 11.5)
    Are there any tips to improve performance and reliability of the Report Engine SDK?
    It is very slow. We are using a Java client to interact with the dswsbobje libraries.
    Calls to " reportEngine.getDocumentInformation" are not consistently working even from the same program.
    We supply the prompt info parameters to generate the report.
    It works for the first 3 times, then fails a couple of times, and then works again.
    Sometimes a report load in 3 seconds, and other times it loads in 30 seconds or not at all.

    Why not open a case with SAP Support?
    Sincerely,
    Ted Ueda

  • Please, help me with with Report Engine SDK!

    I am using Report Engine SDK. This is my code:
    <%@ page import="com.crystaldecisions.sdk.framework.*"%>
    <%@ page import="com.crystaldecisions.sdk.exception.SDKException"%>
    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore"%>
    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject"%>
    <%@ page import="com.crystaldecisions.sdk.occa.security.ILogonTokenMgr"%>
    <%@ page import="com.crystaldecisions.sdk.occa.infostore.*"%>
    <%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
                     com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
                     com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,
                     com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat,
                     java.io.ByteArrayInputStream"
    %>
    <%@ page import="java.util.Iterator"%>
    <%
         // Reference to the Report Engine:
    %>
    <%@ page import="com.businessobjects.rebean.wi.*"%>
    <%!IInfoObjects getList(IInfoStore iStore) {
              IInfoObjects list = null;
              String query = "SELECT SI_ID, SI_NAME, SI_PARENTID," + " SI_KIND, SI_INSTANCE, SI_DESCRIPTION FROM"
                        + " CI_INFOOBJECTS";
              try {
                   list = iStore.query(query);
              } catch (SDKException sdke) {
                   list = null;
              return list;
         }%>
    <%!     void see_all_objects(IInfoStore iStore){          
              IInfoObjects webiDocs = getList(iStore);
              Iterator infoObjectsIter = webiDocs.iterator();
              while (infoObjectsIter.hasNext()) {
                   IInfoObject folder = (IInfoObject) infoObjectsIter.next();
                   System.out.println(folder.getID());
                   System.out.println(folder.getTitle());
                   System.out.println(folder.getDescription());
         %>
    <%
         String CMS = request.getParameter("cms");
         String userID = request.getParameter("user");
         String password = request.getParameter("password");
         String auth = request.getParameter("auth");
         if (CMS == null)
              CMS = "";
         if (userID == null)
              userID = "";
         if (password == null)
              password = "";
         if (auth == null)
              auth = "";
         IEnterpriseSession enterpriseSession;
         try {
              ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr();
              enterpriseSession = mySessionMgr.logon(userID, password, CMS, auth);
              if (enterpriseSession != null) {//Create and store useful objects for the session.
                   session.setAttribute("EnterpriseSession", enterpriseSession);
                   IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
                   session.setAttribute("InfoStore", iStore);
                   //see_all_objects(iStore);
                   //String folderQuery = "SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='4.rpt'";
                        String folderQuery = "SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='5.rpt'";
                   IInfoObjects folders = iStore.query(folderQuery);
                   IInfoObject folder = (IInfoObject)folders.get(0);
                   //Instantiation of a Report Engine:
                   ILogonTokenMgr iLManager = enterpriseSession.getLogonTokenMgr();
                   ReportEngines repEngines = (ReportEngines) enterpriseSession.getService("ReportEngines");
                   ReportEngine widocRepEngine = (ReportEngine) repEngines
                             .getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);//WI allows editing and creation
                   session.setAttribute("widReportEngine", widocRepEngine);
                   ReportEngine fcdocRepEngine = (ReportEngine) repEngines
                             .getService(ReportEngines.ReportEngineType.FC_REPORT_ENGINE); //FC just viewing
                   session.setAttribute("fcdReportEngine", fcdocRepEngine);
                   Opening documents:
                        1. Establish a BusinessObjects Enterprise session for the user
                        2. Get an identifier for the document
                        3. Retrieve the ReportEngine instance to open the document of desired type.
                        4. Open the document using the ReportEngine.openDocument method for Web
                        Intelligence or Desktop Intelligence documents.
                   int idReport = folder.getID();     
                   System.out.println("Document about to be opened "+idReport);
                   System.out.println("Name file: "+folder.getTitle());
                   DocumentInstance docInstance= widocRepEngine.openDocument(idReport);                
              //     DocumentInstance docInstance = fcdocRepEngine.openDocument(idReport);
                   System.out.println("Document opened");
                   String docToken = docInstance.getStorageToken();
                   //User perform actions on document
                   // Open the document using its repository ID
                   BinaryView docBinaryView = (BinaryView)docInstance.getView(OutputFormatType.PDF);
                   //Parameterize the response
                   response.setContentType("application/pdf");
                   response.setHeader("Content-Type", "application/pdf");
                   response.setDateHeader("expires", 0);
                   //output the binary stream via the response object
                   docBinaryView.getContent(response.getOutputStream());
                   System.out.println("Document converted");
                   //To view an individual report, call Report.getView
                   //Open the first version of the document and save.
                   DocumentInstance docToSave = repEngines.getDocumentFromStorageToken(docToken);
                   docToSave.save();
                   System.out.println("Document converted");
                   // Close of the reportEngine
                   repEngines.close();
                   response.sendRedirect("home.html");
              } else
                   response.sendRedirect("index.jsp");
         } catch (SDKException mySDKExept) {
              response.sendRedirect("index.jsp");
         Opening documents:
         //To view an entire document, call DocumentInstance.getView
    %>
    Edited by: Diego XMunch on Mar 10, 2011 3:41 PM

    But I have this error:
    com.businessobjects.rebean.wi.ServerException: Error interno al llamar a la API 'openDocumentMDP'. (Error: ERR_WIS_30270)
         at com.businessobjects.rebean.wi.occa.OccaDocumentComAdapter.checkOpenDocError(Unknown Source)
         at com.businessobjects.rebean.wi.occa.OccaDocumentComAdapter.openDocument(Unknown Source)
         at com.businessobjects.rebean.occa.OccaReportEngineComAdapter.openDocument(Unknown Source)
         at com.businessobjects.rebean.wi.ReportEngineImpl.openDocument(Unknown Source)
         at com.businessobjects.rebean.wi.occa.WebiReportEngine.openDocument(Unknown Source)
         at org.apache.jsp.login_jsp._jspService(login_jsp.java:163)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:619)

  • Report Engine SDK sample code questions

    Hello,
    I've been able to view a boxi report in an iframe via the Enterprise SDK by modifying the sample code in the HowToViewWebiReports_VB example.
    I'm not totally happy with the way that's working, so I'm looking at using the Report Engine SDK, although I understand it's performance and scalability isn't quite as good as the Enterprise SDK.
    I'm a VB.NET guy, not a C# guy, and I'm not clear on how the wssdk_net2.0_portal_sample_12.0_en example is supposed to work.
    I don't have one and my CMS server is running Tomcat, not IIS so there's not going to be an ASP.NET web service running there.
    In the dsws.config for the wssdk_net2.0_portal_sample_12.0_en example I put the name of the CMS server, but it's looking for a web service at http://cmsservername:8080/dswsbobje/services/Session, but I get a 404 when i try to hit that. 
    I'm not familiar with Tomcat, but in searching around on the server, I see a dswsbobje directory under the webapps in my Tomcat installation, but I don't see a services or a Session folder underneath that.  In the dswsbobje folder I see the following folders:
    BOAR-INF
    META-INF
    WEB-INF
    xsd
    Is there something else that needs to be installed on the Tomcat server to get the web service running?
    -Eric

    It looks like I have something there.  When I launch launch http://servername:8080/dswsbobje,  I see:
    Apache-AXIS
    Hello! Welcome to Apache-Axis.
    What do you want to do today?
    Validate the local installation's configuration
    see below if this does not work.
    To enable the disabled features, uncomment the appropriate declarations in WEB-INF/web.xml in the webapplication and restart it.
    Validating Axis
    If the "happyaxis" validation page displays an exception instead of a status page, the likely cause is that you have multiple XML parsers in your classpath. Clean up your classpath by eliminating extraneous parsers.
    I clicked on the "Validate" link and I see:
    Axis Happiness Page
    Examining webapp configuration
    QaaWS Configuration
    QaaWS Servlet is not valid.
    ErrorServer servername not found or server may be down
    See Web Application log to get more info or read QaaWS v2 documentation starting with section
    Perhaps this environment needs some additional configuration?

  • Report Engine SDK: CommunicationException when accessing IReportEngine members

    Hello,
    I have installed BOXI 3.1 SP3, including the .NET SDK, and I am trying to use the Report Engine SDK part to navigate through a WebIntelligence document (analyse its structure, etc.), via a Console App.
    I built my console app targeting .NET framework 3.5, and compiled it in 32 bits mode (x86 platform). I can access the standard SDK without any problem and log in to the CMS then retrieve any InfoObject instances from my enterprise server.
    My problem occurs when I try to access my BusinessObjects.ReportEngine.IReportEngine instance's members. Sample lines of code:
    SessionMgr sessionManager = new SessionMgr();
    EnterpriseSession session = sessionManager.Logon(login, password, cmsName, authType);
    InfoStore infoStore = (InfoStore)session.GetService("InfoStore");
    UserInfo userInfos = session.UserInfo;
    string logonToken = session.LogonTokenMgr.CreateWCAToken("", 1, -1);
    ReportEngines reportEngines = new ReportEngines(logonToken);
    IReportEngine reportEngine = (IReportEngine)reportEngines.getService(ReportEngineType.WI_ReportEngine);
    bool test = reportEngine.IsReady; // or any other member of reportEngine, like reportEngine.OpenDocument(...)
    An exception of type 'BusinessObjects.ReportEngine.CommunicationException' occured.
    Message:
    The Web Intelligence server could not be reached. Contact your Business Objects administrator. (Error: RWI 00236), Session Init Failure,
    Stacktrace:
       à BusinessObjects.ReportEngine.WI.Internal.Server.OCCA.OCCAServerStub.Connect(Boolean forceNewInstance)
       à BusinessObjects.ReportEngine.WI.Internal.Server.OCCA.OCCAServerStub..ctor(OCCAServerConnection connection, Boolean forceNewInstance)
       à BusinessObjects.ReportEngine.WI.Internal.Server.OCCA.OCCAServerConnection.get_Stub()
       à BusinessObjects.ReportEngine.WI.Internal.Server.ServerCaller.SetupStub()
       à BusinessObjects.ReportEngine.WI.Internal.Server.ServerCaller..ctor(IServerSession session, IServerProtocol protocol, IServerConnectionInfo info)
       à BusinessObjects.ReportEngine.WI.Internal.WIDocumentInstance..ctor(WIReportEngine engine, Int32 documentId, OpenDocumentParameters parameters)
       à BusinessObjects.ReportEngine.WI.Internal.WIDocumentInstance..ctor(WIReportEngine engine, Int32 documentId)
       à BusinessObjects.ReportEngine.WI.Internal.WIReportEngine.GetAnyServerInstance()
       à BusinessObjects.ReportEngine.WI.Internal.WIReportEngine.get_IsReady()
    What do you suggest?

    Hi,
    Enterprise / ReportEngine SDK is not supported / tested / compatible with desktop / console apps.
    Could you try the same logic with a web services sdk, as WebServices SDk is the only SDK which could be used to develop thick client apps.
    - Bhushan
    Follow us on Twitter
    Got Enhancement ideas? Try the SAP Idea Place
    Getting started and moving ahead with Crystal Reports .NET applications.

  • BO edge 3.1 howto Report Engine SDK sample

    Hello,
    I'm trying to install any report engine SDK sample on a BO Edge 3.1 installation.
    The webserver is WACS (Web Application Container Server).
    I don't know how to set up a web application that uses the SDK, and I cannot find any useful documentation.
    Has anyone done this?

    Hello,
    Crystal and Xcelsius are client tools so you don't need to install them on the server.
    It might be useful to install them on it when you are troubleshooting issues which might be related to network (firewall, load balancer,...) but otherwise you can keep them on the clients machine.
    The client machines connect to the server by specifying the server details (CMS name and valid user account) when you try to export the reports to the repository.
    Regards,
    Philippe

  • Passing dynamic prompt value using Report Engine SDK

    Hello Experts,
    I have created a webi report which contains prompt. Using SDK, I would like to catch the value of prompt which is selected by a user at runtime.
    e.g. If prompt contains values year, quarter, month, etc and user has selected value of u2018Quarteru2019 at run time, then I would like to catch that value using Report Engine SDK.
    I tried to implement prompt.getCurrentValues(). However that is not working.
    Can someone please help me to figure out the way to catch this dynamic prompt value using Report Engine SDK?
    Thanks,
    John

    Where is the prompt values being set, and where are you trying to catch it?
    Workflow description is missing here.
    Sincerely,
    Ted Ueda

  • How to get Portal user from a standalone Java application

    Hi,
    I have a standalone Java application from where I need to fetch the Portal User Information like userid and email id.
    I am using the below line of code
    iUser = UMFactory.getUserFactory().getUserByLogonID("e017939");
    I have included the jar file com.sap.security.api , But it was giving me the below exception
    java.lang.NoClassDefFoundError: com/sap/tc/logging/Location
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:55)
         at com.am.wcas.java.mailscheduler.kmaccess.FetchDataFromKM.getiUser(FetchDataFromKM.java:29)
         at com.am.ScheduleEmails.main(ScheduleEmails.java:89)
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Then I went throught he SDN threads and they asked me to include the
    logging.jar and com.sap.security.perm.api .
    I Included them, then also, it is giving me Exception
    java.lang.NoClassDefFoundError: com/sap/engine/lib/logging/LoggingHelper
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:56)
         at com.am.FetchKMData.main(FetchKMData.java:30)
    Exception in thread "main"
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Kindly let me know if it is possible to access the User info using UMFactory in a standalone Java application. If yes kindly let me know where i am going wrong.
    Regards,
    Shilpa B.V

    Hi Shilpa,
    1. Check that you have added com.sap.security.api within the Your Project>Libraries folder (under navigation tab) and also added jars in the build path of the Your Project under project>properties>Build Path.
    2. In case you have a DC instead of Web Dynpro Project then you have to add the com.sap.security.api under Your DC>Used DCs and have compile time and runtime dependency added.
    Here java.lang.NoClassDefFoundError is caused basically due to only build time dependency added and reference to the jar missing at runtime. Rest the code to retrieve the current user id using UME API and getUserByLogOnID("....") method with/without portal environment would not be an issue at all.
    Regards,
    Tushar SInha

  • Reading a XML file in a standalone java application

    Hi,
    What are my options if I have a standalone java application running outside any app. server and I need to read an XML file, probably read some of the attributes in the file...? Please explain clearly as I'm new to this. Appreciate your help.
    Thanks,
    Mahdad

    nope you don't need a DTD
    you have to write your Java code in a way that doesn't rely too much on the structure:
    - avoid getFirstChild().getFirstChild()... because you know that this element is first grandson of that element)
    - prefer using getElementByTagName() or some XPath() API
    but if the XML completely changes, well, yeah, you have to do some programmation: better think well your document structure in the beginning.

  • What should be done in certmap.conf for 2-way SSL support from a standalone Java application to an SSL enabled LDAP Server

    To support certficate based client authentication using 2-way SSL from a standalone java application which uses JNDI and JSSE1.0.2 to connect to an SSL enabled LDAP Server how do we configure the certmap.conf?Is there any additional setup required at the LDAP Server side apart from enablinf SSL with the option"Required Client Authentication" enabled.The 2 way SSL handshake goes through but the access log file (After configuring the certmap.conf for the issuer DN of the client certficate etc..)shows SSL failed to LDAP DN?But inspite of this access log error the Java client does get an SSL Connection object with which it is able to connect to the LDAP.IS the certmap.conf file being looked up by the LDAP Server at all?

    have you out.flush() and out.close() before you call connection.getInputStream()?

  • Can we call a webservice  using standalone java application  ?

    Hi friends,
                   Can we call configurd webservice in xi , using standalone java application by just giving url of webservice ?
                  OR
                  Only by means of WEBDynapro we can call  ?
                    Can you please tell me the answer for this .
    Regards .,
    V.Rangarajan

    HI Ranga Rajan
    well, If at all if you have webservice...you can import that werbserivce as External definition in to IR.
    How to import:
    1) Go to IR and and move to your requied component and there you can see the option called imported objects...select on imported objects where you can give the name and you can select the webservices which you want to use it.
    2) Hope you are aware of that a werbservice will have the request and response.
    3) Create the mapping program accroding to your requirement.
    Go through blogs of Bhavesh and Naveen which talks about calling webservice in a specific condition:
    Webservice Calls From a User Defined Function - /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function
    Consuming/Calling webservices from DataBases - /people/sap.user72/blog/2005/10/20/consumingcalling-webservices-from-databases
    Also check this help file on Web Services:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/336365d3-0401-0010-9884-a651295aeaa9
    Cheers..
    Vasu
    <i>** Reward Points if found useful **</i>

  • Accessing JNDI from Standalone JAVA application

    Hi,
    I want to access the JNDI tree from my
    standalone java application. (ie I have
    one weblogic server contains all my ejbs and client - swing - application which accesses that. )
    Here I don't want to ship weblogic.jar
    file to the client with swing application
    because it is of ~ 20 MP.
    Any other way to specify the INITIAL_CONTEXT_FATORY class.
    My code is
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
    But since I don't want to give the
    weblogic.jar bundle to my client, how he
    could manage this with out weblogic.jndi.WLInitialContextFactory
    with him to get the initialContext ?
    -Rajan Kumar

    You can strip out the jndi related classes from the weblogic.jar which can be distributed
    to the client installation. I don't think you will be violating any bea licensing
    policies with this.
    Rajan Kumar <[email protected]> wrote:
    Hi,
    I want to access the JNDI tree from my
    standalone java application. (ie I have
    one weblogic server contains all my ejbs and client - swing - application
    which accesses that. )
    Here I don't want to ship weblogic.jar
    file to the client with swing application
    because it is of ~ 20 MP.
    Any other way to specify the INITIAL_CONTEXT_FATORY class.
    My code is
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
    But since I don't want to give the
    weblogic.jar bundle to my client, how he
    could manage this with out weblogic.jndi.WLInitialContextFactory
    with him to get the initialContext ?
    -Rajan Kumar

  • Standalone java application that calls Db2

    Hi,
    I am trying to use coherence in my standalone java
    application that makes JDBC calls to Db2.
    The sql statemet is like below:
    select lastName,firstName from employee where empNo=2224;
    In the application,I would read from the flat file say
    200 account numbers and query the database.
    If I have queried the database already with the given
    account,I want to retreive from the cache.
    I am having real trouble in getting this work with
    coherence software.
    Any psudo code in this regard will help me a lot.
    Thanks
    DJon

    Hi Jon,
    Thanks for the mail.I am struck in
    implementing the coherence in the sample program.
    any help in this regard is appreciated.
    Thanks
    DJon
    Below is the sample program that works without coherence.go to db2 and get the information.
    import java.sql.*;
    import java.util.*;
    public class DB2Client
    static void printColumn(String in)
    System.out.print(in);
    System.out.print(" | ");
    public static void main(String[] args)
    Driver myDriver = null;
    Connection myConnection = null;
    try
    myDriver =
    (Driver)Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
    myConnection =
    DriverManager.getConnection("jdbc:db2:sample","dujon","jeff");
    PreparedStatement myStatement
    = myConnection.prepareStatement("SELECT
    empno,firstnme,lastname FROM employee where empno > ?");
    myStatement.setString(1,"00");
    ResultSet
    myResults=myStatement.executeQuery();
    while (myResults.next())
    printColumn(myResults.getString("empno") + "");
    printColumn(myResults.getString("firstnme") + "");
    printColumn(myResults.getString("lastname"));
    System.out.println();
    } catch (Exception e)
    e.printStackTrace();
    } finally
    try
    if (myConnection != null)
    myConnection.close();
    } catch (Exception e)
    Now,to implement the above sample with
    coherence I have written 2 programs.
    1. TangosolDB2Cache.java
    2. TestDB2Cache.java
    import com.tangosol.net.cache.CacheStore;
    import com.tangosol.util.Base;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    * An example implementation of CacheStore
    * interface.
    * @author erm 2003.05.01
    public class TangosolDB2Cache extends
    Base implements CacheStore
    // ----- constructors
    * Constructs DBCacheStore for a given
    database table.
    * @param sTableName the db table name
    public TangosolJDBCCache(String
    sTableName)
    m_sTableName = sTableName;
    configureConnection();
         * Set up the DB connection.
         protected void configureConnection()
              try
    Class.forName("com.ibm.db2.jcc.DB2Driver");
                   m_con =
    DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
                   m_con.setAutoCommit(true);
              catch (Exception e)
                   throw ensureRuntimeException(e,
    "Connection failed");
         // ---- accessors
    * Obtain the name of the table this
    CacheStore is persisting to.
    * @return the name of the table this
    CacheStore is persisting to
    public String getTableName()
    return m_sTableName;
    * Obtain the connection being used to
    connect to the database.
    * @return the connection used to
    connect to the database
    public Connection getConnection()
    return m_con;
    // ----- CacheStore Interface
    * Return the value associated with the
    specified key, or null if the
    * key does not have an associated
    value in the underlying store.
    * @param oKey key whose associated
    value is to be returned
    * @return the value associated with
    the specified key, or
    * <tt>null</tt> if no value is
    available for that key
    public Object load(Object oKey)
    Integer iKey = (Integer)key;
         return query("select
    lastName,firstName from employee where empNo = " + iKey);
    * Store the specified value under the
    specific key in the underlying
    * store. This method is intended to
    support both key/value creation
    * and value update for a specific key.
    * @param oKey key to store the
    value under
    * @param oValue value to be stored
    * @throws
    UnsupportedOperationException if this implementation or the
    * underlying store is
    read-only
    public void store(Object oKey, Object
    oValue)
              mycacheTable(oKey,oValue);
    public void erase(Object oKey)
         public void eraseAll(Collection
    colKeys)
              throw new
    UnsupportedOperationException();
         public Map loadAll(Collection colKeys)
              throw new
    UnsupportedOperationException();
         public void storeAll(Map mapEntries)
              throw new
    UnsupportedOperationException();
         // ----- data members
         Hashtable mycacheTable = new Hashtable(1000);
         * The connection.
         protected Connection m_con;
         * The db table name.
         protected String m_sTableName;
         * Driver class name.
         private static final String DB_DRIVER =
    "org.gjt.mm.mysql.Driver";
         * Connection URL.
         private static final String DB_URL =
    "jdbc:db2:sample";
         * User name.
         private static final String DB_USERNAME =
    "dujon";
         * Password.
         private static final String DB_PASSWORD =
    "jeff";
    TESTING THE ABOVE PROGRAM
    import com.tangosol.net.cache.CacheStore;
    import com.tangosol.util.Base;
    import
    com.tangosol.net.cache.MapCacheStore;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    public class TestDB2Cache {
         public static void main(String args[]){
                        TangosolJDBCCache mycache = new
    TangosolDB2Cache("employee");
                        Connection
    con=mycache.configureConnection();
                        MapCacheStore cacheStuff = new
    MapCacheStore(HashMap hmap);
                        String[] employeeNumbers =
    {"000010","000020","000030","000040","000050"};
                                  // find whether it has been cached already
                                       for(int
    i=0;i<employeeNumbers.length();i++){
                                       oCurValue =
    cacheStuff.load(employeeNumbers);
                                       if(oCurValue == null){
                                            // execute SQL statement
                                            con.executeQuery(oCurKey);
                                       else
                                            //get from cache the values and return
                                            cacheStuff.load(oCurKey);

  • How to pack a standalone Java application

    Hi, all. I have a stand alone Java application which includs some classes and some properties files. Meanwhile, I'm using some libraries(in jar files) from 3rd party as library extension.
    When I developed my application in the IDE, I can run it from the IDE and it works fine.
    Now I want to run it out of the IDE, it always complains that is can't find the 3rd party classes. I have tried to modify the classpath to include the extension libraries but it goes no avail. What might be the problem?
    And normally, how will you pack the application to submit it to the end-users? How do you include the libraries from 3rd party without end-users' awareness?
    Thanks a lot!

    Put it in a jar, and use the classpath-setting in the jar manifest file.
    Or extract the 3rdparty libraries, and put everything in a big jar.
    Or provide a .bat-file and a shellscript that sets classpath temporarily.

Maybe you are looking for

  • Address Book - Changing the address format?

    A couple of years ago I imported all my old contacts into address book. I've now discovered that I had the address format set to USA in preferences and I'm a UK user. I've since changed the preference to UK but it this only affects new addresses that

  • How to use SAML in JDeveloper?

    Hi, I am trying to secure the information send between a Web Service secured with an OWSM Gateway and client proxy in JDeveloper using SAML. I can find the security setting in the security wizard for the proxy where you can setup the SAML details but

  • Calling method from jsp file

    Hi is it possible to call any method with in the class except handle method from jsp file?

  • ICloud Drive has stopped responding

    I get this message when I try to open iCloud Drive in icloud.com in Safari

  • DRm 11.1.2.103: Howto: Not allowed to change property value after value set

    Tips on how to ensure this? I would appreciate help on solving the following request: a property must be set by a user (ex property 'Entitytype' of a Unit node). However as soon as the property has been defined (value of property is not blank) this c