Schema name with a cursor

Hello,
I have a procedure that takes the user name as input. I need to get that username.tablename in a curor during execution. Can anyone tell me any possible way of doing this?
Here is the sample outline of that procedure
PROCEDURE p_merge_employee_info(p_schema_name in varchar2,po_status OUT VARCHAR2) IS
cursor c1 is select * from p_schema_name.employee;
begin
for rec in c1
loop
dbms_output.put_line('test');
end loop;
end;
/

Probably you can start with this REF CURSOR example:
scott@DBA> ed
Wrote file afiedt.buf
  1  CREATE OR REPLACE PROCEDURE p_merge_employee_info (p_schema_name IN VARCHAR2)
  2  IS
  3     generic_cv   sys_refcursor;
  4     emprec       emp%ROWTYPE;
  5  BEGIN
  6     OPEN generic_cv FOR 'select * from ' || p_schema_name || '.emp';
  7     LOOP
  8        FETCH generic_cv
  9         INTO emprec;
10        EXIT WHEN generic_cv%NOTFOUND;
11        DBMS_OUTPUT.put_line ('empid:' || emprec.empno||' name:'||emprec.ename);
12     END LOOP;
13     CLOSE generic_cv;
14* END;
scott@DBA> /
Procedure created.
scott@DBA>  exec p_merge_employee_info ('scott');
empid:7369 name:SMITH
empid:7499 name:ALLEN
empid:7521 name:WARD
empid:7566 name:JONES
empid:7654 name:MARTIN
empid:7698 name:BLAKE
empid:7782 name:CLARK
empid:7788 name:SCOTT
empid:7839 name:KING
empid:7844 name:TURNER
empid:7876 name:ADAMS
empid:7900 name:JAMES
empid:7902 name:FORD
empid:7934 name:MILLER
empid:4109 name:delfino
PL/SQL procedure successfully completed.

