How to use pool connection run oracle procedure?

Hi, All:
          I am facing a difficulty I can not find the solution. Maybe you can help
          me.
          I want to call an oracle stored procedure whenever I talk to datebase to
          make the application more efficient. I was able to run the procedure using
          oracle thin driver but not the connection pool using Weblogic jDriver for
          JDBC2.0.
          Please check the following code and see what I did wrong:
          The code in JSP file in Weblogic:
          <%-- JSP page directive --%>
          <%@ page
          import="java.io.*,java.util.*,java.sql.*,weblogic.common.*,weblogic.jdbc20.c
          ommon.*" %>
          <%-- JSP Declaration --%>
          <%!
          protected Connection con = null;
          ResultSet rset = null;
          %>
          <%-- JSP Scriptlet --%>
          <% try {
          Properties props = new Properties();
          props.setProperty("user", "james");
          props.setProperty("password", "aimjames");
          Driver myDriver =
          (Driver) Class.forName
          ("weblogic.jdbc.pool.Driver").newInstance();
          con = myDriver.connect("jdbc:weblogic:pool:hdj2Pool", props);
          String userid = (String)session.getAttribute("user.id");
          int subid =
          Integer.parseInt((String)session.getAttribute("sub.id"));
          String query = "begin pkg_select.sel_req_in_001(" + userid +
          ", " + subid + ", ?); end;";
          weblogic.jdbc.common.OracleCallableStatement cstmt =
          (weblogic.jdbc.common.OracleCallableStatement)con.prepareCall(query);
          cstmt.registerOutParameter(1,java.sql.Types.OTHER);
          cstmt.execute();
          rset = cstmt.getResultSet(1);
          When I run this JSP file, the compilation is fine but the result shows
          nothing. That's means I can not get the ResultSet for some reason.
          The working file when I use oracle thin driver (NOT use a connection pool):
          String userid = (String)session.getAttribute("user.id");
          int subid = Integer.parseInt((String)session.getAttribute("sub.id"));
          String query = "begin pkg_select.sel_req_in_001(" + userid +", " +subid
          +", ?); end ";
          CallableStatement cstmt = con.prepareCall(query);
          cstmt.registerOutParameter(1,OracleTypes.CURSOR);
          cstmt.execute();
          ResultSet rset = (ResultSet)cstmt.getObject(1);
          You may notice that I am trying to bind a parameter to an Oracle cursor. Is
          there anything I did wrong in using weblogic API? I just want to let you
          that in the weblogic JSP file, I also tried to use
          weblogic.jdbc.oci.CallableStatement and
          weblogic.jdbc20.oci.CallableStatement instead of
          weblogic.jdbc.common.OracleCallableStatement, but none of them seems work.
          I did check the bea site at
          http://www.weblogic.com/docs51/classdocs/API_joci.html#1080420 for the
          example to use:
          cstmt.registerOutParameter(1,java.sql.Types.OTHER);
          and I think I followed the exact procedure the example did.
          Please help!
          James Lee
          Artificial Intelligence in Medicine, Inc.
          2 Berkeley Street, Suite 403
          Toronto, Ontario M5A 2W3
          Tel: 416-594-9393 ext. 223
          Fax: 416-594-2420
          Email: [email protected]
          

Joseph
Thanks for the suggestion about latest version of Weblogic Server.
"coding best-practices" is not mentioned in the post.
In order to make servlet application run significantly faster, my servet how to use connection poo is much moreresonable?
It is reasonable to expect servlet to run significantly faster with connection pooling.
Is it true that geting and close a connection whenever
one time database access finished?
Already answered. Applications use a connection from the pool then return it when finished using the connection.
Will the solution affect the servlet performance?
Yes. Already answered. Connection pooling enhances performance by eliminating the costly task of creating database connections for the application.
Is there any official document to introduce connection pool program?
For the latest version
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13726/toc.htm
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13737/jdbc_datasources.htm#insertedID0

Similar Messages

  • How to use BYDATE to run a procedure on a given list of dates ..?

    Hi all,
    Our client has a meeting schedule and he needs a report prior to every meeting. He had sent us the meeting dates and my manager asked me to schedule a job in the database to run prior to his meeting so that we can get him the report on time. Now I have to schedule a job which should be executed on the dates he has given. I tried to configure the BYDATE parameter in dbms_scheduler.create_schedule but its giving me an error. My database is Oracle 10g R1 and OS is Solaris 9.
    select * from V$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bi
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for Solaris: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    select PLATFORM_NAME from v$database;
    PLATFORM_NAME
    Solaris[tm] OE (64-bit)
    BEGIN
    dbms_scheduler.create_schedule (
              schedule_name => 'CLIENT_REPORT_JOB',
              repeat_interval => 'FREQ=DAILY;BYDATE=20080912,20080913',
    comments => 'Client Report');
    END;
    ERROR at line 1:
    ORA-27412: repeat interval contains invalid keyword: BYDATE
    ORA-06512: at "SYS.DBMS_ISCHED", line 595
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1045
    ORA-06512: at line 2
    Can someone help me, please...?
    Thanks in advance.
    Regards,
    FlameThrower

    Hi,
    Many of the Scheduler Calendar enhancements were introduced in 10gR2. Since you are using 10gR1 you should check the Scheduler documentation for 10gR1 to see if BYDATE is supported in that release (I don't think it is).
    If it isn't, as a workaround, you can use a PL/SQL date function which has the list of dates hardcoded in it and returns the next applicable date.
    Hope this helps,
    Ravi.

  • How to use JDBC Connection Pools in a standalone application?

    Hi, there,
    I have a question about how to use JDBC Connection Pools in an application. I know well about connection pool itself, but I am not quite sure how to keep the pool management object alive all the time to avoid being destroyed by garbage collection.
    for example, at the website: http://www.developer.com/java/other/article.php/626291, there is a simple connection pool implementation. there are three classes:JDBCConnection, the application's gateway to the database; JDBCConnectionImpl, the real class/object to provide connection; and JDBCPool, the management class to manage connection pool composed by JDBCConnectionImpl. JDBCPool is designed by Singleton pattern to make sure only one instance. supposing there is only one client to use connection for many times, I guess it's ok because this client first needs instantiate JDBCPool and JDBCConnectionImpl and then will hold the reference to JDBCPool all the time. but how about many clients want to use this JDBCPool? supposing client1 finishes using JDBCPool and quits, then JDBCPool will be destroyed by garbage collection since there is no reference to it, also all the connections of JDBCConnectionImpl in this pool will be destroyed too. that means the next client needs recreate pool and connections! so my question is that if there is a way to keep pool management instance alive all the time to provide connection to any client at any time. I guess maybe I can set the pool management class as daemon thread to solve this problem, but I am not quite sure. besides, there is some other problems about daemon thread, for example, how to make sure there is only one daemon instance? how to quit it gracefully? because once the whole application quits, the daemon thread also quits by force. in that case, all the connections in the pool won't get chance to close.
    I know there is another solution by JNDI if we develop servlet application. Tomcat provides an easy way to setup JNDI database pooling source that is available to JSP and Servlet. but how about a standalone application? I mean there is no JNDI service provider. it seems a good solution to combine Commons DBCP with JNID or Apache's Naming (http://jakarta.apache.org/commons/dbcp/index.html). but still, I don't know how to keep pool management instance alive all the time. once we create a JNDI enviroment or naming, if it will save in the memory automatically all the time? or we must implement it as a daemon thread?
    any hint will be great apprieciated!
    Sam

    To my knoledge the pool management instance stays alive as long as the pool is alive. What you have to figure out is how to keep a reference to it if you need to later access it.

  • How to use @jws:sql call Stored Procedure from Workshop

    Is there anyone know how to use @jws tag call Sybase stored procedure within
    Workshop,
    Thanks,

    Anurag,
    Do you know is there any plan to add this feature in future release? and
    when?
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    In the current release, we do not support calling stored procedures from a
    database control. You will have to write JDBC code in the JWS file to call
    stored procedures.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Anurag,
    I know how to use DB connection pool and create a db control with it. In
    fact, we have created a Web Service with the db control using plain SQL
    in
    @jws:sql. However, my question here is how to use @jws tag in Weblogic
    Workshop to create a Web Services based on Sybase stored procedure orany
    Stored Proc not plain SQL.
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    You can use a database control to obtain a connection from any JDBC
    Connection Pool configured in the config.xml file. The JDBC Connectionpool
    could be connecting to any database, the database control is
    independent
    of
    that.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Is there anyone know how to use @jws tag call Sybase stored
    procedure
    within
    Workshop,
    Thanks,

  • How to use java source in Oracle when select by sqlplus.

    How to use java source in Oracle when select by sqlplus.
    I can create java source in Oracle
    import java.util.*;
    import java.sql.*;
    import java.util.Date;
    public class TimeDate
         public static void main(String[] args)
    public String setDate(int i){
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(new Date((long)i*1000));
    System.out.println("Dateline: "
    + calendar.get(Calendar.HOUR_OF_DAY) + ":"
    + calendar.get(Calendar.MINUTE) + ":"
    + calendar.get(Calendar.SECOND) + "-"
    + calendar.get(Calendar.YEAR) + "/"
    + (calendar.get(Calendar.MONTH) + 1) + "/"
    + calendar.get(Calendar.DATE));
    String n = calendar.get(Calendar.YEAR) + "/" + (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DATE);
         System.out.print(n);
         return n;
    I have table name TEST
    ID DATE_IN
    1 942685200
    2 952448400
    When I write jsp I use method setDate in class TimeDate
    The result is
    ID DATE_IN
    1 1999/11/16
    2 2003/7/25
    Thanks you very much.

    It is unclear where you are having a problem.  Is your issue at runtime (when the form runs in the browser) or when working in the Builder on the form?
    Also be aware that you will need to sign your jar and include some new manifest entries.  Refer to the Java 7u51 documentation and blogs that discuss the changes.
    https://blogs.oracle.com/java-platform-group/entry/new_security_requirements_for_rias
    http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html

  • How to use bind variables in this procedure

    Hi Experts,
    How to use bind variables in this procedure for static queries.
    PROCEDURE DELETE_MER_PROC (M_id IN NUMBER)
    IS
    BEGIN
    V_date DATE;
    SELECT PD_DATE INTO v_date FROM PD_MAINTAIN;
        DELETE FROM MER_CLEAR
        WHERE MER_DT < v_date
        AND ID = M_ID;
    COMMIT;
    END;   
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    Please help me.
    Thanks.

    976208 wrote:
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    You cannot avoid hard parsing - as the 1st time a SQL statement (like the SELECT or DELETE statements in your code) is encountered, it does not reside in the server's Shared Pool, and needs to be added into the pool via a hard parse.
    Bind variables does not prevent hard parsing. Hard parsing happens when the SQL statement (with or without bind variables) is a brand new statement encountered by the server.
    Bind variables enables the same SQL cursor to be reused, by simply changing the bind variable value.
    Not using bind variables means that each SQL statement is unique and not shareable - as the value is hardcoded into the statement and cannot be changed via a bind value. This typically means LOTS of different SQL statements (where the only difference is the changed value in the statement) are created - with each statement being a new statement not seen before in the Shared Pool and needing to be hard parsed.
    One does not design one's code not to be hard parsed. There ALWAYS will be a hard parse in order to get a SQL statement into the Shared Pool. One designs one's code to REUSE cursors in the Shared Pool.

  • How to convert a dedicated running oracle server to a shared server

    i need help as to how to convert a dedicated running oracle server to a shared server.(step by step plz i am fairly a fresh person)
    there are presently 10 users but have to configure for 125 users accessing from 5 locations.
    also need how to implement connection manager

    125 users are not so much, unless your database server is a quite small one. Anyway, you have to configure Dispatchers and Shared Servers. See Configuring Oracle Database for Shared Server
    About Connection Manager see Configuring and Administering Oracle Connection Manager

  • How to use a connection ODBC in  crystal reports viewer?

    Hi Guys!
    I need to know if for update a report in crystal reports viewer, is necessary, have a connection SAP Business Objects Business Intelligence. How to use a connection ODBC in  crystal reports viewer?

    Hi Guys!
    I need to know if for update a report in crystal reports viewer, is necessary, have a connection SAP Business Objects Business Intelligence. How to use a connection ODBC in  crystal reports viewer?

  • How to use unicode fonts in Oracle forms 10g?

    Hi I am working in forms 10g for quite a long time, the software that I have developed so far are all in English language. Now I have requirements to use Bengali Fonts in Forms 10g. I am facing difficulties doing that. Please reply with help. Thanks
    Hasan Al Mamun

    Check this forum post (though that is for 6i, it would be of helpful for you)
    How to use unicode fonts in Oracle forms 10g?
    -Arun

  • How to  use  crystal reports in oracle Jdeveloper

    Hi,
    I was implemented crystal reports in Crystal reports for eclipse also i made .rpt & .JSP how to use these file in oracle JDeveloper 10 g
    can any one please help regarding this matter send any information if avilable send me on my mail My mail id: - [email protected]
    Thank you !
    regards,
    Amol

    you are in the Oracle Forms Forum and your question is related to JDeveloper and Crystal Reports, you think those two are linked to Oracle Forms in anyway??
    Please post your questions in the appropriate Forum.
    Tony

  • How to use order by in stored procedure base block?

    How to use order by in stored procedure base block? I need to change order by dynamically

    Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');

  • In SQLScript, how to use EXEC to call another procedure with parameters in procedure?

    Hi experts,
    In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very much

    Hi Sagar,
    thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
    create procedure ftest1(out sum_num bigint)
    as
    begin
    declare fa_output bigint;
    declare v_sql_drop varchar(200);
    declare v_sql varchar(500);
    declare cursor c_cursor1 for select num from TABLE1;
    --v_sql_drop := 'drop procedure fe';
    --exec v_sql_drop;
    v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
    v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
    v_sql := :v_sql || ' end';
    exec v_sql;
    open c_cursor1;
    for c_item as c_cursor1 do
    exec 'call fe(c_item.num,o_num=>fa_output)';
    if sum_num is null then
    sum_num := fa_output;
    else
    sum_num := :sum_num + fa_output;
    end if;
    end for;
    close c_cursor1;
    end;
    The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again!

  • How to use DB connect against secondary Oracle DB ?

    Hi all,
    this is the issue:
    an existing BI 7.0 based on Oracle 10.2.0.2.0 has to acquire data from an external Oracle 9.2.0.6 database. We want to use DB connect functionality.
    1st Q: are the existing components (DBSL and Oracle db-client) sufficient for interfacing to the secondary database?
    2nd Q: would it be better practice to look at the external database as a completely separate one? which means to install separate DBSL and db-client for it.
    Unfortunately neither online documentation nor SAP notes provide full clarification. Is there any experience in the field? all comments and contributions are warmly appreciated!
    THX, Harry

    Still puzzling on that issue. Will come back when completely solved. /hs
    OK, gurus, expertz and those to be, here's the story:
    BI 7.0 component of SCM-APO (Oracle 10.2.) is successfully connected to remote Oracle 9.2.
    Actually there have been just a couple of points to look after. First thing was to maintain the alias connection string in tnsnames.ora file. Plus this file is required twice, in the ORASID directory as well as in the <SID>ADM directory.
    Next issue is that apparently Oracle 'grants' are not supported by DB-Connect. But at least there is BI support package 11 which enables us to connect to other users' objects (different user than DB-Connect user). This healed the grants issue.
    Further topics have been the date conversion issue (this should already be done in the remote source DB) and name length and characters-2-B-used requirements.
    Once again thanks for your contributions and happy computing!
    Harry
    Message was edited by:
            Harald Schwenger

  • How to create ODBC connection between Oracle 10g and MS SQL Server

    Hi,
    Can someone help us with the steps to create an ODBC connection between Oracle APPS using Oracle 10g database and MS SQL Server.
    Requirement is to extract the transactional data from MS SQL Server on a daily basis and dump it into Oracle tables for an interface to be run. Currently it is being done through Dataloader tool which we feel is causing the data issue with Arabic characters. We want to create the ODBC directly between Oracle and MS SQL Server and check if the data is being pulled correctly.
    The data is in sql server 2000 which has data in Arabic_CI_AS character set which is moved to Oracle 10.2.0.3 database with characterset AL32UTF8. The table data is moved to oracle using the dataloader 3.6 standard edition licensed version. We cannot change the character set of Sql Server 2000.
    Please help
    Thanks
    Shanil

    Hi,
    If you're trying to PULL data from SQLServer into an Oracle database, you wouldnt use Oracle ODBC driver for that, so you may want to post in the Heterogeneous Services forum instead:
    Heterogeneous Connectivity
    If you're trying to PUSH data from SQLServer into an Oracle database, you could use ODBC but most folks use OLEDB for that, and the following note on MOS should help:
    How to Create a Sql Server Linked Server With The Oracle Provider for OLE DB     (Doc ID 191368.1)
    As with any NLS related issue, the first thing to do is dump the codepoints of the data in the Oracle database to see if it is stored validly, rather than relying on what the data "looks like" from some tool or other. It's best to check a single row, with only a few characters in it if you can, and you can do that via
    SELECT DUMP(<columname>,1016) FROM <tablename> WHERE ...
    Hope it helps,
    Greg

  • Please help, urgent! How to hold the connection to oracle database

    I used java to connect Oracle database using thin driver. But I found out the connection will be closed very soon if I did not make any request of query. I query the database like after 1 mins without doing anything, my application will dead for about 2 mins, then everything become normal again.
    How can I hold the connection or is there any other solution? thank you!

    Duffy is, as usual, correct. If you have a single-user environment, then holding onto a connection is probably okay (not desirable but also not pernicious). However, once you have more than one user, you will want to use a connection pool. Jakarta Commons (jakarta.apache.org) has an open source pool that is reliable.
    But the fact that you are having additional problems makes me believe you are missing a few fundamental concepts, such as transactions. Even if the connection dropped, you should be able to reconnect without issue (granted, with some additional latency). The only time it would pose an issue (above and beyond the ones mentioned above and in previous replies) is if you are not managing your transactions properly.
    In short, take some tutorials on JDBC, DataSource, connection pools and transaction management.
    - Saish

Maybe you are looking for

  • OC4J:home is not coming up after deployment of war file(i.e demantra war)

    Hi, The oc4j:home services is not coming up in OracleAS 10.1.3.2 Middle Tier after deplyment of war file(j2sdk 1.4.2_10) I tried so many times bouncing but oc4j:home is not coming up. Below is the status. Please guide me and help me. D:\product\10.1.

  • How to manage two quantity of two unit in process order?

    Hi  Guys In our plant, we have actived the catch weight management. For products A, we have set the standard conversion relation as follow: 1 EA (basic of unit)= 2.5 KG (production unit). But when I create the process order for products A, I only can

  • Why hashMap is not the part of collection framework

    why hashMap is not the part of collection framework ?? why Map start its own new hierarchy?? thanks

  • Ipod wont update, restore, WORK!!??

    hi everyone, my ipod's been playing up, its the second time this has happened, the last time i managed to sort out the problem but it was an accident! It started off by suddenly deleting all the songs in my ipod, they're still in my library but wont

  • Can a 2009 iMac11,1 be upgraded to Lion?

    I have a 2009 iMac that I have tried previously to upgrade to Lion.  I remember that it was severly unsuccessful.  I do not remember why.  Before I try again, I wanted to ask the community about their experiences with the upgrade.  My hardware data i