Can I use same connection pool on multiple web app?

Hi,
I have several web applications on my domain, and they all share the same database.
I am using TOMCAT 4, and I've wrote my own pool, but the problem is that there are also some other domains on the server, so I can't put my connection pool in the tomcat's share or common directory.
Right now, I am thinking of switching to use tomcat's datasource implementation. How do I configure the datasource so that all my web apps will use the same connection pool?
Thanks!

There's no actual webapp configuration when using Datasources... your Java code accesses the Datasource through JNDI:
     Connection con = null;
     String dataSourceName = "someDataSource"
     try {
          Hashtable parms = new Hashtable();
          parms.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
          Context ctx = new InitialContext(parms);
          javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup(dataSourceName);
          con = ds.getConnection();
     } catch (NamingException e) {
          throw new SQLException("NamingException - " + e.toString());
     }If you want, you can keep the DataSource name in the application's ServletContext, so that you don't hard code it into your Java code.

Similar Messages

  • Can I use Interop.Excel in Office 365 web app development

    Hi,
    I want to develop a app for office 365 web. I know javascript api is available for that purpose but the problem is, it is limited to some functionality only. I want to manipulate excel sheets and ranges so will Interop assembly work ? 
    Thanks

    Hi Maulik,
    >>Can I use Interop.Excel in Office 365 web app development <<
    No, the Office PIAs is used to interact with Office Client which developet with COM technology. The Office online is different with Office client, it is an service and exposed with HTML.
    >>I know javascript api is available for that purpose but the problem is, it is limited to some functionality only.<<
    Did javascript mean JavaScript API for Office? If you have any feedback about apps for Office, you can submit it from link below:
    Customer Feedback for the Office Developer Platform
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • Can we use same data definition with multiple concurrent programs?

    Hi,
    My requirement is as below:
    I have two concurrent programs (say CP1 and CP2), both concurrent programs need to use same data definition (the same data template xml file) and same RTF layout template. However when registering data definition in the E-Biz, the data definition code must match concurrent program, hence I have to create two definitions (for the same data template xml file) and because layout template is attached with data definition I have to duplicate the layout definition also.
    In summary, i have to create two (duplicate) Data Definition and Layout Template for the same dataTemplate.xml and Layout.rtf files. Is there any way to avoid this duplication?
    The only issue with duplication is any change in xml or rtf needs to be updated in all the four definitions (2 data definitions and 2 layout definitions).
    Thanks
    Bhavik

    I found the resolution and thought of sharing
    you can see this post
    *[How to use same data definition/template between multiple concurrent programs? |http://techatwork.wordpress.com/2009/08/06/how-to-use-same-data-definitiontemplate-between-multiple-concurrent-programs/]*
    Thanks
    Bhavik

  • How to use my connection pool in multiple servlets?

    I now have a functioning connection pool using these lines in a servlet:
    private Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    ========================
    If I want to create additional servlets in the same web app which query the same database,
    do I need to repeat this block of code in every servlet, or can I just put it in one servlet
    and have other servlets access it in some way to get a connection? Should I change the code
    above from a "private" Connection to a "public" Connection?
    An example servlet is shown below. To put my question another way: If I want to
    create a second servlet with a different set of queries, would I just make a copy of the first
    servlet and then change only the queries, or is there a more efficient way to have multiple
    servlets get connections from the pool?
    Any suggestions are greatly appreciated.
    Thank you.
    Logan
    ************************************servlet example**********************************
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.Date;
    import java.text.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class CraigsMain extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    private Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    // Process the http Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
    try {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String sql = "select formtitle from checkboxforms where cbformid = 157";
    // error occurs at this line
    Connection ocon = getConnection("java:comp/env/jdbc/CraigsList");
    PreparedStatement pStmt = ocon.prepareStatement(sql);
    ResultSet rs1 = pStmt.executeQuery();
    rs1.next();
    out.println("<br>" + rs1.getString(1));
    rs1.close();
    pStmt.close();
    ocon.close();
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException ne) {
    System.err.println("naming exception error: " + ne);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    =======================================================================

    sjasja, Thank you for the reply. What you are suggesting is exactly what I have been looking for. But I'm pretty weak on how to make this separate con pool servlet work. My first attempt is shown below. It doesn't compile this line, which is obviously wrong:
    public static Connection getConnection(String lookup) throws NamingException, SQLException {
    Could you please help me with this servlet code? Thanks.
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class ConPoolInit extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
    public static Connection getConnection(String lookup) throws NamingException, SQLException {
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup(lookup);
    Connection ocon = ds.getConnection();
    context.close();
    return ocon;
    } // private Connection getConnection(String lookup) throws NamingException, SQLException {
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException ne) {
    System.err.println("naming exception error: " + ne);
    =======================================

  • Can i use same address pool for different remote access VPN tunnel groups and policy

    Hi all,
    i want to create a different remote access VPN profile in ASA. ihave one RA vpn already configured for some purpose.
    can i use the same ip address pool used for the existing one for the new tunnel-group (to avoid add rotuing on internal devices for new pool) and its a temporary requirement)
    thanks in advance
    Shnail

    Thanks Karsten..
    but still i can have filtering right? iam planning to create a new group policy and tunnelgroup and use the existing pool for new RA  and i have to do some filetring also. for the new RA i have to restrict access to a particualr server ,my existing RA have full access.
    so iam planning to create new local usernames for the new RA and new group policy with vpn-filter value access-list to apply for that user as below,  this will achive waht i need right??
    access-list 15 extended permit tcp any host 192.168.205.134 eq 80
    username test password password test
    username test attributes
    vpn-group-policy TEST
    vpn-filter value 15
    group-policy TEST internal
    group-policy TEST attributes
    dns-server value 192.168.200.16
    vpn-filter value 15
    vpn-tunnel-protocol IPSec
    address-pools value existing-pool
    tunnel-group RAVPN type ipsec-ra
    tunnel-group RAVPN general-attributes
    address-pool existing-pool
    default-group-policy TEST
    tunnel-group Payroll ipsec-attributes
    pre-shared-key xxx

  • How can I use the Connection Pool with DB2

    Hi All,
    I am facing the problem with the usage for the Connection Pool.
    I want to use DB2 via JNDI lookup.
    But when starting the Weblogic server, Error occured with the following message.
    <Error> <JDBC> <Cannot startup connection pool "MyJDBCPool" Cannot load driver class : com.ibm.db2.jdbc.app.DB2Driver>
    DB2 and Weblogic are on the same machine.
    In case of the use of remote DB2 database, I also encountered the same error.
    Configurations are as follows.
    <JDBCConnectionPool DriverName="com.ibm.db2.jdbc.app.DB2Driver"
    MaxCapacity="10" Name="MyJDBCPool"
    Password="{3DES}gCGsOfD9M6iwOtgL2v/NpA==" Targets="myserver"
    TestConnectionsOnReserve="false" TestTableName="test" URL="jdbc:db2://localhost:6789/yongjoo"/>
    <SNMPAgent Name="mydomain"/>
    <JDBCDataSource JNDIName="acsdb" Name="acsdb" PoolName="MyJDBCPool" Targets="myserver"/>
    Could you please give some information about this problem? I will appreciate your kindness.

    Hi Joe,
    Thanks your help.
    Perhaps It's my fault for Weblogic console's setting.
    After I reset the target server in console, Error message disappeared.
    But, when I call the TestCode, I encountered another error message. The error
    is NameNotFoundException.
    When lookingup the JNDI name, NameNotFoundException errer occured. I tried to
    change my setting and JNDI name, but the results are the same.
    Would you please give me some information about this one more time? I will be
    appreciated for your help.
    Follows are Config.xml
    <JDBCConnectionPool DriverName="com.ibm.db2.jdbc.app.DB2Driver" MaxCapacity="10"
    Name="MyJDBCPool" Password="{3DES}gCGsOfD9M6iwOtgL2v/NpA==" Targets="myserver"
    TestConnectionsOnReserve="false" TestTableName="test"
    URL="jdbc:db2://localhost:6789/yongjoo"/> <SNMPAgent Name="mydomain"/>
    <JDBCDataSource JNDIName="acsdb" Name="acsdb" PoolName="MyJDBCPool"
    Targets="myserver"/>
    and follows are TestCode,
    url = "t3://localhost:7001"; //default URL
    datasource = "jdbc/acsdb";
    Context ctx = null;
    Hashtable p = new Hashtable();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, url);
    try{
    ctx = new InitialContext(p);
    System.err.println("initialContext(p)"+ctx); <-- success
    ds = (DataSource)ctx.lookup("java:comp/env/jdbc/acsdb");
    }catch(NameNotFoundException ne){
    throw new ConnectionException(); .
    }catch(NamingException ne){
    throw new ConnectionException();

  • How can i use the connection pool in JDBC2.0

    Thanks

    Hi,
    You can use DbConnection broker which directly returns connection to DB
    Try http://www.javaexchange.com/
    In that you can specify max and min pool connection pool size
    see example below:
    DbConnectionBroker dbBroker = new DbConnectionBroker(strDBDriver, strDBURL,strDBUser, strDBPassword, iMinPoolSize,     iMaxPoolSize, strLogFile, dblTimeInMillisBetResets);

  • Can i use same licence for after effects 7 on multiple computers

    can i use same licence for after effects 7 on multiple computers

    you can install on any number of computers, but you can activate on, at most, two computers concurrently with a single user license.

  • 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.

  • Can we use same program ID for more than one RFC scenarios

    Hi experts,
                I am working on a RFC to FILE scenario. I have created one TCP/IP connection in SM59 with a program ID. Can we use this program ID for more than one scenario. I have written code as below
    data: iquote type standard table of ZIQMD initial size 0,
          IPRODUCT type standard table of ZPMS initial size 0,
          wa_quote type ZIQMD,
          wa_PRODUCT type ZPMS.
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER'
      TABLES
        I_QUOTE       = iquote          .
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER' in background task DESTINATION
    'ID4'
      TABLES
        I_QUOTE       = iquote          .
      COMMIT WORK.
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER'
      TABLES
        IPRODUCT       = IPRODUCT          .
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER' in background task DESTINATION
    'ID4'
      TABLES
        IPRODUCT       = IPRODUCT          .
        COMMIT WORK.
    when i am executing the code like this. i am able to send the data to 'Z_CBT_RFC_QUOTEMASTER'  , but iam not getting data  for 'Z_CBT_RFC_PRODUCTMASTER'  interface. ID4 is the connection that i have created in SM59. with program ID as ABCD.
                  Can i use the same connection for all interfaces.Please help in this, if we can use same connection for all interfaces. then how to make changes in XI.
    Thanks in advance.
    Thanks & Regards,
    Poorna.

    Just tried this and I can confirm that my earlier understanding was correct!
    One of my colleagues confused me out and the conclusion is,
    1. You need a separate TCP IP Connection for every interface with a Unique program ID.
    Regards
    Bhavesh

  • Find My Phone - can I use same user + password for 2 phones?

    Just loaded the "Find My Phone" App on my new iPhone 4 and set it up. What a great tool for locating a lost iPhone. The only problem is that my wife and I have a joint mail and apple ID account.
    So, my question is can I use Same user name (mail account) and password for TWO iPhone 4's (mine and wifes)? I assume that would work since each phone has a different serial number, and it seems to be ok when connected to my computer to sync each phone separately.
    Any help would be appreciated, thanks.

    My phone was stolen a few days ago. It must be flat by now, I have had it locked by my service provider, Find my Phone still works but says it's in Sydney, I live in Melbourne. Is this accurate? How can it still find the phone if it's not on?

  • How can I use same iTunes on iPad 64GB and iPhone 5 16 GB memory

    How can I use same iTunes account on iPad 64GB and iPhone 5 16 GB memory

    Just connect them your computer. iTunes will treat each device separately. Or if you mean iTunes Store account, you can choose what you download to each device, either directly from the iTunes Store or in synching from iTunes on your computer, as long as you don't have automatic downloads turned on.
    Regards.
    Forum Tip: This forum is for questions about using iPads in companies and organizations. Questions about the general use of iPads will normally best be posted in the Using iPad forum.

  • What's the difference between using a connection pool and a datasource

    Howdy. I figure this is a newbie question, but I can't seem to find an
    answer.
    In the docs at bea, the datasource docs say
    "DataSource objects provide a way for JDBC clients to obtain a DBMS
    connection. A DataSource is an interface between the client program and the
    connection pool. Each data source requires a separate DataSource object,
    which may be implemented as a DataSource class that supports either
    connection pooling or distributed transactions."
    In there it says the datasource uses the connection pool, but other than
    that, what is the difference between a connection pool and a datasource?

    Thanks for the info. I think it makes some sense. But it's a bit greek.
    I'm sure it'll make more sense the more I work with it. Thanks.
    "Chuck Nelson" <[email protected]> wrote in message
    news:3dcac1f5$[email protected]..
    >
    Peter,
    Here is a more formal definition of a DataSource from the Sun site
    "A factory for connections to the physical data source that thisDataSource object
    represents. An alternative to the DriverManager facility, a DataSourceobject
    is the preferred means of getting a connection. An object that implementsthe
    DataSource interface will typically be registered with a naming servicebased
    on the JavaTM Naming and Directory (JNDI) API.
    The DataSource interface is implemented by a driver vendor. There arethree types
    of implementations:
    Basic implementation -- produces a standard Connection object
    Connection pooling implementation -- produces a Connection object thatwill automatically
    participate in connection pooling. This implementation works with amiddle-tier
    connection pooling manager.
    Distributed transaction implementation -- produces a Connection objectthat may
    be used for distributed transactions and almost always participates inconnection
    pooling. This implementation works with a middle-tier transaction managerand
    almost always with a connection pooling manager.
    Does that help clarify the distinction?
    Chuck Nelson
    DRE
    BEA Technical Support

  • How do I find out what is using a connection pool

    This morning weblogic 8.1.5 complained it couldn't expand a connection pool because it had reached is max concurrent connects limit.
    The issue I have is that I don't actually know what is using the connection pool. It should be defunct and redundent but obviously not.
    This caused all the threads to be consumed and the managed server hung.
    Does anyone know wether it's possible to interigate the pool to find out what it's doing ? I can't check the db as it's managed by another company and I have a v limited read only account.... I can't even select from v&session.
    Cheers in advance for any help.

    Dave Snaith wrote:
    This morning weblogic 8.1.5 complained it couldn't expand a connection pool because it had reached is max concurrent connects limit.
    The issue I have is that I don't actually know what is using the connection pool. It should be defunct and redundent but obviously not.
    This caused all the threads to be consumed and the managed server hung.
    Does anyone know wether it's possible to interigate the pool to find out what it's doing ? I can't check the db as it's managed by another company and I have a v limited read only account.... I can't even select from v&session.
    Cheers in advance for any help.If the pool is not supposed to be used, disable it via the console,
    and whatever applications are still trying to use it will get
    quick exceptions.
    Joe

  • Best use of connection pool

    hi all,
    i have some confusion if someone have good suggetions for me.
    i make an connection pool class, and in that package and subpackages i have different class files which do interact with DB thus in whole class files i want to use that same connection pool.
    would any one tell me which will be best method to do it.
    or i have to pass the connection pool to every class object.
    Thanks

    InitialContext initialContext = new InitialContext();
    DataSource dataSource = (DataSource)initialContext.lookup("connPool");
    Connection connection = dataSource.getConnection();You need to do a JNDI lookup for the DataSource and getConnection() from that.
    ***Annie***

Maybe you are looking for