How do I set miminum # of connections for pool with Oracle and Tomcat?

Hi,
I can't seem to find any attribute to initialize the number of connections for my connection pool. Here is my current context.xml file under my /App1 directory:
<Context path="/App1" docBase="App1"
debug="5" reloadable="true" crossContext="true">
<Resource name="App1ConnectionPool" auth="Container"
type="oracle.jdbc.pool.OracleDataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
url="jdbc:oracle:thin:@127.0.0.1:1521:oddjob"
user="app1" password="app1" />
</Context>
I've been googling and reading forums, but haven't found a way to establish the minimum number of connections. I've tried all sorts of parameters like InitialLimit, MinLimit, MinActive, etc, with no success.
Here is some sample code that I am testing:
package web;
import oracle.jdbc.pool.OracleDataSource;
import oracle.jdbc.OracleConnection;
import javax.naming.*;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class ConnectionPool {
String message = "Not Connected";
public void init() {
OracleConnection conn = null;
ResultSet rst = null;
Statement stmt = null;
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
OracleDataSource ds = (OracleDataSource) envContext.lookup("App1ConnectionPool");
message = "Here.";
     String user = ds.getUser();
if (envContext == null)
throw new Exception("Error: No Context");
if (ds == null)
throw new Exception("Error: No DataSource");
if (ds != null) {
message = "Trying to connect...";
conn = (OracleConnection) ds.getConnection();
Properties prop = new Properties();
prop.put("PROXY_USER_NAME", "adavey/xxx");
if (conn != null) {
message = "Got Connection " + conn.toString() + ", ";
          conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME,prop);
stmt = conn.createStatement();
rst = stmt.executeQuery("SELECT username, server from v$session where username is not null");
while (rst.next()) {
message = "DS User: " + user + "; DB User: " + rst.getString(1) + "; Server: " + rst.getString(2);
rst.close();
rst = null;
stmt.close();
stmt = null;
conn.close(); // Return to connection pool
conn = null; // Make sure we don't close it twice
} catch (Exception e) {
e.printStackTrace();
} finally {
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rst != null) {
try {
rst.close();
} catch (SQLException e) {
rst = null;
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
stmt = null;
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
conn = null;
public String getMessage() {
return message;
I'm using a utility to repeatedly call a JSP page that uses this class and displays the message variable. This utility allows me to specify the number of concurrent web requests and an overall number of requests to try. While that is running, I look at V$SESSION in Oracle and occassionaly, I will see a brief entry for app1 or adavey depending on the timing of my query and how far along the code has processed in this example. So it seems that I am only using one connection at a time and not a true connection pool.
Is it possible that I need to use the oci driver instead of the thin driver? I've looked at the javadoc for oci and the OCIConnectionPool has a setPoolConfig method to set initial, min and max connections. However, it appears that this can only be set via Java code and not as a parameter in my context.xml resource file. If I have to set it each time I get a database connection, it seems like it sort of defeats the purpose of having Tomcat maintain the connection pool for me and that I need to implement my own connection pool. I'm a newbie to this technology so I really don't want to go this route.
Any advice on setting up a proper connection pool that works with Tomcat and Oracle proxy sessions would be greatly appreciated.
Thanks,
Alan

Well I did some more experiments and I am able to at least create a connection pool within my example code:
package web;
import oracle.jdbc.pool.OracleDataSource;
import oracle.jdbc.OracleConnection;
import javax.naming.*;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class ConnectionPool {
String message = "Not Connected";
public void init() {
OracleConnection conn = null;
ResultSet rst = null;
Statement stmt = null;
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
OracleDataSource ds = (OracleDataSource) envContext.lookup("App1ConnectionPool");
message = "Here.";
     String user = ds.getUser();
if (envContext == null)
throw new Exception("Error: No Context");
if (ds == null)
throw new Exception("Error: No DataSource");
if (ds != null) {
message = "Trying to connect...";
boolean cache_enabled = ds.getConnectionCachingEnabled();
if (!cache_enabled){
ds.setConnectionCachingEnabled(true);
Properties cacheProps = new Properties();
cacheProps.put("InitialLimit","5");
     cacheProps.put("MinLimit","5");
cacheProps.put("MaxLimit","10");
ds.setConnectionCacheProperties(cacheProps);
          conn = (OracleConnection) ds.getConnection();
Properties prop = new Properties();
prop.put("PROXY_USER_NAME", "adavey/xyz");
if (conn != null) {
message = "Got Connection " + conn.toString() + ", ";
          conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME,prop);
stmt = conn.createStatement();
//rst = stmt.executeQuery("SELECT 'Success obtaining connection' FROM DUAL");
rst = stmt.executeQuery("SELECT user, SYS_CONTEXT ('USERENV', 'SESSION_USER') from dual");
while (rst.next()) {
message = "DS User: " + user + "; DB User: " + rst.getString(1) + "; sys_context: " + rst.getString(2);
message += "; Was cache enabled?: " + cache_enabled;
rst.close();
rst = null;
stmt.close();
stmt = null;
conn.close(OracleConnection.PROXY_SESSION); // Return to connection pool
conn = null; // Make sure we don't close it twice
} catch (Exception e) {
e.printStackTrace();
} finally {
// Always make sure result sets and statements are closed,
// and the connection is returned to the pool
if (rst != null) {
try {
rst.close();
} catch (SQLException e) {
rst = null;
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
stmt = null;
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
conn = null;
public String getMessage() {
return message;
In my context.xml file, I tried to specify the same Connection Cache Properties as attributes, but no luck:
<Context path="/App1" docBase="App1"
debug="5" reloadable="true" crossContext="true">
<Resource name="App1ConnectionPool" auth="Container"
type="oracle.jdbc.pool.OracleDataSource"
driverClassName="oracle.jdbc.OracleDriver"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
url="jdbc:oracle:thin:@127.0.0.1:1521:oddjob"
user="app1" password="app1"
ConnectionCachingEnabled="1" MinLimit="5" MaxLimit="20"/>
</Context>
These attributes seemed to have no effect:
ConnectionCachingEnabled="1" ; also tried "true"
MinLimit="5"
MaxLimit="20"
So basically if I could find some way to get these attributes set within the context.xml file instead of my code, I would be a happy developer :-)
Oh well, it's almost Miller time here on the east coast. Maybe a few beers will help me find the solution I'm looking for.

Similar Messages

  • How could I set the proxy settings for just some URLs and not for all?

    Hello,
    I am using HttpURLConnection to establish a HTTP connection . The connection pass through a proxy, and it requires security.
    I know that I can set the proxy settings in the system properties, and this works perfect.
    But I don't want to set the proxy settings in the system properties, because this proxy settings will be for ALL the URLs, and I just want for a few URLs.
    How could I set the proxy settings for just some URLs and not for all?
    Thanks

    java.net.URL.openConnection(java.net.Proxy proxy)
    @since 1.5

  • How do you set up the alert for FaceTime with sound

    How do you set up the alert for FaceTime with sound?

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime: Set-up, Use, and Troubleshooting Problems
    http://tinyurl.com/32drz3d
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
     Cheers, Tom

  • My daughter and i share same itunes account but we want to separate and have our own. if i change "our" account to "her" account how can i set up a new "for me only" account and retrieve all my contacts and apps

    my daughter and i share the same i tunes account but want to have our own now. how can i set up a new account just for me and still move or transfer my existing apps, contacts etc?

    Yes, with the credentials of the account that the media/content was purchased with.
    Content is permanently tied to the account it is purchased with and cannot be merged, moved, or transferred to another account.

  • Connection Problem with Oracle and Tomcat.

    I was able to enter Oracle using scott/tiger when I did not connect Tomcat.But when I connect tomcat I am unable to log onto Oracle.
    When I logged to the database then I tried to start the Tomcat but it gave an exception.So I went to the task manager and ended the running processes like isqlplus.exe, oracle.exe, tomcat.exe, apache.exe.When I ended all the processes except oracle.exe, tomcat gave an exception. But when I ended oracle.exe Tomcat started working but Oracle stopped working. I don't know what the problem is.
    Can anyone help me out?
    Thanks,
    Sravanthi.

    > Can anyone help me out?
    Yeah sure. Is there a SQL or PL/SQL related question in there.. somewhere.. hiding away?
    After all, you do realise that the name of this forum is SQL and PL/SQL and that it deals with the SQL and PL/SQL languages in the Oracle server.. right?

  • How do I set up Aperture 3 for use with wide gamut monitor?

    I use a NEC 2690wuxi attached to a macbook pro for my main screen when i do retouching on photos. Right now the images come up a bit neon on the NEC and look fine on the laptop screen. Is there a way to adjust this?...
    I have no problem with this when working in Photoshop CS3 or Lightroom 2.6.
    thanks...

    I have the same problem using my macbook Pro and a EIZO CG241W monitor.
    I calibrate both the macbook screen and the EIZO and set the colorsync profile to make the EIZO the default profile. If I have aperture on the macbook screen all appears ok including the picture I open in Photoshop to compare. If I have the preview on the external monitor the colors are overly saturated in Aperture and no where close to the picture opened in photoshop. Strangely enough the thumbnail previews seem to show the proper color.It is the large preview as well as the mirrored screen (option+M) that show the wrong colors. I also notice that if I click on an image opened in Photoshop CS4 and drag it to the external monitor that as long as I hold it clicked the colors match those in the preview but as soon as I let go the colors change back to what I think is the proper colors. This means that Aperture is still using the macbook monitor profile even though the EIZO monitor has been set as default in the colorsync program. I have had the same issue with aperture2.
    Photoshop, bridge,lightroom 2 and Phaseone Capture 1 Pro versions 3 through 5 all handle the profiles correctly. I have been doing pre press for european catalogues for years this way. I also reverted to OS X 10.5.8 after having installed snow leopard as snow leopard also had colorsync problems while using dual monitors on a Macbook Pro. I don't think anyone here in the forums will have a solution to this problem ,I can only hope enough people have complained to apple directly so that the software engineers will be put to work to fix this problem. Aperture 3 is absolutely impossible for me to use like this and I am very disappointed to have spent money on professional software that obviously does not work correctly on a dual monitor set up. And no.. I can not do proper color correction on my MAcbook Pro Screen!!
    Should anyone have an idea how to solve the problem outside of the obvious answers I am all ears,
    as of now I will copy this and send it to apple support!

  • How do I set one monitor calibration for the whole system and users?

    I'm really angry because when I logged into my first default account, My settings where normal, but I logged into my alt account, the settings where all messed up (NO ONE TOUCHED MY COMPUTER, AND THE ACCOUNT HAS A STRONG PASSWORD) The white balance was that slightly blue one. So, I changed it, and logged in to the alt account again to see it was okay. I want to my main account and used screenlock, and noticed on the login screen (I logged out of the account after I saw to see this same thing) it was the light bluer white balance. So I logged in and calibrated AGAIN and it finally when back to the default on the login screen (2:2 or something and native white balance) and my preferences for my accounts (television gamma, and native white balance) I just want it system wide to be:
    -2:2 TELEVISION GAMMA
    -Native White Gamma
    Or at-least the login screen, and my two accounts, and that settings to be the system wide default.

    Thanks for helping me make it worse.
    First off, if you want help, act like an adult. We're all just other users you're talking to, not Apple employees. Such angry behavior will only ensure that no one will respond to any questions by you in the future.
    Second, there's nothing wrong with Kappy's advice. The /Library/ColorSync/Profiles/ folder is accessible by all user accounts. So putting one common monitor profile there and setting it in each account is what you want to do.
    What you're seeing is a known issue when switching users without restarting. I don't know if there's ever been a true solution for it.
    One of many articles on the subject:
    http://www.macosxhints.com/article.php?story=20060103162354164
    I know the linked article is about Tiger, but the bug persists through Leopard.

  • How do I set up my router for use with only my laptop?

    I want to use my WRT300N v1 broadband router wirelessly with only my laptop, but the set-up instructions I've seen involve wiring the router to a desktop. Can anyone provide me with the instructions I need?
    Thanks.

    It is not an mandotary step to connect the Desktop to the Router... it just indicates that first you need ant computer connected to the router using cable & working online ....
    If you want to go online with Laptop .... either you can connect the Laptop to the Router using Cable or you can wirelessly go online ,.....
    Connect the Laptop to the router using Ethernet Cable ,,,,, at LAN port 1-4 .... Check the light status ... access setup page ...
    Click on the Wireless tab on the Setup page- Here Wireless Network mode
    should be mixed- Provide any non linksys network name ....
    Name (SSID) box- Set wireless channel to 11- And wireless SSID
    broadcast should be Enabled and then click on "Save Settings" >>Now
    Click on the Sub tab under wireless > "Wireless Security" Change the
    Wireless security mode to "WEP/WPA"...have a note of the key ... click save settings ...
    On the Laptop try connecting to the Wireless network ...
    See if it connects ....

  • How to set min & max connections for  MSSQLconnection pool

    Hi,
    I want to set minconnection, maxconnection, idletimeout initial limit for the pool
    I have got a MSSQL database connection using following java code.
    // MSSQL DbConnection Code
    import java.sql.*;
    public class MsSqlDataSource
    public static void main(String arr[])
    Connection con = null;
    ResultSet rs = null;
    try{
    com.microsoft.sqlserver.jdbc.SQLServerDataSource ds = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
    ds.setServerName("10.50.50.51");
    ds.setPortNumber(1711);
    ds.setDatabaseName("test");
    ds.setUser("starhome");
    ds.setPassword("starhome");
    con = ds.getConnection();
    }catch(Exception e){}
    }In oracle i have passed min and max number of connection properties through setConnectionCacheProperties method.
    //Connection Pooling using Oracle Data Source:
    m_connSource = new OracleDataSource();
    m_connSource.setDriverType("thin");
    m_connSource.setServerName(m_host);
    m_connSource.setNetworkProtocol("tcp");
    m_connSource.setDatabaseName(m_db);
    m_connSource.setPortNumber(m_port);
    m_connSource.setUser(m_user);
    m_connSource.setPassword(m_password);
    // Enable caching. m_connSource.setConnectionCachingEnabled(true);
    java.util.Properties prop = new java.util.Properties();
    prop.setProperty("MinLimit", m_minConnections);
    prop.setProperty("MaxLimit", m_maxConnections);
    prop.setProperty("InitialLimit", m_initialConnections);
    prop.setProperty("InactivityTimeout", m_inactivityTimeout);
    prop.setProperty("AbandonedConnectionTimeout", m_abandonedTimeout);
    prop.setProperty("ConnectionWaitTimeout", m_connWaitTimeout);
    m_connSource.setConnectionCacheProperties(prop);I dont know how to pass min and max number of connection properties for SQLServerDataSource. Is there any method available to pass min and max number of connection properties for SQLServerDataSource.
    Iam using Tomcat. I found one way to set min and max connections for pool by doing changes in context.xml and web.xml using below url http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html
    I dont want to touch tomcat configuration files. I need to set connection pooling properties which is independent of application server.
    Please anybody give solution for this?
    Thanks,
    Prisha

    Hi,
    you need to define your database under the DB Admin tab. In the Schema objects node you'll find Sequence Implementations, and there you can definde min max values as well as caching and increments.
    Gerald

  • How do you set up Port Forwarding for ARD 2.2 in AEB N?

    Help,
    I'm a novice at Apple Remote Desktop (ARD) - not an IT guy, so it has to be pretty basic and detailed.
    How do you set up Port Forwarding for ARD 2.2 on the Apple Airport Extreme BS router, 802.11 N. I have one at each end of the internet connection. At one end I have an Airport Extreme N router with 2 macs and eventually 1 windows XP machine (if I can) that I would like to be able to connect to over the interenet (the clients) and at the other end, I have a Mac with ARD 2.2 installed also with an Airport Extreme N router. Note: Both routers use Static IP addresses and all computers use static IP's internally not through DHCP. What are the settings or directions to do this.
    I have read and printed out the directions for Configuration of ARD 3.0 that are posted many times in the ARD discusion group, but it uses a Linksys router ( http://www.starkpr.com/ard.htm posted by Dave Sawyer). The Mac router is different, particularly with the place to set a Private IP address. I'm not sure about alot of things, but especially about the Private IP address, what number do I set it to, the one that is in my Network connections list? It automatically changes to a different number in AE N setup for Port Forwarding (by one) as if it is not suppose to the same?????
    Are there any directions available that are as straight forward for the Airport Extreme N router, as the one's that are listed here for the Linksys Router's? ( http://www.starkpr.com/ard.htm )
    Any and All help will be greatly appreciated.
    P.S. I know I should have 3.0 but bought 2.2 just weeks before 3.0 came out and they would not give me an upgrade price, so I'm waiting for 4.0 to upgrade.
    Thanks,
    Jim

    Try the following for each AirPort Extreme ...
    AEBSn - Port Mapping Setup
    To setup port mapping on an 802.11n AirPort Extreme Base Station (AEBSn), either connect to the AEBSn's wireless network or temporarily connect directly, using an Ethernet cable, to one of the LAN port of the AEBSn, and then use the AirPort Utility, in Manual Setup, to make these settings:
    1. Reserve a DHCP-provided IP address for the host device.
    Internet > DHCP tab
    o On the DHCP tab, click the "+" (Add) button to enter DHCP Reservations.
    o Description: <enter the desired description of the host device>
    o Reserve address by: MAC Address
    o Click Continue.
    o MAC Address: <enter the MAC (what Apple calls Ethernet ID if you are using wired or AirPort ID if wireless) hardware address of the host computer>
    o IPv4 Address: <enter the desired IP address>
    o Click Done.
    2. Setup Port Mapping on the AEBSn.
    Advanced > Port Mapping tab
    o Click the "+" (Add) button
    o Service: <choose the appropriate service from the Service pop-up menu>
    o Public UDP Port(s): 3283
    o Public TCP Port(s): 3283
    o Private IP Address: <enter the IP address of the host server>
    o Private UDP Port(s): 3283
    o Private TCP Port(s): 3283
    o Click "Continue"
    o Click the "+" (Add) button
    o Service: <choose the appropriate service from the Service pop-up menu>
    o Public UDP Port(s):
    o Public TCP Port(s): 5900
    o Private IP Address: <enter the IP address of the host server>
    o Private UDP Port(s):
    o Private TCP Port(s): 5900
    o Click "Continue"
    o Click the "+" (Add) button
    o Service: <choose the appropriate service from the Service pop-up menu>
    o Public UDP Port(s):
    o Public TCP Port(s): 5988
    o Private IP Address: <enter the IP address of the host server>
    o Private UDP Port(s):
    o Private TCP Port(s): 5988
    o Click "Continue"
    (ref: "Well Known" TCP and UDP ports used by Apple software products)

  • How do I set up e print for my laserjet P1102 for Mac

    how do I set up e print for my laserjet P1102 for Mac? I have downloaded soft ware & ejected disc as directed & don't know next step. Thanks

    Hi,
    As you have setup the printer now you should be having the printers IP address. 
    If not please connect your printer to wifi network with a valid internet network and get the IP address by printing the config page.
    Make sure you connect Mac Book to the same wifi network.
    Now type the IP address on a browser in your Mac Book and hit enter.
    You should be able to see the Embedded Web Server page of your printer.
    Now navigate to Web Services Tab.
    Click on Enable to enable eprint on your printer.
    This will enable the web services on your printer and print the information sheet.
    The information sheet will contain the claim code for your printer.
    The <Claimcode>@hpeprint.com will be your email ID for the printer.
    Kind Regards,
    Oliver
    "Although I work for HP, I'm speaking for myself and not on behalf of HP"--Please mark the post that solves your problem as "Accepted Solution"
    "Say "Thanks" by clicking the Kudos Star in the post that helped you.

  • How can i set the alternating colors for a table rows

    Dear All,
    Please any one help me how can i set the Alternating colors for Table Rows.
    i created a theam there i set the background alternating color to brown and i set the table design properity to alternating. but it is not reflecting.

    Hi,
    The design property in Table properties should work for your requirement. Select "alternating" value for design.
    Please see the API below:
    design
    Determines the appearance of the table. The property design can take the following values and is represented by enumeration type WDTableDesign.
    alternating - The table rows are displayed alternately in a different color.
    standard - The table background has one color. The individual table rows are displayed with grid net lines.
    transparent - The table background is transparent. The individual table rows are displayed without grid net lines.
    Check whether you have changed the right property or not? Also table should contain more than one rows to test this scenario.
    Regards,
    Jaya.
    Edited by: VJR on Jun 17, 2009 6:43 PM

  • How can I set up my Mac for two users to share photos, music etc

    How can I set up my Mac for two users to share photos, music etc?

    On the Mac with the libraries you want to share:
    iTunes Preferences click on the Sharing tab and put a tick in 'Share by library on local network'.
    iPhoto Preferences click on Sharing and put a tick against 'Share my photos'.
    When launching the same apps on other Macs on the network the libraries should be available, listed on the left.

  • How do I set the aspect ration for 4:3  or for 16:9?

    How do I set the aspect ration for 4:3  or for 16:9 in Adobe PE12?

    PulcinellaNM
    What computer operating system is your Premiere Elements 12 running on? Have you updated from 12 to 12.1 Update via a project's Help Menu/Update? If not, please do so. That is all background information for now.
    As for the question that you are posting....
    I think we need to go a lot deeper into what you are doing. Here are some considerations
    The aspect ratio setting is in the import settings. In Premiere Elements 12 Expert workspace, the project automatically sets the project preset based on the properties of the first video file that you drag to the Expert workspace Timeline. If your video's properties include a 16:9 flag, then the project settings will have a 16:9 flag (aspect ratio). If you do not want the project to set the project settings automatically, you can set the project settings yourself manually with File Menu/New/Project and then import your source video.
    If a problem exists where imported 16:9 video is presenting in Premiere Elements as 4:3 instead of 16:9 (typical of the JVC .mod file issue), then you can set the pixel aspect ratio under Interpret Footage feature inside the project workspace.
    At this point, I think it best for you to give more details and background behind your question so that we can be sure that we are giving you the information that you need to succeed in your projects.
    If you need clarification on anything written, please do not hesitate to ask for clarification.
    Thank you.
    ATR

  • Apple ID for my 9 year old - How can I set up an ID for my 9 years old. We have bought him an ITouch for his birthday, he also has a $30 iTunes card. To load up the iTunes card he needs an ID. When I try to set him up it says he is below the min age.

    How can I set up anApple ID for my 9 years old. Every time I try it tells me he is bolew the min age. If this is the case how can he download free games and how can he redeem his birthday $30 iTunes card? I dont want him to use my ID as it has my credit card details.
    I'm very fustrated with this as it seems the Apple kit is for 13 years and older only.
    Cheers
    Brad

    That's great your 9-yr-old is responsible enough to handle an iTouch!
    There's no way around the age limit. I suggest a family account that you, an adult, control.

Maybe you are looking for