Using Java within a stored proc to access multiple database connections

Hi List;
We have an environment where we have needs to provide cross database visibility between Oracle, Sql Server and PostgreSQL. So we need the capability for Oracle to query PostgreSQL and Sql Server tables, PostgreSQL must be able to query Oracle and Sql Server tables and Sql Server must be able to query Oracle and PostgreSQL tables.
I'm thinking that we can implement stored procs which are either written in java or call a java process . The java code in turn should be able to connect to any DBMS desired via JDBC query the tables in question and return the result set to the calling database.
Any thoughts on how feasable this is would be appreciated. Does this seem like a solid solution? Any initial concerns or red flags? what about performance via JDBC?
Thanks in advance for your help.

John,
from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
Timo

Similar Messages

  • Should I do this with Java Code or Stored Procs ? (for best performance)

    Hi All,
    I need to decide where should I implement my business logic, in Java code or Stored procs.
    Here is the requirement :
    - One Order has 70 products (Order_Table )
    - Can be duplicate products, so I have to do summarize / grouping by product
    - For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
    - This is done when/after the transaction is SAVED (COMMIT)
    The question is, which one has better PERFORMANCE :
    (1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
    OR
    (2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
    OR
    (3) I do all the logic with Java Code within ADF
    Given the requirement above, which approach is most efficient / best performance ?
    Thank you very much,
    xtanto

    Problem with this is that you ask 100 people and you probably get 100 different answers. ;o)
    Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
    In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
    Can't be more precise than that.
    Grant

  • Anyone knows about using java to get data from MS Access database.

    hi there
    anyone knows about using java to get data from MS Access database? thank you

    there is a list of jdbc drivers at:
    http://industry.java.sun.com/products/jdbc/drivers
    they have several ms access drivers listed.
    also, you can use a jdbc-odbc bridge which allows you to use jdbc to connect to any odbc data source:
    http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/bridge.doc.html

  • Using Single Datasource to Access Multiple Databases

    Hi,
    We would like to know the pros and cons of accessing multiple
    databases through a single datasource, versus accessing each
    database through its own datasource. Our environment includes
    multiple web servers w/ the latest version of ColdFusion MX 7,
    clustered through a load balancer. Each web server has 800+ dsns
    pointing to different SQL databases on the same SQL server. We have
    noticed that the ColdFusion administrator is taking a long time to
    display or verify all datasources and sometimes it even times out.
    Another problem is that sometimes the neo-query file gets corrupted
    (for unknown reasons) which results in the deletion of one, or
    more, or all datasources on the web server.
    Because of the issues above we are researching the
    possibility of removing most of the datasources, and then accessing
    each database through a single bridge datasource. In that regard we
    plan to change our queries by inserting the sql db name and user in
    front of each table in the query such as:
    <cfquery name="query" datasource="single_dsn_name">
    select * from [#dbname#].dbo.tableName
    </cfquery>
    In the example above, obviously #dbname# would be a variable
    that will hold the name of the requested database. The code above
    would similarly apply to queries using, update, insert and join
    words.
    Are there any limitations or negatives from scalability,
    performance, and reliability perspective in implementing the above
    scenario versus having one datasource for each database.
    Also, if there is a better way of accomplishing this, we
    would love to hear about it.

    Here is my opinion, because I work with both schemas. The
    main advantage to use one datasource for all DBs in a SQL Server is
    the simplicity of administration.
    But the main disadvantage is security, because you are using
    a single user to access all DB in a server, you don't have
    isolation, and a user that knows your schema can access data of
    other DBs that he sould not be authorized.
    Another issue is is a user must access 2 differents DB with
    different permissions (a DB only read and the other read/write),
    you'll have to create another datasource, user, etc for it.
    But the decision depends in the enviroment. If you are a
    hosting company, I would use 1 datasource for user or DB. If the
    servers and DBs are of the same company, I could use one datasource
    for each SQL server.
    Best regards

  • 1 user license access multiple database

    Hi all...
    I have a question :
    In SAP B1 8.8, can 1 user license (for 1 physical user) access multiple databases?
    Multiple database is created for Head Office and Branches.
    Since Finance Accounting Manager is centralized at Head Office, so the Manager must have access to multiple databases.
    Can only 1 user license applied to this Finance Accounting Manager?
    Regards,

    Hi Ingrid,
    Finance/Logistic/CRM Limited will perform as professional user license in the multiple db accessing in one server except  the functionality authorization. You must make sure that all the users that use the Finance/Logistic/CRM Limited license have the same user code in the dbs
    JimM
    <ultra - said it once>

  • Accessing Multiple Databases

    I have a requirement in which I will need to use the same classes to
    access different databases. In other words, let's say I have a Person
    class. I'd like to use the enhanced Person class to pull people from a
    SQL Server database, and an Oracle database.
    The documentation mentions that you can access multiple databases by using
    different kodo.properties files with different names. However, it doesn't
    mention using different mappings, that I can see.
    What I'm thinking I could do is extend kodo.jdbc.meta.FileMappingFactory.
    Then I could have a .mapping file for each different database. My
    extension would just need to know to access *.sqlserver.mapping or
    *.oracle.mapping for instance.
    Is this plausible? If so, any hints on extending FileMappingFactory? How
    is that guy determining the name of the mapping file? Can I simply
    override a method?
    I'm hoping this will work, so that I don't have to create a
    SQLServerPerson and an OraclePerson. Any ideas appreciated.
    Thanks,
    Steve

    Ok, in answer to my own question, I'm providing the following which I hope
    Abe or Stephen will look at, and tell me this won't break everything.
    It seems that jdbc-class-ind is only read at the base level, and thus I
    couldn't add an "indicator" for each of my subclasses. So, as I wrote
    previously, I needed a way to read my jdbc-class-ind-value in my .mapping
    file for each class. Here is the code I came up with:
    <code>
    public class MyFileMappingFactory extends FileMappingFactory {
    JDBCConfiguration myConfiguration = null;
    static Logger log = Logger.getLogger(MyFileMappingFactory.class);
    public synchronized void readMapping(ClassMetaData type,
    MappingInfoRepository repos) {
    super.readMapping(type,repos);
    try {
    String[] persistentClasses =
    myConfiguration.getPersistentClassesList();
    MappingRepository mappingRepos =
    myConfiguration.getMappingRepository ();
    for (int i=0;i<persistentClasses.length;i++) {
    String className = persistentClasses;
    try {
    Class clazz = Class.forName(className);
    ClassMapping mapping = mappingRepos.getMapping(
    clazz, clazz.getClassLoader(), true);
    mapping.addExtension(
    "jdbc-class-ind-value",
    mapping.getMappingInfo().getAttribute("jdbc-class-ind-value"));
    catch (Exception e) {
    log.error("Could not set jdbc-class-ind-value for class '" +
    className + "'.");
    catch (Exception ex) {
    public void setConfiguration(Configuration conf)
    myConfiguration = (JDBCConfiguration) conf;
    super.setConfiguration(conf);
    </code>
    I did a lot of introspection using JBuilder as well as the Javadoc to
    figure out what I needed to call. Basically, I need to have
    kodo.PersistentClasses set in my config file, and I added an attribute to
    the .mapping jdbc-class-map element. Finally, my kodo.properties has to
    point to my custom MappingFactory.
    It all seems to work, but I wanted to verify with the experts I'm not
    breaking anything. I had hoped to figure out how to put an <extension> in
    the .mapping file so that it stood out even more as being "custom code",
    but could not figure out how to read such an element.
    Steven Kouri wrote:
    I think you've answered my question, but it doesn't help my problem. I
    actually did both: I loaded the static classes in my code as well as used
    the kodo.PersistentClasses property. Neither helped this situation.
    The reason it seems is when the fromMapping() gets called. It only got
    called after calling execute() on my query. Thus, the rest of my mappings
    hadn't been loaded yet. I put a breakpoint in fromMapping(), and here was
    my stack trace:
    execute()
    executeWithArray()
    executeWithMap()
    internalCompile()
    getMetaDatas()
    getMappings()
    getMapping()
    getMappingInternal()
    getMapping()
    getMappingInternal()
    intialize()
    fromMapping()
    So, I need to figure out a way to get my code to read all the mappings
    before I do an execute(). I think. :) I'll investigate further unless
    you can give me a pointer in the right direction.
    Thanks!
    Steve
    PS: 1pm? 1PM? I'm here before 7am! But then, I usually leave at 4pm. :)
    Abe White wrote:
    Is the .mapping file preparsed, or is it only accessed when a class is
    requested from the datastore?
    We only resolve mappings when the classes are actually used. Have you
    listed all your persistent classes in the kodo.PersistentClasses
    configuration property, as suggested by the documentation for
    MetadataValueIndicator?
    PS: It's 5:37pm on a Friday. I'm going home. You should too! :)
    When you decide to start work at 1pm, you tend to stick around a little
    later.

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

  • Using collection as a stored proc. parameter

    I have a requirement of a using a stored proc ('in') parameter as a collection and using it futher in the where clause of a sql query. What are my options here ? I am currently trying with a nested table, getting errors in using with sql query.
    What are my options here ?

    sql>create or replace type NumberTable as table of number;
      2  /
    Type created.
    sql>create or replace procedure p_test
      2    (p_list in NumberTable)
      3  is
      4    v_count pls_integer;
      5  begin
      6    select count(*)
      7      into v_count
      8      from table(p_list);
      9    dbms_output.put_line( 'Count: ' || v_count );
    10  end;
    11  /
    Procedure created.
    sql>declare
      2    v_list NumberTable := NumberTable(1, 2, 3, 4, 5);
      3  begin
      4    p_test(v_list);
      5  end;
      6  /
    Count: 5
    PL/SQL procedure successfully completed.There are some cases where you need to use CAST with the TABLE function:
    table(cast(p_list as NumberTable))

  • How to use NTILE in a stored proc.?

    My module works in SQL*Plus but not in a stored proc. Have tried dynamic SQL to no avail.
    Has anyone been successful (in 8.1.7)? If so, how did you overcome the problem?

    Thanks, Rich.
    Here is my similar effort:
    create or replace procedure New_CSD_Hist(p_yr IN number,
                                            p_qtr IN number,
                                            p_market IN varchar2)
    is
         TYPE CSD_cur_type is REF CURSOR;
         CSD_cur           CSD_cur_type;
         more_data           BOOLEAN:=TRUE;
    begin
    OPEN CDS_cur FOR
    SELECT client,
              (ntile(3) over(order by sum(csd_spend) DESC)) as csd
    from      csd_hist
    where      csd = '0' and
              csd_spend > 0 and
              market = p_market and
              yr = p_yr and
              qtr = p_qtr
    group by client;
    HERE is another effort, trying to follow an example from Pipelines:
    lv_stmnt :=
    'declare '||
    'lv_yr varchar2(4) := :1; '||
    'lv_qtr varchar2(1) := :2; '||
    'lv_market varchar2(16) := :3; '||
    'begin '||
    'insert into clientspend select client,'||
    'ntile(3) over (order by sum(csd_spend) DESC) as csd '||
    'from csd_hist where csd = ''0'' and csd_spend > 0 and '||
    'market = :3 and yr = :1 and qtr = :2 '||
    'group by client; end;';
    execute immediate lv_stmnt using p_yr,p_qtr,p_market;
    commit;
    Again,
    Thanks for your comments and suggestions.,
    Dick Berry

  • How to use Java Robot to click the same button multiple times

    Hi All,
    I am trying to use Java Robot to turn a Windows utility located on the Desktop by clicking the same button on and then off with the following code:
      1.  Robot robot1 = new Robot();
      2.  robot1.mouseMove(400,180);
        // Turn on the utility
      3.  robot1.delay(100);
      4.  robot1.mousePress(InputEvent.BUTTON1_MASK);
      5.  robot1.delay(100);
      6.  robot1.mouseRelease(InputEvent.BUTTON1_MASK);
        //Wait for 2 minutes
      7.  robot1.delay(200);
        // Move the mouse to disconnect button
      8.  robot1.mouseMove(400,180);
        // Turn off the utility
      9.  robot1.mousePress(InputEvent.BUTTON1_MASK);
    10. robot.delay(100);
    11. robot.mouseRelease(InputEvent.BUTTON1_MASK);However, only the first click (line 1 - 7) worked. Everything from step 8 onwards doesn't appear to be doing anything. Even instantiating another robot2 to carry out step 8 - 11 did not work either. Also have tried running steps 9 - 11 only. ie skip 8.
    My aim is to turn this tool on and off at regular interval.
    Any assistance would be greatly appreciated.
    Thanks in advance,
    Jack

    Hi darth_code_r and Vincent,
    Both you and Vincent are right about insufficient time between the release ( 6 ) of mouse button and step ( 9 ) press the same button again to turn it off. You are also correct in saying that it was not necessary to move the mouse again ( 8 ) since it was sitting on the right button already.
    Below is the code I have ended up with which worked for me:
    1.  Robot robot1 = new Robot();
    2.  robot1.mouseMove(390,150);
    4.  robot1.mousePress(InputEvent.BUTTON1_MASK);
    6.  robot1.mouseRelease(InputEvent.BUTTON1_MASK);
         //Wait for 3 minutes
    7.  robot1.delay(30000);
    9.  robot1.mousePress(InputEvent.BUTTON1_MASK);
    11. robot1.mouseRelease(InputEvent.BUTTON1_MASK);This utility also takes a few seconds to turn itself on and vice versa. As a result, it is necessary to give it sufficient time to turn on prior to turning it off again with the second mouse press.
    Thanks to both of you very much,
    Jack

  • How to access multiple database present in single instance

    Hi Team,
    In oracle 11.2, can there be multiple databases in an instance???  In one of our environment, I could see multiple databases in an instance. Could you please help me in giving the data dictionary or query to access those databases?
    Actually, querying v$database, I could see only one database which is same as instance name. But in inventory, there are multiple database in an instance?
    I am still not exactly clear about this. Can someone help me with this?
    Thanks!
    Vidhya

    In Oracle one instance manages one (1) database. A database consists of multiple *schemas*.
    Other vendors erroneously call a schema 'database'.
    So, no, you didn't see multiple databases.
    There is also one datadictionary, consisting of a set of views.
    All views beginning with dba_  list the entire database, all schemas.
    All views beginning with all_ list the objects you have access to.
    All views beginning with user_ list your own objects.
    The view DICT show you the contents of the datadictionary.
    Oracle also has online documentation at http://docs.oracle.com
    From your question it is clear you should read the document called the 'Oracle Concepts Manual'.
    You can find all documentation for 11gR2 here Oracle Database Online Documentation 11g Release 2 (11.2)
    Too many people here don't make any effort to read it. This is probably the reason why you got no response.
    Sybrand Bakker
    Senior Oracle DBA

  • Error Invoking Java class from Stored proc

    We are getting this error while calling a stored procedure that invokes a
    static function of a java class from inside Oracle 8.1.7.
    ORA-29516: Aurora assertion failure: Java thread deadlock detected
    ORA-06512: at "APPS.SERVICECONSUMERINVOKE", line 0
    ORA-06512: at line 40
    In a Toad SQL Window, when I execute the stored procedure that invokes the
    java function, it executes successfully on the first attempt. When I try to
    execute it again on the same SQL Window, it gives the above error. The java
    class is part of a package and indirectly makes a JMS request-reply call
    via other helper classes.
    The same package works fine from other web containers and
    unlike the Oracle JVM Aurora, the JVMs don't detect a deadlock.
    Why does the Aurora throw an error?

    Did you try issusing a commit and then trying again in Toad SQL Window?
    The advice is to contact support:
    ORA-29516: Aurora assertion failure: string
    Cause: An internal error occurred in the Aurora module.
    Action: Contact Oracle Worldwide Support.

  • Oracle SID from within a stored proc

    Sorry - probably a no-brainer, but can't find it anywhere in the doc. Can anyone tell me how to query the current session identifier in pl/sql. (ie. the SID I can use to find an entry in v$$session.
    Thanks,Tim

    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:114412348062

  • How to use Java code to implement Divide-and-Conquer multiplication???

    i think use Divide-and-Conquer multiplication algorithm to multiply 31415975 by 81882818. Because i have study data structure and algorithm for needs people helps to solve this problem!!! The answer is should equals the both number (31415975 * 81882818) multiplication! There are must pass the program to calculation the multiply with use divide-and-Conquer!
    How to use the program calculation the both number multiplication with divide-and-Conquer??? That is needs display the different number multiplication on the screen!!!

    This is what I think you meant to say
    yijun1988 wrote:
    I am considering using Divide-and-Conquer multiplication algorithm to multiply 31415975 by 81882818.
    Because i have study data structure and algorithm.
    I need help to solve this problem!
    The result should equal the product (multiplication) of the two numbers (31415975 * 81882818)
    The input must be passed as parameters to the program to calculate the product using Divide-and-Conquer!
    How to implement number multiplication with divide-and-Conquer?
    The steps of the algorithm need to be displayed on the screen!Which part of this are you having problems with?

  • Generic Reports accessing Multiple Database Servers

    <p>Hi,</p><p>I have a report which is accessing a table present within SQL Server. This is done by creating a system DSN which points to SQL Server at report design time through the database expert from the Crystal Reports Developer. The same table is also present in another database server ie ORACLE. The requirement is that I should be able to execute the report against ORACLE database at runtime. I have seen a lot of examples to do this using ODBC and OLEDB ie changing datasources at runtime but all of these have to specify the database username and password at runtime. </p><p>Is there any way for me to achieve this without passing the username and password at runtime? If so it would be great if i could get all possible approaches to achieve this. </p><p>Thanks in advance</p><p>Joseph Samuel</p><p>&#160;</p>

    I am doing the samething.
    I found that if the report is created under OS Auth mode of Oracle, then it is OK in integrated security mode in runtime, you don't need to set any logon information in runtime, but sure, please follow the OS Auth requirement of Oracle.
    But if the report is created using stand security mode and wish it to be run under integrated security mode in runtime, then a logon error would occurs, but if the crystal report view control set to enable the database logon promot, then we can still enter something in username textbox and check the "use integrated security" checkbox, then the report is still OK.
    I wish to have the database logon prompt disable and override the logon information in program in runtime and let the report shown without any problem, but up to now, i still have no any idea.  I will come back after I got any solution for this.

Maybe you are looking for

  • WSJ: Apple to Bring iPhone, iPad Features to Mac

    http://online.wsj.com/article/SB10001424052970204880404577226864202052768.html?m od=WSJ_hp_LEFTTopStories CUPERTINO, Calif.—Apple Inc. Chief Executive Tim Cook wants to make its Mac more like an iPhone. In an interview at the company's headquarters h

  • I was in germany and my itunes store is now in german how do i get it back to english?

    anyone have any idea how to get my itunes store back to english?

  • Question on Delta Init Loads

    Hi All, I have a basic question on Delta Inits. I am a beginner in BW and would truly appreciate any input. At my company, we currently are doing delta loads on the cube 0RT_C35 (Material Movements). They did the Delta Inits prior to that. Now if we

  • Sharepoint 2010 Excel Calclation Error

    Hi, i am using Sharepoint 2010 in Form Environment. getting below error when we call the Excel workbook in browser randomly. We have use package called xldisplay to view single sheet in browser. Excel View in browser workgin fine. Any suggestion. Err

  • Question about Nexus 7010.

    Hello everybody, Just a quick question, how do you restore a running-config (or a Nexus .bin file) to a Nexus 7010. Is it thesame process as the IOS base scenario. Please explain and help. Thank you in advance. --chie