Problems with query with more than 20 values in the select clause

I have a region based on a function returning a SQL query. It needs to have more than 20 values in the select clause. When I run the page I get a no data found error in the region. I managed to reproduce this behavior with just the following as the select returned by the function:
select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
from dual
I am running the 1.3.9.00.15 release of Marvel on 9.2.0.2 of the db on Solaris.

Hello Raju,
I will email you the connection settings when I return to the office.
One thing I should have mentioned: The sql string is returned from a package in the db, so the query region text I originally posted isn't quite correct.
it is something like:
declare
begin
return my_pkg.my_fnc;
end;
the stored package is nothing more than:
package my_pks is
funtion my_fnc(i_test_param in varchar2) is
begin
return 'select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 21 from dual';
end;
end;
Sorry for the inaccurate info in the first post, but I am away from the server in question right now.

Similar Messages

  • Essbase Variable with more than a value for use after in Planning forms.

    I want to now if it would be possible to create a variable with more than a value for use after in Planning forms.
    The variable that I want to use is created in Essbase.
    Example:
    &Years = FY08,FY09,FY10

    Hi.
    The only workaround I know for the problem is to create parent in the dimension.
    In your case, create member “planyears”.
    Then you define children that are shard (this are the multiple member for the variables FY08, FY09 etc..)
    Create Essbase sub variable that will have 1 member value “planyears”
    When you use the Sub Variable in form select function “Children” and in that case it will use the member FY08,FY09 etc on the form.
    Limitation: I’m working on version 9.2.0.3 so you can’t create hierarchy in the year dimension, but you can use it in other dimension.
    AE

  • Fill BEx Variable with more than one value via Custom Exit

    Dear SDN comunity,
    I want to fill a BEx Variable via a custom exit. My problem is, I don't know how to fill this variable with more than one value.
    I try to give you some background info based on an exaple:
    <u><b>Variable-Details</b></u>
    <b>Type of Variable:</b> Characteristic Value
    <b>Variable Name:</b> ZCCD
    <b>Description:</b> Company Code Selection
    <b>Processing by:</b> Custom Exit
    <b>Characteristic:</b> Company Code
    <b>Variable Represents:</b> Multiple Single Values
    <u><b>This is the used ABAP code:</b></u>
    WHEN 'ZCCD'.
    CLEAR l_s_range.
    l_s_range-low = '2002;2004'.
    l_s_range-sign = 'I'.
    l_s_range-sign = 'EQ'.
    APPEND l_s_range TO e_t_range.
    <u><b>The system returns this message:</b></u>
    Value "2002;2004" is too long for variable ZCCD
    appreciate your help!
    //michael

    Eugene, Marcus
    it works now, thx a lot!
    Please find attached the final code:
    CLEAR l_s_range.
    l_s_range-low = '2002'.
    l_s_range-sign = 'I'.
    l_s_range-<b>opt</b> = 'EQ'.
    APPEND l_s_range TO e_t_range.
    CLEAR l_s_range.
    l_s_range-low = '2004'.
    l_s_range-sign = 'I'.
    l_s_range-<b>opt</b> = 'EQ'.
    APPEND l_s_range TO e_t_range.
    (Delta to Marcus's code is bold)

  • Call Transaction and fill a select-options field with more than one value?

    Hello everybody,
    how can I fill a select-options field with more than one value.
    Here is the code example:
      CLEAR: GT_BDCDATA, GS_BDCDATA.
      GS_BDCDATA-program = 'RHALEINI'.
      GS_BDCDATA-DYNPRO = '1000'.
      GS_BDCDATA-DYNBEGIN = 'X'.
      APPEND GS_BDCDATA TO GT_BDCDATA.
      CLEAR: GS_BDCDATA.
      GS_BDCDATA-FNAM = 'PCHOTYPE'.
      GS_BDCDATA-FVAL = 'P'.
      APPEND GS_BDCDATA TO GT_BDCDATA.
      CLEAR: GS_BDCDATA.
      LOOP AT gt_hrobjinfty INTO gs_hrobjinfty.
        GS_BDCDATA-FNAM = 'PCHOBJID-LOW'.
        GS_BDCDATA-FVAL = gs_hrobjinfty-objid.
        APPEND GS_BDCDATA TO GT_BDCDATA.
        CLEAR: GS_BDCDATA.
      ENDLOOP.
      CALL TRANSACTION 'PFAL' USING GT_BDCDATA MODE 'A'
                       MESSAGES INTO GT_MESSAGES.
    THX.

    Hi,
    Please refer the code below:
    *Code used to populate 'select-options' & execute report
    DATA: seltab type table of rsparams,
          seltab_wa like line of seltab.
      seltab_wa-selname = 'PNPPERNR'.
      seltab_wa-sign    = 'I'.
      seltab_wa-option  = 'EQ'.
    * load each personnel number accessed from the structure into
    * parameters to be used in the report
      loop at pnppernr.
        seltab_wa-low = pnppernr-low.
        append seltab_wa to seltab.
      endloop.
      SUBMIT zreport with selection-table seltab
                                    via selection-screen.
    Thanks,
    Sriram Ponna.

  • URGENT: passing more than one value at the same parameter

    Hello friends at www.oracle.com,
    if I have a Forms program that sends some parameters to a Report, how can I send more than one value at the same parameter that is being sent?
    For example: the Reports parameter P_CODE should receive (from Forms) and print the values 1, 2, 3 and 4, each one in a different page. But, only 4 is being printed, and these values aren't saved at a database, so I have to pass the other three values too. How can I solve this problem?
    This is quite urgent and I need help on this.
    Best regards,
    Franklin Gongalves Jr.
    [email protected]

    Thanks to Oracle Reports Team for answering! I'm sure this will work.
    Best regards,
    Franklin Gongalves Jr.
    [email protected]
    hello,
    on the forms side, you will have to build the list for this parameter by e.g. string concat.
    on the reports side you will have to "decode" this parameter according to how you built it in forms.
    e.g. if you pass the list like this "10~20~30" you might use a where-clause in the query
    ... where instr(myCol, :myParam) >0
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

  • Performance problem with more than one COUNT(DISTINCT ...) in a query

    Hi,
    (I hope this is the good forum).
    In the following query, I have 2 Count Distinct on 2 different fields of the same table.  Execution time is okay (2 s) with one or the other COUNT(DISCTINCT ...) in the SELECT clause, but is not tolerable (12 s) with both together in the query! I have
    a similar case with 3 counts: 4 s each, 36 s when together!
    I've looked at the execution plan, and it seems that with two count distinct, SQL server sorts the table twice before joining the results.
    I do not have much experience with SQL server optimization, and I don't know what to improve and how. The SQL is generated by Business Objects, I have few possibilities to tune it. The most direct way would be to execute 2 different queries, but I'd like
    to avoid it.
    Any advice?
    SELECT
      DIM_MOIS.DATE_DEBUT_MOIS,
      DIM_MOIS.NUM_ANNEE_MOIS,
      DIM_DEMANDE_SCD.CAT_DEMANDE,
      DIM_APPLICATION.LIB_APPLICATION,
      DIM_DEMANDE_SCD.CAT_DEMANDE ,
      count(distinct FAITS_DEMANDE.NB_DEMANDE_FLUX),
      count(distinct FAITS_DEMANDE.NB_DEMANDE_RESOL_NIV1)
    FROM
      ALIM_SID.DIM_MOIS INNER JOIN ALIM_SID.DIM_JOUR ON (DIM_JOUR.SEQ_MOIS=DIM_MOIS.SEQ_MOIS)
       INNER JOIN ALIM_SID.FAITS_DEMANDE ON (FAITS_DEMANDE.SEQ_JOUR=DIM_JOUR.SEQ_JOUR)
       INNER JOIN ALIM_SID.DIM_APPLICATION ON (FAITS_DEMANDE.SEQ_APPLICATION=DIM_APPLICATION.SEQ_APPLICATION)
       INNER JOIN ALIM_SID.DIM_DEMANDE_SCD ON (FAITS_DEMANDE.SEQ_DEMANDE_SCD=DIM_DEMANDE_SCD.SEQ_DEMANDE_SCD)
    WHERE
      ( ( DIM_MOIS.NUM_ANNEE_MOIS ) >201301
    GROUP BY
      DIM_MOIS.DATE_DEBUT_MOIS,
      DIM_MOIS.NUM_ANNEE_MOIS,
      DIM_DEMANDE_SCD.CAT_DEMANDE,
      DIM_APPLICATION.LIB_APPLICATION

    Here is the script, nothing original. Hope this helps.
    -- Fact table :
    -- foreign keys begin by FK_,
    -- measures to counted (COUNT DISTINCT) begin with NB_
    CREATE TABLE [ALIM_SID].[FAITS_DEMANDE](
        [SEQ_JOUR] [int] NOT NULL,
        [SEQ_DEMANDE] [int] NOT NULL,
        [SEQ_DEMANDE_SCD] [int] NOT NULL,
        [SEQ_APPLICATION] [int] NOT NULL,
        [SEQ_INTERVENANT] [int] NOT NULL,
        [SEQ_SERVICE_RESPONSABLE] [int] NOT NULL,
        [NB_DEMANDE_FLUX] [int] NULL,
        [NB_DEMANDE_STOCK] [int] NULL,
        [NB_DEMANDE_RESOLUE] [int] NULL,
        [NB_DEMANDE_LIVREE] [int] NULL,
        [NB_DEMANDE_MEP] [int] NULL,
        [NB_DEMANDE_RESOL_NIV1] [int] NULL,
     CONSTRAINT [PK_FAITS_DEMANDE] PRIMARY KEY CLUSTERED
        [SEQ_JOUR] ASC,
        [SEQ_DEMANDE] ASC,
        [SEQ_DEMANDE_SCD] ASC,
        [SEQ_APPLICATION] ASC,
        [SEQ_INTERVENANT] ASC,
        [SEQ_SERVICE_RESPONSABLE] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
     CONSTRAINT [AK_AK_FAITS_DEMANDE_FAITS_DE] UNIQUE NONCLUSTERED
        [SEQ_JOUR] ASC,
        [SEQ_DEMANDE] ASC,
        [SEQ_DEMANDE_SCD] ASC,
        [SEQ_APPLICATION] ASC,
        [SEQ_INTERVENANT] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_APPLICATION] FOREIGN KEY([SEQ_APPLICATION])
    REFERENCES [ALIM_SID].[DIM_APPLICATION] ([SEQ_APPLICATION])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_APPLICATION]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE] FOREIGN KEY([SEQ_DEMANDE])
    REFERENCES [ALIM_SID].[DIM_DEMANDE] ([SEQ_DEMANDE])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE_SCD] FOREIGN KEY([SEQ_DEMANDE_SCD])
    REFERENCES [ALIM_SID].[DIM_DEMANDE_SCD] ([SEQ_DEMANDE_SCD])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE_SCD]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_INTERVENANT] FOREIGN KEY([SEQ_INTERVENANT])
    REFERENCES [ALIM_SID].[DIM_INTERVENANT] ([SEQ_INTERVENANT])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_INTERVENANT]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_JOUR] FOREIGN KEY([SEQ_JOUR])
    REFERENCES [ALIM_SID].[DIM_JOUR] ([SEQ_JOUR])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_JOUR]
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE]  WITH CHECK ADD  CONSTRAINT [FK_FAITS_DEMANDE_DIM_SERVICE_RESPONSABLE] FOREIGN KEY([SEQ_SERVICE_RESPONSABLE])
    REFERENCES [ALIM_SID].[DIM_SERVICE] ([SEQ_SERVICE])
    GO
    ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_SERVICE_RESPONSABLE]
    GO
    -- not shown : extended properties
    -- One of the dimension  tables (they all have a primary key named SEQ_)
    CREATE TABLE [ALIM_SID].[DIM_JOUR](
        [SEQ_JOUR] [int] IDENTITY(1,1) NOT NULL,
        [SEQ_ANNEE] [int] NOT NULL,
        [SEQ_MOIS] [int] NOT NULL,
        [DATE_JOUR] [date] NULL,
        [CODE_ANNEE] [varchar](25) NULL,
        [CODE_MOIS] [varchar](25) NULL,
        [CODE_SEMAINE_ISO] [varchar](25) NULL,
        [CODE_JOUR_ANNEE] [varchar](25) NULL,
        [CODE_ANNEE_JOUR] [varchar](25) NULL,
        [LIB_JOUR] [varchar](25) NULL,
        [LIB_JOUR_COURT] [varchar](25) NULL,
        [JOUR_OUVRE] [tinyint] NULL,
        [JOUR_CHOME] [tinyint] NULL,
     CONSTRAINT [PK_DIM_JOUR] PRIMARY KEY CLUSTERED
        [SEQ_JOUR] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    ALTER TABLE [ALIM_SID].[DIM_JOUR]  WITH CHECK ADD  CONSTRAINT [FK_DIM_JOUR_DIM_ANNEE] FOREIGN KEY([SEQ_ANNEE])
    REFERENCES [ALIM_SID].[DIM_ANNEE] ([SEQ_ANNEE])
    GO
    ALTER TABLE [ALIM_SID].[DIM_JOUR] CHECK CONSTRAINT [FK_DIM_JOUR_DIM_ANNEE]
    GO
    ALTER TABLE [ALIM_SID].[DIM_JOUR]  WITH CHECK ADD  CONSTRAINT [FK_DIM_JOUR_DIM_MOIS] FOREIGN KEY([SEQ_MOIS])
    REFERENCES [ALIM_SID].[DIM_MOIS] ([SEQ_MOIS])
    GO
    ALTER TABLE [ALIM_SID].[DIM_JOUR] CHECK CONSTRAINT [FK_DIM_JOUR_DIM_MOIS]
    GO

  • IN operator with more than 1000 values

    Hi,
    For a given list of IDs (PKs), I need to fetch the corresponding rows.
    The problem is that I have more than 1000 values and as far as I know that IN operator is limited to 1000
    values.
    I thought about using UNION such that each Select contains up to 1000 IDs.
    example":
    select * from temp where id in(1....1000)
    union all
    select * from temp where id in(1001....2000)
    Is there a better way to do that?
    Thanks
    dyahav

    As others have presented technical solutions, i'll present you a logical one (seemingly logical anyways, but it will depend on your application).
    I have seen some applications where you get
    select * from some_table where ... <conditions>;That result set is returned to the front end and presented to the users who then pick a series of records and submit another request to the database which ends up being...
    --note, this could be a many table join, with lots more information that just the some_table, this is illustrative only
    select * from some_table where pk_value in (super_super_duper_list_based_on_last_result_set);If this mimics what you have in your application, i'd recommend just fixing it so the users can select a reasonable set of data, OR the entire set (in the last case you'd just send the <conditions> instead of a massive list of PK values).
    Again, highly speculative but i thought i'd mention it in the off chance it's useful to you.

  • Problem with more than one item in a track

    DVDSP 4.0.2 / OSX.4.2 I've built a DVD with several tracks. In each track I've placed several .m2v files, one after another. Finished build plays fine on my Mac and on one of my stand alone DVD players. But on another stand alone (Sony DVP-S360) something very odd happens. DVD begins to play just fine, but whenever it encounters a track with more than one source file, it will play until it gets to the spot in the program where the second source file is in the track and then it hangs and won't do anything. I'm just curious if anyone has any insight into this problem. Is it a DVDSP conflict thing with certain players? Or is this Sony player just not capable of playing a DVD built this way? Thanks.

    This page here:
    http://www.videohelp.com/dvdplayers.php?DVDnameid=428&Search=Search&
    has someone talking about finally getting burned DVDs to work, which suggests they previously had problems. I can't think why the track would not seem like continuous video, as if it had always been that way. Our Sony DVD player at work seems sensitive to higher data rates. What data rate did you use?

  • How can we create a table with more than 64 fields in the default DB?

    Dear sirs,
    I am taking part in the process of migrating a J2ee application from JBoss to SAP Server. I have imported the ejb project.
    I have an entity bean with 79 CMP fields. i have created the bean and created the table for the same also. but when i tried to build the dictionary, i am getting an error message as given below,
    "Dictionary Generation: DB2:checkNumberOfColumns (primary key of table IMP_MANDANT): number of columns (79) greater than allowed maximum (64) IMP_MANDANT.dtdbtable MyAtlasDictionary/src/packages"
    Is it mean that we can not create tables with fields more than 64?
    How can i create tables with more than 64 fields?
    Kindly help,
    Thankyou,
    Sudheesh...

    Hi,
      I found a link in the help site which says its 1024 (without key 1023).
    http://help.sap.com/saphelp_nw04s/helpdata/en/f6/069940ccd42a54e10000000a1550b0/content.htm
      Not sure about any limit of 64 columns.
    Regards,
    S.Divakar

  • How to send more than one value to the Jump target report variable screen.

    Hi,
       I have two reports with Plant variable on their input variable screens. Say this Plant can take two values X and Y. The first report is executed with Plant value X and displays data. When a jump is made  to report two, Plant value X is retrievd into report two's plant varible value. Now how to send value Y also to Report two when jump is made. I think we can do it with a customer exit? Any help is appreciated
    Thanks
    Bhanu

    Hi Bhanu,
    I guess u have created a Variable with Sinlge value ,So Create a Variable which has Multiple Sinlge Values or Interval so that u can have more than one value and if u hvae more than value u will get data for those values and when u do a jump then u can see the data in the JUMP query for both the Values of Input.
    Rgds
    SVU123

  • Gantt Chart: Problems with more than 39 elements

    Hi all,
    I have a problem with Gantt Project Chart.
    Please have a look at http://tryapexnow.com/apex/f?p=2141:2 (credentials: demo/demo)
    If you limit to 39 rows this works fine, but with 40 rows or more the timeline is not in line with the datagrid.
    Strange thing is that as soon as you collapse all tasks the timeline is correct.
    Uncollapsing brings back wrong display.
    Has anybody seen this behaviour before and can help me out on that?
    Thanks for help,
    Moritz
    Edited by: commi235 on 31.05.2011 13:23

    Hello Moritz,
    the "Maximum Rows"-option is as default set to 40.
    if you created the chart by "Create Region => Chart => Flash Chart => ..." you can change this value in tab "Chart Series", below the "Build Query"-button.
    But I don't know how to change the maximum number of rows, when the chart is created via
    "var chart = new AnyChart(''#IMAGE_PREFIX#flashchart/anygantt_4/swf/AnyGantt.swf''); " in a HTML-region.
    I'm very interested in finding a solution.
    Kirsten

  • How to pass a parameter with more than one value to a report? (urgent)

    Hi, all
    I try to pass a parameter from a search form to a report in
    which I would like to print out my search result. My problem is
    I can pass the parameter to report but only one value which my
    cursor points to. could anyone tell me how to pass a list of
    value to the report? my trigger in form like this:
    declare
    PL_ID PARAMLIST;
    sc_no books.c_no%type;
    begin
    PL_ID := GET_PARAMETER_LIST('parametername');
    IF NOT ID_NULL(PL_ID) THEN
    DESTROY_PARAMETER_LIST(PL_ID);
    END IF;
    PL_ID := CREATE_PARAMETER_LIST('parametername');
    IF ID_NULL(PL_ID) THEN
    MESSAGE('PL/SQL held against Button failed to execute');
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    ADD_PARAMETER(PL_ID, 'PARAMFORM', TEXT_PARAMETER,'NO');
    sc_no := :searchlist.c_no; --(c_no is the value I want to pass
    but not only one.)
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    RUN_PRODUCT(REPORTS, 'reportpathname.rep', SYNCHRONOUS, RUNTIME,
    FILESYSTEM, PL_ID, NULL);
    end;
    Thank you in advance
    Diana

    Is it your values in parameter NO separated by coma? And is it
    parameter in where clause?
    Do you want something like :
    from table
    where s_no in (NO) ?
    If is answer "yes" you can create lexical parameter in report.
    You can write in report sowething like:
    select a.field1, a.field2,.....
    from table a
    &COND /* this is if is condition only one line after "from".
    if you have more lien after where then you will put this &COND
    in line where you want to have your multivalue.
    Then in your trigger in form you should write:
    sc_no := 'where a.sc_no in ('||:searchlist.c_no||')';
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    /* again this is if you have only one line with WHERE ili
    conditions */
    or you will write:
    sc_no := 'and a.sc_no in ('||:searchlist.c_no||')';
    ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
    It will substitute line in which is your conditions with
    multivalue.

  • Search Help with more than one value back

    Dear Experts,
    We added two customer fields to the SC.
    For the first customer field we created Search Help.
    When picking any option from the search help we need TWO values back u2013 one value to the first customer (the field with the search help) and the second value to the second customer field (the field without the search help).
    Can you please advice how can we have TWO values back from the search help?
    Thanks in advance,
    Keren

    Hello Keren,
    See if the below thread answers your question..
    How to create a search help
    Thanks
    Arshad

  • Can't access ejb with more than 1 person at the same time?

    I am using the ejb to access the database using DBConnection Pool that I find in book. The code is as follow:
    The problem is when more than one user access almost at the same time, the one who enter frst can access, but the other one can't and return context lookup error in creating EJB.
    What's the problem of it, is it the ejb concurrent access problem or database concurrent access problem?
    package login.database;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.Date;
    public class DBConnectionManager {
    static private DBConnectionManager instance;
    static private int clients;
    private Vector drivers = new Vector();
    private PrintWriter log;
    private Hashtable pools = new Hashtable();
    static synchronized public DBConnectionManager getInstance() {
    if (instance == null) {
    instance = new DBConnectionManager();
    clients++;
    return instance;
    private DBConnectionManager() {
    init();
    public void freeConnection(String name, Connection con) {
    DBConnectionPool pool = (DBConnectionPool) pools.get(name);
    if (pool != null){
    pool.freeConnection(con);
    public Connection getConnection(String name) {
    DBConnectionPool pool = (DBConnectionPool) pools.get(name);
    if (pool != null) {
    return pool.getConnection();
    return null;
    public Connection getConnection(String name, long time) {
    DBConnectionPool pool = (DBConnectionPool) pools.get(name);
    if (pool != null) {
    return pool.getConnection(time);
    return null;
    public synchronized void release() {
    if (--clients != 0) {
    return;
    Enumeration allPools = pools.elements();
    while (allPools.hasMoreElements()) {
    DBConnectionPool pool = (DBConnectionPool) allPools.nextElement();
    pool.release();
    Enumeration allDrivers = drivers.elements();
    while (allDrivers.hasMoreElements()) {
    Driver driver = (Driver) allDrivers.nextElement();
    try {
    DriverManager.deregisterDriver(driver);
    log("Deregistered JDBC driver " + driver.getClass().getName());
    } catch (SQLException e) {
    log(e, "Can't deregister JDBC driver: " + driver.getClass().getName());
    private void createPools(Properties props) {
    Enumeration propNames = props.propertyNames();
    while (propNames.hasMoreElements()) {
    String name = (String) propNames.nextElement();
    if (name.endsWith(".url")) {
    String poolName = name.substring(0, name.lastIndexOf("."));
    String url = props.getProperty(poolName + ".url");
    if (url == null) {
    log("No URL specified for " + poolName);
    continue;
    String user = props.getProperty(poolName + ".user");
    String password = props.getProperty(poolName + ".password");
    String maxconn = props.getProperty(poolName + ".maxconn", "0");
    int max;
    try {
    max = Integer.valueOf(maxconn).intValue();
    } catch (NumberFormatException e) {
    log("Invalid maxconn value " + maxconn + "for " + poolName);
    max = 0;
    DBConnectionPool pool = new DBConnectionPool(poolName, url, user, password, max);
    pools.put(poolName, pool);
    log("Initialized pool " + poolName);
    private void init(){
    InputStream is = getClass().getResourceAsStream("db.properties");
    Properties dbProps = new Properties();
    try {
    dbProps.load(is);
    } catch (Exception e) {
    System.err.println("Can't read the properties file. " +
    "Make sure db.properties is in the CLASSPATH");
    return;
    String logFile = dbProps.getProperty("logfile","DBConnectionManager.log");
    try {
    log = new PrintWriter(new FileWriter(logFile, true), true);
    } catch (IOException e) {
    System.err.println("Can't open the log file: " + logFile);
    log = new PrintWriter(System.err);
    loadDrivers(dbProps);
    createPools(dbProps);
    private void loadDrivers(Properties props) {
    String driverClasses = props.getProperty("drivers");
    StringTokenizer st = new StringTokenizer(driverClasses);
    while (st.hasMoreElements()) {
    String driverClassName = st.nextToken().trim();
    try {
    Driver driver = (Driver) Class.forName(driverClassName).newInstance();
    DriverManager.registerDriver(driver);
    drivers.addElement(driver);
    log("Registered JDBC driver " + driverClassName);
    } catch (Exception e) {
    log("Can't register JDBC driver: " + driverClassName + ", Exception: " + e);
    private void log(String msg) {
    log.println(new Date() + ": " + msg);
    private void log(Throwable e, String msg) {
    log.println(new Date() + ": " + msg);
    e.printStackTrace(log);
    class DBConnectionPool {
    private int checkedOut;
    private Vector freeConnections = new Vector();
    private int maxConn;
    private String name;
    private String password;
    private String URL;
    private String user;
    public DBConnectionPool(String name, String URL, String user, String password, int maxConn) {
    this.name = name;
    this.URL = URL;
    this.user = user;
    this.password = password;
    this.maxConn = maxConn;
    public synchronized void freeConnection(Connection con) {
    freeConnections.addElement(con);
    checkedOut--;
    notifyAll();
    public synchronized Connection getConnection() {
    Connection con = null;
    if (freeConnections.size() > 0) {
    con = (Connection) freeConnections.firstElement();
    freeConnections.removeElementAt(0);
    try {
    if (con.isClosed()) {
    log("Removed bad connection from " + name);
    con = getConnection();
    } catch (SQLException e) {
    log("Removed bad connection from " + name);
    con = getConnection();
    else if (maxConn == 0 || checkedOut < maxConn) {
    con = newConnection();
    if (con != null) {
    checkedOut++;
    return con;
    public synchronized Connection getConnection(long timeout) {
    long startTime = new Date().getTime();
    Connection con;
    while ((con = getConnection()) == null) {
    try {
    wait(timeout);
    } catch (InterruptedException e) {}
    if ((new Date().getTime() - startTime) >= timeout) {
    return null;
    return con;
    public synchronized void release() {
    Enumeration allConnections = freeConnections.elements();
    while (allConnections.hasMoreElements()) {
    Connection con = (Connection) allConnections.nextElement();
    try {
    con.close();
    log("Closed connection for pool " + name);
    } catch (SQLException e) {
    log(e, "Can't close connection for pool " + name);
    freeConnections.removeAllElements();
    private Connection newConnection() {
    Connection con = null;
    try {
    if (user == null) {
    con = DriverManager.getConnection(URL);
    else {
    con = DriverManager.getConnection(URL, user, password);
    log("Created a new connection in pool " + name);
    } catch (SQLException e) {
    log(e, "Can't create a new connection for " + URL);
    return null;
    return con;

    Hi,
    static synchronized public DBConnectionManager getInstance() {
    The word "synchronized" will allow only one user at a time to access the getInstance() method which returns DBConnectionManager. Suggest u read some stuff on the same
    As I am not sure which App server ur using, u cld do the following
    1. Create a Conection Pool in ur App Server itself (Weblogic/Websphere/Jboss way)
    2. Create a DataSource which maps to this Connection Pool.
    3. Use the DataSource object which handles poolong of Connections to access the database
    4. As mentioned above, Read notes/documents on "Synchronized" and "Vector" before you use this word in any code of EJB. This will solve ur problem. Read topic called "Collection Framework".
    Seetesh

  • SQL select query having more than 1000 values in 'IN' clause of predicate.

    Hi,
    We are executing a select query from a table and showing it through a front end screen. When the count of values given in the 'IN' clause of predicate are exceeding 1000 , it is throwing error.
    eg. select * from Employees where emp.Id. in('111',123','121','3232',........1001 Ids)
    We are using Oracle version 10.2.0.
    Please suggest how to tackle such issue.
    Regards,
    Naveen Kumar.C.
    Edited by: Naveen Kumar C on Aug 30, 2008 10:01 PM

    Use a nested table:
    create or replace type numbertype
    as object
    (nr number(20,10) )
    create or replace type number_table
    as table of numbertype
    create or replace procedure tableselect
    ( p_numbers in number_table
    , p_ref_result out sys_refcursor)
    is
    begin
    open p_ref_result for
         select *
    {noformat}     from   employees
         ,        (select /*+ cardinality(tab 10) */ tab.nr
                   from   table(p_numbers) tab) tbnrs
         where id = tbnrs.nr;
    end;
    /{noformat}
    Using nested tables will reduce the amount of parsing because the sql statement uses binded variables! The cardinality hint causes Oracle to use the index on employees.id.

Maybe you are looking for

  • Blotch On Screen

    Tried to use my 30GB iPod with video this morning and found there's a black splotch (kinda looks like an ink spot) in the upper right corner of the screen. The top third or so of the screen is faded and blank in spots. The bottom half is viewable, bu

  • How can I delete specific convos in the messages app without it gliching?

    I have an iPhone 4S with absolutely everything up to date. Now I'm pretty much what you could call a texting hoarder.. I have text messages on my phone all the way up until the previous year sometimes. As of this very moment, I'm trying to delete cer

  • Step to Send IDOC to Webmethod

    I have a Scenario to Send IDOC from SAP R/3 to Webmethods. Could you plz tell me the Steps to configure the IDOc and then send it to the Webmethods for further Processing. if we have any documentation, then plz forward me. Any Links which i can refer

  • Installing CS5 on second computer (Installer failed To Initalize)

    I have CS5 and want to install it on my laotop I already have it on my desktop Ihave down loaded adobe advisor it detetec's nothing wrong but I get error mesage ( installer faied to initilize )

  • INCORRECT DATE FORMAT

    Hello everybody, I encounter the below mentioned error: SQLLoader: Release 9.2.0.1.0 - Production on Sat Jun 13 12:26:50 2009 Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved. ORA-01821: date format not recognized The control file i