Similar Messages

  • Using a Variable for Table Name  with a cursor

    Hello All
    Is it possible to use a Parameter passed to a procedure as the table name
    in a cursor selection statment. I thought the below would work but I get
    a error. Does anyone have any ideas?? The Error is listed below to.
    Here's the code I just complied
    CREATE OR REPLACE PROCEDURE Dup_Add(NEWQATABLE IN VARCHAR2) IS
    CURSOR c1 IS SELECT MUNI,PROV FROM NEWQATABLE GROUP BY MUNI, PROV;
    c1rec c1%ROWTYPE;
    BEGIN
    OPEN c1;
    LOOP
    FETCH c1 INTO c1rec;
    EXIT WHEN c1%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(c1rec.MUNI);
    END LOOP;
    CLOSE c1;
    END;
    Here is the errors
    LINE/COL ERROR
    3/8 PLS-00341: declaration of cursor 'C1' is incomplete or malformed
    3/15 PL/SQL: SQL Statement ignored
    3/38 PLS-00201: identifier 'NEWQATABLE' must be declared
    5/7 PL/SQL: Item ignored
    10/3 PL/SQL: SQL Statement ignored
    10/17 PLS-00320: the declaration of the type of this expression is
    incomplete or malformed
    12/3 PL/SQL: Statement ignored
    12/24 PLS-00320: the declaration of the type of this expression is
    incomplete or malformed
    LINE/COL ERROR
    Thanks
    Peter

    If you are going to have a table name or a column name as a parameter, then you have to open the cursor dynamically. The following example uses Native Dynamic SQL (NDS) to open a ref cursor dynamically. I also eliminated the group by clause, since it is intended for use with aggregate functions and you weren't using an aggregate function. Also notice that there are some other differences in terms of defining variables and fetching and so forth.
    SQL> CREATE TABLE test_table
      2  AS
      3  SELECT deptno AS muni,
      4         dname  AS prov
      5  FROM   dept
      6  /
    Table created.
    SQL> CREATE OR REPLACE PROCEDURE Dup_Add
      2    (newqatable IN VARCHAR2)
      3  IS
      4    TYPE cursor_type IS REF CURSOR;
      5    c1 cursor_type;
      6    c1muni NUMBER;
      7    c1prov VARCHAR2 (20);
      8  BEGIN
      9    OPEN c1 FOR 'SELECT muni, prov FROM ' || newqatable;
    10    LOOP
    11      FETCH c1 INTO c1muni, c1prov;
    12      EXIT WHEN c1%NOTFOUND;
    13      DBMS_OUTPUT.PUT_LINE (c1muni || ' ' || c1prov);
    14    END LOOP;
    15    CLOSE c1;
    16  END;
    17  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> SET SERVEROUTPUT ON
    SQL> EXECUTE dup_add ('test_table')
    10 ACCOUNTING
    20 RESEARCH
    30 SALES
    40 OPERATIONS
    PL/SQL procedure successfully completed.

  • Transform the schema name with APPLY_DML_HANDELER

    Hello:
    I have referred following notes, but I was trying to transform the schema name from schema_name_A to Schema_name_B in APPLY_DML_HANDELER, which does not seem like working.
    264035.1 How To Transform Schema Name In Streams
    309575.1 How To Transform A Schema Name In Streams for DML and Simple DDL Operations
    313766.1 Streams Heterogeneous Apply To SQL*Server
    Please confirm, if what I am trying to do it doable or not? Below is handler code.
    CREATE OR REPLACE PROCEDURE APPLY_DML_HANDLER(in_any_data IN SYS.ANYDATA) IS
    v_in_lcr SYS.lcr$_ROW_RECORD;
    v_in_lcr_status PLS_INTEGER;
    BEGIN
    v_in_lcr_status := in_any_data.GETOBJECT(v_in_lcr);
    v_in_lcr.set_object_owner('CSRREP');
    v_in_lcr.EXECUTE(TRUE);
    END;
    All gets compiled good and runs, but dba_apply_errors shows Ora-23416.
    Thanks,
    Rohit

    Hi Rohit,
    ORA-23416: table "string"."string" does not contain a primary key constraint
    Cause: The master table does not constaint a primary key constraint or the primary key constraint has been disabled.
    Action: Create a primary key constraint on the master table or enable the existing constraint.
    It is doable. I've done already done that in 9i. Be conscious that that kind of handler is executed for each LCR. So, that's highly paid.
    I think there are new features to do it in a better way in 10g but I haven't tried it yet.
    I had a bug somewhat similar that I fixed doing the following:
    dbms_rule_adm.grant_object_privilege(
    privilege => SYS.DBMS_RULE_ADM.EXECUTE_ON_RULE_SET,
    object_name => v_ruleset_name,
    grantee => v_new_owner
    );

  • Case of schema names with code insight

    I'm running SQL Developer 3.0.04. I want my SQL statements to be of the form "SELECT * FROM schema.table" but I can't seem to find the right code insight option to make this happen. There seems to be a way to make everything lowercase (including keywords) but the closest I can get to what I really want is "SELECT * FROM SCHEMA.table".
    How do I stop the schema name being upper-cased when using code insight without affecting the keywords?

    I don't think you're understanding the issue. This is about code insight, not about the tables being defined in lower case. Here's a step by step example:
    SELECT * FROM mys<ctrl+space> -> SELECT * FROM myschema
    SELECT * FROM myschema.f<ctrl+space> -> SELECT * FROM MYSCHEMA.fred
    when what I want is "SELECT * FROM *myschema*.fred"

  • Specify schema name in select statements

    Is there a way to specify the schema name for the connection so that I don't have to specify schema name with every statement?
    Currently I am executing the statement:
    Statement stmt = null;
    ResultSet rs = null;
    String getAllNames =
                   "SELECT NAME FROM " + schemaName +".NAMES " + schemaName +" WHERE STATUS_CODE != 12 ";
    stmt = conn.createStatement();
    rs = stmt.executeQuery(getAllNames);
    But I have a lot of such statements, a few which uses parameters.
    Is there a way I can specify the schemaName once and for all so that I don't have to perform string concat everytime the function is invoked.

    well I tried that, since the application runs under CICS which uses the trusted connection with DB2, all CICS application will be using the same userid and there is no way to ensure that other applications would not be using the same table name in some other application. So the only option I have is to specify the schema name with the select statements but I don't want to append the schema name with each statement.

  • Function not found when package name exists with same name as schema name

    Hi all, any help would be appreciated :)
    I found an issue with pl/sql resolving a functions location when the db has a package name with the same as the db schema name.
    My example:
    -- arbitrary test function, not in any package
    create or replace FUNCTION testFunc
         inTest     IN VARCHAR2
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN 'a';
    END;
    -- There is a package called "FM" with functions that are not referenced or used in this example and the db schema is "FM".
    -- The following PL/SQL fails with the message: "ORA-00904: "FM"."TESTFUNC": invalid identifier"
    select cursor (select testFunc('a') from dual) from dual;
    -- The following PL/SQL works:
    select * from (select testFunc('a') from dual);
    As mentioned the function testFunc is NOT in the FM package. This issue does not happen when I remove the FM package. So it seems like there is an issue with cursors calling functions when there exists any package with the same name as the db schema.
    Can anyone tell me why this happens and also what I can add to force the function that is not in any package to be referenced (without Oracle trying to look in the FM package)?
    DB: Oracle 11.2.0.2
    thanks!
    Paul

    Hi Paul,
    In general I would not advice to have schema and objects with the same name.
    Here is what documentation is saying here: How Name Resolution Differs in PL/SQL and SQL
    PL/SQL uses the same name-resolution rules as SQL when the PL/SQL compiler processes a SQL statement, such as a DML statement. For example, for a name such as HR.JOBS, SQL matches objects in the HR schema first, then packages, types, tables, and views in the current schema.
    PL/SQL uses a different order to resolve names in PL/SQL statements such as assignments and subprogram calls. In the case of a name HR.JOBS, PL/SQL searches first for packages, types, tables, and views named HR in the current schema, then for objects in the HR schema.As you can see above when using PL/SQL for your case Oracle searches first for packages, types, tables, and views named FM in the current schema, then for objects in the FM schema.
    And because a package FM is found it is raising an error due to the fact that the procedure could not be found in that package.
    I hope this clarify.
    Regards.
    Al

  • Using dbms_datapump package to export the schema with the schema name as pa

    Hi,
    I am using the pl/sql block to export schema using dbms_datapump package,Now I want to pass the scheme name as the parameter to the procedure and get the .dmp and .log files with the schema name included.
    CREATE OR REPLACE PROCEDURE export
    IS
    h1 number;
    begin
    h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'export1', version => 'COMPATIBLE');
    dbms_datapump.set_parallel(handle => h1, degree => 1);
    dbms_datapump.add_file(handle => h1, filename => 'EXPDAT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
    dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0);
    dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''CHECKOUT'')');
    dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS');
    dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U' || to_char(sysdate,'dd-mm-yyyy') || '.DMP', directory => 'DATA_PUMP_DIR', filetype => 1);
    dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
    dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
    dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
    dbms_datapump.detach (handle => h1);
    exception
    when others then
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    end;
    Thank you in advanced
    Sri

    user12062360 wrote:
    Hi,
    I am using the pl/sql block to export schema using dbms_datapump package,Now I want to pass the scheme name as the parameter to the procedure and get the .dmp and .log files with the schema name included.
    OK, please proceed to do so
    >
    CREATE OR REPLACE PROCEDURE export
    IS
    h1 number;
    begin
    h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'export1', version => 'COMPATIBLE');
    dbms_datapump.set_parallel(handle => h1, degree => 1);
    dbms_datapump.add_file(handle => h1, filename => 'EXPDAT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
    dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0);
    dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''CHECKOUT'')');
    dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS');
    dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U' || to_char(sysdate,'dd-mm-yyyy') || '.DMP', directory => 'DATA_PUMP_DIR', filetype => 1);
    dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
    dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
    dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
    dbms_datapump.detach (handle => h1);
    exception
    when others then
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    end;
    EXCEPTION handler is a bug waiting to happen.
    eliminate it entirely

  • JDeveloper - ESB / BPEL - JMS Adapter - prefix queue name with db schema

    When I use the JMS Adapter in ESB to create a new message queue producer or consume using database (AQ) I'm experiencing a problem when selecting the queue.
    I can browse the queue in the database but when I have selected the queue JDeveloper prefix it with the schema name owning the queue.
    Example:
    java:comp/resource/DocumentQueueResourceProvider/Queues/QUEUES.DOCUMENT_IMPORT_QUEUE
    Schema owner is QUEUES and the name of the queue is DOCUMENT_IMPORT_QUEUE.
    The problem is when I try to use it its unable to look up the queue and I have to manually remove the prefix from .wsdl file before deploying it - as with setting mcf.IsTransacted='false'.
    When the resource provider finds the queue and exposes it in the JNDI three it does it without the prefix.
    Question: How do I either:
    a) make the schema prefix be removed by JDeveloper
    b) make the resource provider prefix the queue name with the schema name.
    Anybody?
    Best regards
    Christian Damsgaard

    Try this:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="http://www.yourcompany.com/msg"
    xmlns:tns="http://www.yourcompany.com/msg"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xsd:element name="rootnode" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eof}"/>
    </xsd:schema>
    This will result in a single node xml.
    Edited by: user472896 on Sep 22, 2010 10:29 AM

  • Need to know schema name and table name associated with a column-URGENT

    Hi folks,
    I need to know the schema name and the table name associated with a column. Though jdbc has the api to getTableName and getSchemaName, some database vendor like oracle does return empty upon call of mentioned methods. I found that oracle driver does not support that ……
    Can any one give me the solution? It is urgent. Or do you suggest any third pary jdbc driver which can provide those?
    Thanks
    Angelina

    Angelina,
    Your question has been discussed several times previously in this forum. Search this forum's archives for "getTableName". Oracle JDBC driver does not implement this (because "it is not feasible" -- according to Oracle).
    First of all, I would suggest that you could probably change your application's logic so that you would not need this functionality (but I guess that is not feasible either, right :-)
    Alternatively, you could try querying the Oracle database data dictionary.
    Good Luck,
    Avi.

  • Prefixing sequence with schema name in generated sql on oracle

    Hi,
    We use kodo 3.4 with an oracle database in a J2EE environment.
    When we put on the kodo tracing during on of our testcases we see statements being generated like :
    select LOOPBAANPERIODESEQUENCE.NEXTVAL from DUAL
    When we check the rest of the statements we see :
    SELECT * FROM PC52290.EINDELOOPBAAN (EINDELOOPBAAN being a table)
    Is there any way to make kodo generate the following statement ?
    select PC52290.LOOPBAANPERIODESEQUENCE.NEXTVAL from DUAL
    Our kodo.properties we use :
    javax.jdo.PersistenceManagerFactoryClass=kodo.jdbc.runtime.JDBCPersistenceManagerFactory
    javax.jdo.option.Optimistic=true
    javax.jdo.option.RetainValues=true
    javax.jdo.option.NontransactionalRead=true
    kodo.jdbc.DBDictionary=kodo.jdbc.sql.OracleDictionary
    kodo.jdbc.ForeignKeyConstraints=true
    kodo.LicenseKey=<VALID_LICENSE_HERE>
    kodo.Log=DefaultLevel=WARN,SQL=TRACE,Runtime=WARN,Configuration=WARN
    kodo.jdbc.Schemas=PC52290
    kodo.PersistentClasses= ...
    An example of our mapping :
              <class name="LoopbaanPeriode">
                   <extension vendor-name="kodo" key="jdbc-sequence-factory" value="native"/>
                   <extension vendor-name="kodo" key="jdbc-sequence-name" value="LOOPBAANPERIODESEQUENCE"/>
    <extension vendor-name="kodo" key="jdbc-class-ind-value" value="1"/>
    <field name="beginDatum"           persistence-modifier="persistent" />
    <field name="statuut" persistence-modifier="persistent" />
    <field name="loopbaan"                     persistence-modifier="persistent"/>
    </class>
    regards,
    David De Schepper.

    Hi David,
    When faced with a similar problem, I wrote my own subclass of DBDictionary
    (in my case actually a subclass of OracleDictionary), and plugged it into
    kodo using the kodo.jdbc.DBDictionary property. My class overrode the
    following methods:
    public String getFullName(Table, boolean);
    public String getFullName(Index);
    Then at runtime, these methods stuffed in the correct Schema name for
    certain tables and indexes, based on values yoinked from some user
    properties.
    Not sure if this will help or not in your case.
    Cheers!
    .droo.
    On 4/9/06 2:48 PM, in article [email protected], "David De
    Schepper" <David De Schepper> wrote:
    yes that works but that is not an option for us.
    We have an oracle schema for each developer on our team and don't want to
    hardcode it in our mapping file (for obvious reasons)
    FYI : kodo 4.0.1 does it correctly (generates PC52290.LOOPBAANPERIODESEQUENCE)
    but since i have problems doing the upgrade to kodo 4.0 (with as few code
    changes as possible) i'm going to have to advice my company not to do the
    upgrade.
    (In case you are intersted or have some time :
    http://forums.bea.com/bea/thread.jspa?forumID=500000029&threadID=600017073&mes
    sageID=600041994#600041994)

  • Prefixing a sequence name with a schema in 9041

    G'day,
    I'm attempting to upgrade to Toplink 9041, and one thing i've noticed is that the Workbench does not allow any special characters in the name of a sequence. This does not allow us to prefix sequence names with a schema, the same way our tables are prefixed.
    What gives?
    Cheers,
    Troy.

    You can do this from a stored procedure that you invoke from your pre-mapping trigger:
    - Scan the source and get the max_id
    - execute immediate 'drop sequence; create sequence ... start with '||max_id+1
    Etc.
    Good luck, Erik Ykema

  • DatabaseProcedure with return type prefixed with schema name

    Hi (Paco)
    I have a question about the DatabaseProcedure class. We are using Oracle proxy users for our database connections.
    Everything is accessed via a database role that are granted to the logged on user. All our database objects, tables etc are protected with this database role.
    When I want to call a database function/procedure I need to add the schema name as a prefix to the custom database object that we uses for parameters/return types.
    So far so good. I can also define a parameter prefixed with schema name via the DatabaseProcedure.registerArrayType ...
    But when I try to define a function call that uses this parameter I get an error saying "Declaration is not valid".
    The problem is located to the PROCEDURE_DEFINITION regular pattern:
    private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL); The return type cannot be prefixed with the schema name.
    Any good suggestions or workarounds?!
    I actually did change the pattern runtime via reflection to make it work - but I really don't like this solution in the long run!
    /Torben
    Edited by: Zonic on 2013-05-07 10:52

    Hi Torben,
    I think I have a workaround for the issue that might work for you. If you look at the source of <font face="courier">DatabaseProcedure.registerArrayType</font> you find that it actually calls <font face="courier">DatabaseProcedure.registerCustomParamType</font>.
    public static void registerArrayType(String name)
      registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name);
    }As a workaround you could replace your calls to <font face="courier">DatabaseProcedure.registerArrayType</font> with calls to <font face="courier">DatabaseProcedure.registerCustomParamType</font> as follows.
    // Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call:
    DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here.
    DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)");
    DatabaseProcedure.ParamType type = dp.getParamDef(0).getType();
    System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTSThis way you don't have to use the "illegal" name in the DatabaseProcedure definition.
    Regards,
    Paco van der Linden

  • How to make sure that schema name is not included with generated sqls

    How to make sure that schema name is not included with generated sqls with tableadapter wizard.
    What should I use? Oledb, ODT.NET, where can set that I want "pure" sqls, not schemas, not ", or anything like this
    I want
    "Select a,b from t1" ,not "select "a","b" from schema.t1"
    Also schema name is put in all parameters, all over the place... What if schema name changes. (b1test to b1prod)
    . I now manually edit XML files of dataset. It works but....
    thanks

    The full hardware :
    Processor Intel core due 3.00 MHz
    RAM:1.5GB
    psu:650 Watt (but i baught i cheap one so it may be actually about 400 watt)
    HD Disk:160 GB
    But about the power supply if it not able to run the VGA card ,Is it will not show any screen or it will not able to run the computer??

  • Need Database Schema diagram with reports names

    Dear Experts,
    I need retail and petroleum industry database schema diagram with different report requirements.
    If u have  Plz do share. I want to develop some reports as per requirements.
    If u have any sample dummy schema Plz do share, I will be much thankful to u. This is for fresher interview, I need to attain this week end.
    Regards,
    Mahesh.

    i dont think its possible with original exp/imp....and also not possible with data pump (10g and up)....but not sure on data pump....data pump has capability of restarting a job..but didnt heard about appending (atleast not that i heard).
    only way i can think of...create triggers on every table when DML happens and insert the new data into new tables...and then exp those new tables and import the new tables...thats the only way i can think of...again just my 2 cent....

  • Get Database Schema Name

    Hi,
    I am trying to retrieve the schema name from my application so I can perform some ALTER DATABASE `foo`... statements in MySql which ensure database intergrity for my application. Ideally i would want to accomplish this without having to run a regular expression on my connect url:
    url="jdbc:mysql://localhost:3306/bad2?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true"
    which already has the default schema/database I am using. I was wondering if there is some JDBC standard method that all drivers comply to as I would rather avoid having to write some conditional, vendor specific code. Ideally this will be present in DatabaseMetadata.Thanks,
    Nedko
    http://www.nedkoko.com
    Edited by: nedKoKo.com on Oct 11, 2007 10:55 AM
    Edited by: nedKoKo.com on Oct 11, 2007 11:25 AM

    Owen unfortunately Connection.getCatalog() works well with all databases but Oracle which gets me back to square 1 of the problem. My application is designed to use different database vendors among which are MySql, MsSQL and Oracle. A standard connection URL should work fine and connect to the specified schema of your choice. The problem however is that the Connect URL string in Oracle is different and does not specify the default schema:
    Mysql: url="jdbc:mysql://localhost:3306/database_name?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true"
    MsSQL: url="jdbc:jtds:sqlserver://sqlserver:1433/database_name;SelectMethod=cursor"
    Oracle: url="jdbc:oracle:thin:@bart:1521:orcl"
    The oracle URL is constructed according the specs (http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#05_03) and does not specify schema by default but just SID name. As I am using Hibernate persistence in my J2EE app I am forced to specify "schemaName" when I initialize my environment which works fine but is Oracle specific. On the other hand Connection.getCatalog() works great with other vendors but returns NULL for Oracle. Ideally i want to be able to resolve everything in a unified way and not have to write vendor specific code. Any suggestions are appreciated.
    Nedko

Maybe you are looking for