Make use of established database connection

From within an application in the Application Navigation, I have successfully established a connection to a database which is on another host machine. The steps are:
right-click on the name of the application > select New > Database Tier > Database Connection > Connection Name ....
After the connection is done, I am able to see the tables, etc. in the Connection Navigation, i.e., the connection was successful.
Under the same application, I created a web project and in the project I am writing a servlet. I figure I can make use of the established connection as described above, to create sql statement object? But I do not know how. For example, I named that connection SbConnection, and tried the statements:
  Statment stmt = null;
  stmt = SbConnection.createStatement();
But it does not work out. I am trying this because the classical way of
  Class.forname(....).newInstance();
  Connection conn = DriverManager.getConnection(......);
does not work no matter how I tried.
I am just starting in doing web application, servlet and JSP etc. and would appreciate a lot for any help.

Fantastic, dvohra! It works out! Thanks a lot for the know-how!
Next I am going to dig out something to read about JNDI and DataSource type of connection. But the part of editing the web.xml is magic and myth to me. Any suggested books or web sites for reading? (After know-how is know-why and know what I am doing.) Many thanks!

Similar Messages

  • JDBC Adapter - Established database connection failed

    Hi Guys,
    we have installed the JDBC Adapter based on the How To Guide and we checked after the installation the  Libaries :Cluster --> Server --> Libraries --> com.sap.aii.af.jmsproviderlib and the box Box "JARs Contained" was filled.
    So in my point of view we have done everything right during the installation.
    Now the developer tested theJDBC Adapter and he comes back with following Error:
    Attempt to establish database connection failed with SQL error com.sap.aii.adapter.jdbc.sql.DriverManagementException: Cannot establish connection to URL "jdbc:microsoft:sqlserver://xxx.x.xx.xxx:1433; databaseName=CZZ03;":ClassNot FoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    Do you have any ideas?
    Regards
    Markus

    Hello Markus,
    To install JDBC driver follow the how to guide.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-how-to-guides/how%20to%20install%20and%20configure%20external%20drivers%20for%20jdbc%20and%20jms%20adapters.pdf
    Configuration of JDBC Adapter for SQL Server
    JDBC Driver = com.microsoft.jdbc.sqlserver.SQLServerDriver
    Connection = jdbc:microsoft:sqlserver://hostname:<port>;DatabaseName=<DBName>
    UserID and Password.
    If the connection is not working find the correct port number.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40b92770-db81-2a10-8e91-f747188d8033
    JDBC- X I -  R/3 Scenario
    /people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
    Thanks,
    Satya Kumar
    Reward Points If it is Useful..

  • How to use Forms Default Database Connection in java class

    When a form based application is started, a connection is made with underlying database. This is the Default (Primay) Database Connection.
    The problem is I have some of my business logic implemented in a java class. In this class I have to make a another connection with the same database. What I want to do is to use the original Database Connection in the java class. In this I may avoid the overhead of reconnection.
    Could anyone pls guide me in this way...

    you can't share the forms connection. Sorry :(

  • Establish Database connection to connect to OEM Repository from Agents

    I have a requirement to establish Database connection from Agent through Plug-in.
    Ex:
    My plug-in metadata will have a perl script which gets executed in each individual agents and it should connect to the OEM Repository database to execute a package.
    Your Help is Appreciable.

    You would have to take in all of the information needed to connect to the database as instance properties for your target type. So each time someone creates an instance of your target type, they'd have to enter the connection details for the repository database.
    The specifics of what are needed should be in the extensibility guide where the SQL fetchlet is documented.

  • Sybase Connection Error - cannot establish database connection

    BO Data Services Tool -> Creation of new Data Store -> Sybase ASE
    When I tried to create a sybase datastore(New connection), I've got this error message. But I am able to connect to sybase database with client application with same connection parameter. I appreciate if someone come across same issue.
    ERROR MESSAGE
    *WARNING: Cannot establish database connecton.
    u2018Sybase connecton error: <Sybase ASE Server message number <1640> State <2> Severity <16> From Server <tstlS03>: Message Text is:
    Adaptve Server requires encrypton of the login password on the network.
    Sybase ASE Server message number <4002> State <1> Severity <14> From Server <tstlSO3>: Message Text is: Login failed.
    Sybase CS Library message number <6717S468> Severity <4>: Message Text is: ct_connectO: protocol specific layer: external error: The attempt to connect to the server failed.>.u2019 lODI- 1111341)

    I tried to create repositories for sybase, it failed.  But it succeeded when created datastore.  The procedures's as follow:
    1. Create ODBC for this sybase connection, and it should display "Connection successful" when you click "Test connection".
       (you need to specify several parameters like user id & password, server,database name and file, etc.)
    2. Create datastore by using ODBC connection.

  • Regarding using a javabean database connections file

    Hi..I have a javabean file which contains some database connections.I would like to use this file in another javabean file. However, I got this 'cannot resolve symbol' error on the following line.The two javabean files i have here are sqlBean and TransactInfoBean which are contained in the same package.
    <coding>
    public class TransactInfoBean extends sqlBean {
    </coding>

    Are you sure you've got everything right ? One big problem with Java is that there is a difference between myClass and MyClass. A simple capital can make a big difference.

  • Manually establish database connection everytime!!

    Hi,
    This issue just happen recently,
    whenever I try to log in to SAP portal, I have to manually key in the db details everytime in order to establish the connection.
    In other words, SAP cannot remember the db connection, which make me really troublesome.
    I had try to ping the server and is working fine.
    So far I have no idea what might cause the issue happen.
    Just hope I can get solution right here.
    Machine info:
    Win xp pro SP 3
    SAP version:
    SAP Business One 2007 B (8.60.041)  SP:00  PL:20
    Thanks for the help..!

    You would have to take in all of the information needed to connect to the database as instance properties for your target type. So each time someone creates an instance of your target type, they'd have to enter the connection details for the repository database.
    The specifics of what are needed should be in the extensibility guide where the SQL fetchlet is documented.

  • Use of oledb database connection in input form of process

    I've created dynamic pdf form with data connection to mssql database and with script that automatically adds rows to table and fills fields.
    When I try to open this form as input form for my process in workspace it generates an error: Unable to create SOM expression. That means that sql database connection works not properly.
    How can I fix this? Is it possible to use data connection to oledb database in the input form?

    Hi,
    I have a form that includes db connection (OLDB ->Access). But in
    workspace I have an error while initiating it. The error is an Adobe Acrobat message;
    "Unable to create SOM expression $record.tablename.fieldname"
    I am using Acrobat 9 pro ext. and when I use reader then there is no problem.
    I removed enhanced security settings in preferences of Acrobat. What else i can do? Any suggestions?
    Thank in advance..

  • Need help Crystal Reports running in BO 4.1 while using Universe as database connection.

    Sorry, I may not know how to describe this in the correct technical manner, but I'll explain in as simple terms as I can.
    I open up Crystal Reports 2013 click new document
    and it begins to ask for Database Expert.
    I select Universes and log in to my Business Objects Enterprise Explorer.   I then select the Universe that I want to write my report with,
    then i save the rpt on my local machine.
    then I log into my Business Objects 4.1 CMC or BI and upload this rpt file so that I can begin to schedule the report for example...
    but the problem i have is whenever I try to run the report, 
    it asks for a prompt for my database connection...  
    it displays the Universe name, but User Name Password, I am not sure what to write,
    do I write My login for Business Objects?  do I write the user name password of the database that Universe uses?
    in CMC I see a database configuration,  I tried many combinations and still have been receiving the following error message
    The viewer could not process an event. The database logon information for this report is either incomplete or incorrect. []
    ---- Error code:0 [CRWEB00000119]
    From all I read the point of using the Universe in Crystal reports is to be automatic in such a way that it doesnt need the database conneciton, because its technically using the Universe as the database connection....
    so what am I doing wrong here?    maybe its my database configuration,    I keep reading that it doesnt need anything...   that you upload the Crystal Reports and it would just work...
    any help with this issue would be greatly appreciated..
    thanks
    -Daniel

    Hi Daniel,
    What is the reporting DB used?
    The trick with your configuration is the following:
    - Universe Designer: 32bits application that may work fine on your desktop
    - Crystal 2013: 32bits application as well
    - When you export to the repository, Web Intelligence (64bits) has to process the Universe to extract the query.
    Your server should have the drivers required for Crystal + Universe: 32bit and 64bit versions.
    See more details on this KBA:
    https://service.sap.com/sap/support/notes/1821625
    Regards,
    Julian

  • Use ADF Default Database Connection

    Hi All,
    I am writing a class that requires to connect to the database and perform some functions. This class is invoked from a button. My challenge is, how can I use the current adf application database connection (jndi) instead of creating another class that returns a connection object?
    Thank you.
    Eric.

    Are you using ADF BC in your application?
    If so you can write an AM Service method that uses the current connection/transaction - and then use that method from your UI button.
    http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/bcadvgen.htm#BABEIFAI
    and then
    http://blogs.oracle.com/shay/2010/07/am_service_method_-simpledem.html

  • Establishing Database connection for XML Data Definition?

    I have a XML Data Definition which will query data from Oracle Database.
    I did some research and tried few setting options in JDeveloper (11g), but had no luck on finding a way to connect to Database.
    My goal is to use JDeveloper to run a XML Data Definition against Database and generate a XML File with data.
    Can this be done?
    Data Definition:
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <dataTemplate name="XX_ATT_VALIDATION" description="description"
    dataSourceRef="MTS-AT"
    version="1.0">
    <properties>
              <property name="include_parameters" value="false" />
              <property name="include_null_Element" value="true" />
              <property name="include_rowset_tag" value="false" />
    </properties>
    <parameters>
              <parameter name="p_batch_id" dataType="character"/>
    </parameters>
    <dataQuery>
         <sqlStatement name="Q_HEADER_VALUES">
              <![CDATA[
    select distinct
    sci.bill_cycle,
    to_char(sci.bill_date,'mm/dd/yyyy') bill_date,
    to_char(sysdate,'mm/dd/yyyy') report_run_date
                   from st_cm_interface sci
                   where sci.record_type='05'
                   and sci.batch_id=:p_batch_id
              ]]>
    </sqlStatement>
    <dataStructure>          
         <group name="G_HEADER_VALUES" source="Q_HEADER_VALUES">
    <element name="bill_cycle" value="bill_cycle"/>
    <element name="bill_date" value="bill_date"/>
    <element name="report_run_date" value="report_run_date"/>
    </group>
    </dataStructure>
    </dataTemplate>

    Hi,
    Consider there is 2 database, Oracle_1 and Oracle_2.
    I want to fetch some table data in Oracle_2 from Oracle_1 database Stored procedure/functions through query staments and cursors. How to establish the Oracle_1 DB connection in Oracle_2 DB stored procedure/function. Is it possible?
    It's not the same how you implement the programs in java or .Net to create DB connection. It's different over here. You have use the DataBase Links in order to make to connection with another DB and use that Link in the stored procedure or function where ever its necessary as per your requirement.
    - Pavan Kumar N

  • Establishing database connection in stored procedures/functions

    Hi, any body knows how to do it....
    Consider there is 2 database, Oracle_1 and Oracle_2.
    I want to fetch some table data in Oracle_2 from Oracle_1 database Stored procedure/functions through query staments and cursors. How to establish the Oracle_1 DB connection in Oracle_2 DB stored procedure/function. Is it possible?

    Hi,
    Consider there is 2 database, Oracle_1 and Oracle_2.
    I want to fetch some table data in Oracle_2 from Oracle_1 database Stored procedure/functions through query staments and cursors. How to establish the Oracle_1 DB connection in Oracle_2 DB stored procedure/function. Is it possible?
    It's not the same how you implement the programs in java or .Net to create DB connection. It's different over here. You have use the DataBase Links in order to make to connection with another DB and use that Link in the stored procedure or function where ever its necessary as per your requirement.
    - Pavan Kumar N

  • Using predefined JDBC database connection in runtime for BC4J

    I've created an aplication using BC4J context, however I want to have several distinct users acessing this aplication, so I create the connection to the database using stantart JDBC 2.0, and now I want my application to use this connection instead of the one defined for BC4J.
    The database user owner of the objects must be locked.
    Is this possible?
    Many thanks.
    Nuno

    In Forms I used the following code to change the user at runtime. I created 3 char fields 'u','p' and 'c' for username, password and connect string respectively.
    declare
    uname varchar2(10);
    begin
    uname := get_application_property(username);
    -- To display your current username
    message(uname);
    pause;
    logout;
    logon(:u,:p&#0124; &#0124;'@'&#0124; &#0124;:c);
    end;
    Have a nice day,
    Abhijith Unnikannan,
    Oracle Support Services

  • Why it takes long time to establish Database Connection ???

    Can any one please have a look on the following code snippet and show me which mistake I'm doing so it take long time to connect to DB(more than 5 minutes !!!!)
    Thanx in advance ...
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String dbString2 = "jdbc:oracle:thin:@" + "127.0.0.1" + ":" + "1521" + ":" + "nat";
    aCon = DriverManager.getConnection(dbString2, "scott", "tiger");
    stmt = aCon.createStatement();
    System.out.println("Connection to DB Established");
    catch (ClassNotFoundException cnfe)
    System.out.println("Class not found:");
    cnfe.printStackTrace();
    catch (SQLException sqle)
    System.out.println("SQL Exception: " + sqle.toString());
    sqle.printStackTrace();

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Why do you need this if you are going to Oracle. Try
    removing this. It might be trying things out with the
    old driver and then moving to the new driver. This has nothing to do with it. (And it doesn't "try things out")
    >
    Also check your machines. They might be slow. There is
    no reason, it should take more than few hundred
    milliseconds to connect to a database on localhost as
    your case is.Possible reasons...
    - Network traffic
    - Faulty router/gateway
    - Busy server
    - Faulty network card (either end)
    - Conflict with another box

  • How to make use of logical database in reports?

    hi,
    I am working on a Cash Flow Forecast report, which requires the usage of 'PSJ' Logical Database for the selection screen with Profit Center(PRCTR) as one field and the other field being Period ( in MM/YYYY format).
    I have not worked on Logical Database before. Since, its for the first time I am working on LDB, I require help on it.
    How to proceed for this, can someone help me with it?
    On receiving further inputs, I will proceed and might come up with some more queries.
    Regards,
    Ravi

    Hi Hari,
    Thanks a lot for being so patient. yeah, I will just send you a code snippet of mine. My code is of 3000 Lines. Hence, I will send few parts of it. Just go through and let me know if you need any further information from my side.
    Here is the snippet:
    *& TABLES
    TABLES: PROJ,                              "Project definition.
            PRPS,                              "WBS Element Master Data
            COSP,                              "CO: External Table.
            COFP,                              "CO: External Table.
            SETLEAF,                       "Value in sets.
            FAGLFLEXT,                         "Profit Center.
            S031,                              "Statistics: Movements for Current Stocks.
            SETHEADERT,                        "short Description of Sets.
            AFVC,                              "Operation within an Order.
            AUFK,                              "Order master data.
            PRHI,                              "Work Breakdown Structure.
            AFKO,                              "Order header data PP orders.
            NRIV,                              "Number range Intervals.
            SKB1,                              "G/L Account Master (company code).
            FMCI.                              "Commitments Item master data.
    Type Pool
    TYPE-POOLS: SLIS.
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>,
                   <DYN_FIELD>.
    DATA: COUNT TYPE I,
          D_PERIOL LIKE COFP-PERIO,
          D_PERIOH LIKE COFP-PERIO,
          D_GJAHRL LIKE COFP-GJAHR,
          D_GJAHRH LIKE COFP-GJAHR,
          D_GJAHR LIKE COFP-GJAHR,
          D_PERIO LIKE COFP-PERIO,
          OBJNR LIKE COSP-OBJNR,
          PKOKR LIKE PRPS-PKOKR,
          G_NRLEVEL LIKE NRIV-NRLEVEL,
          G_BELNR LIKE COFP-BELNR,
         I_OBJ-OBJNR LIKE COFP-OBJNR,
          G_OPNGBAL LIKE FAGLFLEXT-HSL01,
          G_PAYROLL LIKE COSP-WKG001,
          G_PYROL_TAX LIKE COFP-WKGBTR,
          G_PENSION LIKE COFP-WKGBTR,
          G_BTLDGR LIKE COFP-WKGBTR,
          G_REIMPYMT LIKE COFP-WKGBTR,
          G_INTCORCPT LIKE COFP-WKGBTR,
          G_CAPEXP LIKE COFP-WKGBTR,
          G_SLSLDGR LIKE COFP-WKGBTR,
          G_REIMRCPT LIKE COFP-WKGBTR,
          G_TOTPYMNTS LIKE COFP-WKGBTR VALUE 0,
          G_TOTRECPTS LIKE COFP-WKGBTR VALUE 0,
          G_MVMTFRMNTH LIKE COFP-WKGBTR VALUE 0,
          G_CLSGBAL LIKE COFP-WKGBTR VALUE 0.
    DATA: LYEAR(4) TYPE N,
          LMONTH1(2) TYPE N,
          MON1(2) TYPE N.
    DATA: HYEAR(4) TYPE N.
    DATA: LMONTH(2) TYPE N.
    DATA: HMONTH(2) TYPE N.
    DATA: TOTAL(10) TYPE N.
    DATA: SUM(10) TYPE N.
    DATA: G_PSPID LIKE PROJ-PSPID.
    DATA: TOTAL1 LIKE COFP-WKGBTR,
          TOTAL2 LIKE COFP-WKGBTR.
    DATA: G_KOKRS LIKE COFP-KOKRS,
          G_FIPOS LIKE SKB1-FIPOS,
          G_POSIT LIKE COFP-POSIT,
          G_BUKRS LIKE COFP-BUKRS.
    DATA: L_RACCT LIKE FAGLFLEXT-RACCT VALUE '0000220000',
          H_RACCT LIKE FAGLFLEXT-RACCT VALUE '0000227999'.
    DATA: I TYPE I VALUE '74'.
    DATA: P TYPE I VALUE '62'.
    *& SELECT-OPTIONS
    PARAMETERS : S_PRCTR LIKE PROJ-PRCTR.         "Profit Center
    SELECT-OPTIONS: SL_SPMON FOR S031-SPMON OBLIGATORY.            "Period
    *INITIALIZATION
    INITIALIZATION.
      SL_SPMON-SIGN = C_IN.
      SL_SPMON-OPTION = C_BT.
      SL_SPMON-LOW = SL_SPMON.
      SL_SPMON-HIGH = SL_SPMON.
      APPEND SL_SPMON.
    AT SELECTION-SCREEN
    Event which occurs each time the user hits enter on the selection
    Screen.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR SL_SPMON-LOW.
      PERFORM MONAT_F4.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR SL_SPMON-HIGH.
      PERFORM MONAT_F4.
      SELECT SINGLE * FROM PROJ WHERE PRCTR = S_PRCTR.
      IF SY-SUBRC <> 0 AND NOT ( S_PRCTR IS INITIAL ).
        MESSAGE E019.
      ENDIF.
    ALL WBS ELEMENT SELECTION
      SELECT PSPID INTO TABLE I_PROJTAB FROM PROJ WHERE PRCTR = S_PRCTR.
      IF SY-SUBRC = 0.
        LOOP AT I_PROJTAB.
          CALL FUNCTION 'GET_TREE_FROM_PRHI'
            EXPORTING
              I_POSID                   = I_PROJTAB-PSPID
       I_PSPNR                   = 00000000
       NO_BUFFER                 = ' '
            TABLES
              PSP_TREE                  = I_PRHI
            EXCEPTIONS
              INPUT_ERROR               = 1
              PSP_HIERARCHY_ERROR       = 2
              PSP_NOT_FOUND             = 3
              OTHERS                    = 4
       ENDLOOP. " PROJTAB
      ENDIF.
      SELECT * FROM PRPS INTO TABLE I_PRPSVC FOR ALL ENTRIES IN I_PRHI
                      WHERE PSPNR = I_PRHI-POSNR.
      SELECT * FROM AFVC INTO TABLE I_AFVC FOR ALL ENTRIES IN I_PRPSVC
                      WHERE PROJN = I_PRPSVC-PSPNR.
      SELECT * FROM AUFK INTO TABLE I_AUFK FOR ALL ENTRIES IN I_PRPSVC
                      WHERE PSPEL = I_PRPSVC-PSPNR AND AUTYP NE C_TWENTY.
      SELECT OBJNR FROM PRPS INTO TABLE I_OBJ FOR ALL ENTRIES IN I_PRHI
                      WHERE PSPNR = I_PRHI-POSNR.
      IF SY-SUBRC <> 0.
        MESSAGE E010.
      ENDIF.
    I hope that's of some use.
    Thanks & Regards,
    Ravi

Maybe you are looking for

  • PC Users: From iPod to iTunes

    I have created a huge mess when I attempted to move iTunes onto an external hard drive. It is such a huge mess that I want to delete the current data from iTunes and transfer my music from my iPod to iTunes to retrieve my library. I tried downloading

  • Unable to Start LR?

    I have been unable to use LR 4 for weeks and I get an error message to the effect:  Application unable to start (0xc000007b).  What is Adobe's solution to this problem?  Its holding up my workflow as a photographer. LouSeyler

  • Enable comma separated values (CSV) output

    I am trying to figure out how to (Enable comma separated values (CSV) output ) for a report. Do you have an example or info on how to do that?

  • How to export playlist in mp3 format onto usb using MAC

    I have seen suggestions but using PC itunes and there must be small differences since it does work for me. Two main problems 1) returning back to mp3.  2) exporting  playlist to usb. Thanks for any help!

  • Appearance Panel blank in CC 2014 latest update

    When I open the appearance panel, with an object selected which has fills, strokes and a drop shadow, the appearance panel is blank. The panel appears, the fly-out menu is functional, but nothing else is there, just gray. Screenshot below: Is this a