Servlets and multiple JDBC connections...

Hi Guru's
I want to perform multiple JDBC queries simultaneously from my servlet. Let's say I have a connection pool containing JDBC connections. Now what I want to do is to use each of this connections simultaneously to perform queries in parallel.
What is the best way to do this??? create multiple threads, one for each query, and then collate results when all threads are finished???
Has anyone does this before or know of any links or samples which I can look at??
your help much appreciated...
Many Thanks

Thanks but further questions....
But take care:
multithreading might only work parallel if there are
multiple processors - otherwise the thread fragments
will be processed one after the other until they are
finished.I agree. My server has multiple processors hence multi-threading.
Why do you need to perform the queries
simultaneously?
wouldn't it work too when you perform the queries one
after the other?To speed up performance. Sequential processing is too slow at the moment.
Hope you don't try doing so inside one single
database...yes inside a single databse.
Do you have any links to sample example etc..??? Importantly are you aware of any issues when one does this type of multi-threading from servlet. i.e does it clash with servlet's threading model etc...
I am aware of how servlets multithread requests and am quite familiar with them. Just wanted some examples on multithreading JDBC connections from servlets and how I can wait for all threads to finish before collecting results....also wanted to make sure that there are no other issues....
further help will be much appreciated.....

Similar Messages

  • Multiple JDBC connection pools

    Hi
    I have WLI application ( 7.0 ) and another J2EE appliction configured on WLS (
    7.0 ). If I have multiple jdbc connection pools configured to access different
    ( or even the same ) databases, I am unable to get the connection to execute a
    sql query in the J2EE app. The connection pool gets initialized properly during
    the server startup and I can see them in the console but when I try to acquire
    a connection from the pool for execution of a jdbc stmt, I am unable to obtain
    a connection. Did any one succeed in configuring mulitple jdbc connection pools
    and WLI and another J2EE app to run together on WLS 7.0? Any suggestions are welcome.
    Thanks
    Sreeram

    Well ... It boiled down to ACLs.
    "Sreeram" <[email protected]> wrote:
    >
    Hi
    I have WLI application ( 7.0 ) and another J2EE appliction configured
    on WLS (
    7.0 ). If I have multiple jdbc connection pools configured to access
    different
    ( or even the same ) databases, I am unable to get the connection to
    execute a
    sql query in the J2EE app. The connection pool gets initialized properly
    during
    the server startup and I can see them in the console but when I try to
    acquire
    a connection from the pool for execution of a jdbc stmt, I am unable
    to obtain
    a connection. Did any one succeed in configuring mulitple jdbc connection
    pools
    and WLI and another J2EE app to run together on WLS 7.0? Any suggestions
    are welcome.
    Thanks
    Sreeram

  • Auto-Commit and Pooled JDBC Connections

    Forum Members,
    If I am using Oracle Pooled JDBC Connections in the OC4J container is auto-commit set to "true" by default?
    If I set auto-commit to "false" and then close the logical connection, when that connection is handed out again on a later call to getConnection(), is auto-commit automatically set back to "true"?
    Thanks,
    Richard

    Richard,
    Pardon me if I am stating the obvious, but you could test that in your code by invoking the getAutoCommit() method in interface java.sql.Connection.
    My experience (with OC4J stand-alone versions up to -- and including -- 10.1.2) is that the behaviour depends on which data source you have configured. For example, if you have defined an "ejb-location" attribute in your "data-sources.xml" file, and you use that as your JNDI lookup for your data source, then OC4J handles transactions and you shouldn't deal with "auto-commit" at all. See the following post for more details:
    Re: OC4J 10.1.3 Preview 4 - Global transaction active
    But if you have defined a "location" attribute and use that, then you do need to handle transactions explicitly.
    Hope this helps.
    Good Luck,
    Avi.

  • Issues with FIOS modem/router's wireless and multiple devices connected to the WLAN?

    I am an IT consultant who was assisting someone with getting some devices connected to the fios wireless router and adding a wireless print server so they could print wirelesly. 
    I was having difficulty with one of their systems that was connected prior to me going on site.
    It was having difficulty obtaining an IP from the WLAN, i tried reinstalling the adapter, removing stored wlan settings and setting it up again, etc.
    When it did obtain an IP it could not ping the router.
    I had left it suggesting that they replace the wireless adapter on that system.
    However they're saying that after they shut down one of their other devices that i had connected (a netbook), that this problematic system started working fine.
    It makes no sense that a wireless client would have an impact on another wireless client. We're only talking 4 total devices here, a netbook, a laptop, a wireless print server and a desktop in another area of the house that has a usb wireless adapter.
    Does anyone have any ideas on if Verizon's wireless built in to the fios modem/router just isn't too good to handle multiple wireless devices?
    After hearing this i was thinking they might have been better off configuring the fios router as a bridge and getting a better wireless router or shutting off the fios supplied wifi and implementing a wireless access point instead of using the router/modem that verizon provides.

    By bridge I mean in the sense you see some of the early DSL setups configured before they started using multiport routers -- essentially bridging the WAN MoCA port to the LAN ethernet.   The ActionTEC's won't do that.   This is what I think most are seeking to do when they want to turn the device into a "bridge" (essentially making the Verizon unit "transparent" to the communication which in this scenario it can't be).  You can do as suggested an turn the ActionTEC into essentially a "switch/bridge" that is only bridging the MoCA LAN and Ethernet LAN segments, but this then requires you to have an ethernet WAN feed from the ONT ... and as indicated, it is definitely not a "supported" configuration from Verizon (although there is nothing "wrong" with doing it this way if you are comfortable with networking and understanding the mechanics of all that is going on -- if not, sticking with a supported configuration is highly advisable).

  • MS Visual C++/Delphi 7 and multiple db connections/sessions

    I've been reviewing peformance problems with an app that was written in MS Visual C++/Delphi 7. It was originally written to use SQL Server but has since also been ported to run on Oracle. The problem (well, at least one of them) is that each screen can have multiple controls on it (various OCX's and the like) and when any of the controls needs to get data from the database, it opens its own connection. The C++ controls and the Delphi controls can't share a connection so the app will have to have at least two connections no matter what.
    But my question is, how do you create a single connection to the database and use it over and over again in the various controls without opening and closing it? I'm NOT a programmer with experience in these tools. I've been asked to review performance from an overall viewpoint and one of the big issues, as I see it, is the fact that one user could have 1-??? sessions open at any given time. It makes tracing a user's activity almost impossible (as sessions keep coming and going) and creates problems with transaction control, etc.
    Can anyone tell me a bit about if it's possible to create and use a single connection throughout the app for all the various different controls and if so, point me to a simple example?

    Assuming they're using ODBC, go into the ODBC Data Source Manager (from the Control Panel) and check to see whether the ODBC driver this app is using is set to pool connections. If it is, your application should be sharing connections. You may want to play with the pool timeout parameter, depending on how quickly your connections are being opened and closed.
    If it has 4 controls all simultaneously asking for their own connection, it will have 4 connections open. If control 2 doesn't open a connection until control 1 has closed its connection, you'd only have 1 connection open. Hopefully, though, the next screen that wants a number of connections will be able to utilize the connections that have already been opened and placed in the pool.
    Justin

  • Multiple JDBC Connections

    I am running net8 with oracle 8.1.7 on linux. I have an applet that connects to the database. I seem to lose my connection when another applet starts and connects to the database. Anyone know why I can't get more than one database connection?

    Are both applets running on the same machine? If so, are you sure you don't have some sort of singleton class so each applet is actually trying to share the connection?
    You might also check the SQL*Net logs for any error information.

  • Servlets and Persistent Database Connections

    I'm looking at building an application using
    java Servlets.
    My Application will consist of many individual Java Servlets.
    I want to ensure that there is a persistent database connection so that the users do not have to log on again when a page generated via Servlet1 contains a URL to Servlet2....
    null

    Look at the Http session class in the Servlet specification. It will maintain state for you across client requests.

  • New Fios G1100 and Multiple Xboxs Connected to xbox live issues.

    I just upgraded my router from the Actiontec MI424WR to the G1100. Now I am into an issue with Fios keeping a connection to xbox live on selected xbox devices. I have 3 xbox 360 and 2 xbox one connecting to the network. Both Xbox One maintain solid connection to live, but the 360 experience I have a totally different experience. My set up has 1 Xbox One Wired, 1 wireless. I have 2 xbox 360 wireless and 1 wired. I am also experiencing problems with one of my desktops which is wired that randomly loses a connection to internet. I been using this TRENDnet 8-Port 10/100Mbps GREENnet Switch (TE100-S80G) to help with wired connections. Both Xbox Ones on the network remain connected at all times, or at least I haven't seen a drop. My experience with my xbox 360s are completely different from my Xbox One.They all drop connection randomly every 5 to 20 min. I can immediately sign back in , but this continuosly happens. I was able to get one xbox 360 to maintain a continuous connection by putting it IP address and enabling DMZ on it. I have tried port forwarding but that doesn't work. Anybody have any suggestions or solution? Or should I just shipped back the G1100 and go back to Actiontec MI424WR.      

    Who is your ISP...?
    Are you getting any error message...?
    Try the following settings and check..
    Open the router setup page,On the set-up tab change the MTU Size to 1365 and click Save Settings...Click on "Administration" tab and disable the option UPnP and click Save Settings...
    Click on "Applications and Gaming" tab and then click on "Port Range Forwarding" subtab...
    1) On the first line in Application box type in ABC, in the start box type in 53 and End box type in 3074, leave the protocol as both and under ip address type in 192.168.1.20 and check the enable box, click Save Settings once done...
    2) Once you return to the set up page click on the Security tab and uncheck Block Anonymous Internet Requests and click on Save Settings...
    3)Click on the Status tab and take note of DNS1 and DNS2 Addresses...
    4) Goto the XBox Network Settings and IP Address Settings and select manual IP Settings and assign the following on your Xbox
    IP Address :- 192.168.1.20, Subnet Mask :- 255.255.255.0, Default Gateway :- 192.168.1.1...
    5) Also assign the DNS Addresses on the Xbox
    Use DNS1 and DNS2 Addresses you took note off of the router status tab as Primary DNS & Secondary DNS for the xbox...
    6) Turn off your modem, router, and Xbox...Wait for a minute...
    7) Plug the modem power first, wait for another minute and plug the router power cable, wait another minute and turn on the Xbox and test it...it will connect...

  • Establishing multiple WLEC connection pools

    Running WLS 6.0 communicating with WLE 4.2:
    I'm looking at setting up multiple connection pools to communicate with multiple
    WLE application domains.
    The code fragment below is from the BEA documentation and works fine if you know
    the domain(pool) name. My code uses the "lookup" method in the InitialContext
    class to get the pool name for single WLEC pool/domain configuration. Is there
    a method to return a list of domain(pool) names?
    Each WLEC connection pool has a Tobj_Bootstrap object that lets you access the
    associated WLE domain. The WLEC component provides an object called BootstrapFactory
    which provides access to the Tobj_Bootstrap object for a particular WLE domain.
    Include the following code in your WebLogic Server client to connect to a WLE
    domain:
    Tobj_Bootstrap myBootstrap = Tobj_BootstrapFactory.getClientContext("myPool");
    where
    The getClientContext() method returns the Tobj_Bootstrap object that is associated
    with myPool. If getClientContext() cannot find a WLEC connection pool with this
    name, it returns null.
    myPool is the name of a WLEC connection pool for the desired WLE domain. This
    WLEC connection pool needs to be defined in the Administration Console.

    Well ... It boiled down to ACLs.
    "Sreeram" <[email protected]> wrote:
    >
    Hi
    I have WLI application ( 7.0 ) and another J2EE appliction configured
    on WLS (
    7.0 ). If I have multiple jdbc connection pools configured to access
    different
    ( or even the same ) databases, I am unable to get the connection to
    execute a
    sql query in the J2EE app. The connection pool gets initialized properly
    during
    the server startup and I can see them in the console but when I try to
    acquire
    a connection from the pool for execution of a jdbc stmt, I am unable
    to obtain
    a connection. Did any one succeed in configuring mulitple jdbc connection
    pools
    and WLI and another J2EE app to run together on WLS 7.0? Any suggestions
    are welcome.
    Thanks
    Sreeram

  • Can not deploy a report using JDBC connection on CR2008 Server

    Hi Group,
    I have a report created with JDBC connection. When I tried to add it to CR2008 server, it gives an error - "An unexpected error has occurred ". Basically I want to add a report to a public folder via CMC. I am using adminstrator account.
    Then I thought I need to add JDBC driver into CR2008 server. so I put oracle jdbc jar into CR2008 server classpath and add JDBC connection info into CRConfig.xml. but I still got the same error.
    I also tried:
    - Change the report to use native Oracle driver rather than JDBC. The deployment succeeded (but this is not what I want)
    - Add a data source connection via Business View Manager, but no luck.
    I know how to use/change jdbc connection with programtic way, but I just want to know if I want to use built-in components in CR2008 server without any coding the reports can be deployed and managed.
    Thanks in advance.
    Dennis

    Hello Will,
    Crystal Reports supports connections to JDBC/JNDI out of the box, and have done so for a while, whether stand-alone or published to Enterprise.
    To specify where the server would search for the JDBC driver jar files, you'd change the classpath tag found in the CRConfig.xml file found on the machine where the Crystal Reports Page or Job Server is running. 
    For early Crystal Enterprise 10 and before, it used Java Native Interface (JNI) to start the Java process to retrieve the data from the JDBC connection.
    For later Crystal Enterprise 10 and later, it starts off a "Java Server" process, and communicates to the Crystal Reports process via CORBA TCP/IP connection.
    Commonissues that may arise:  (1) CRConfig.xml not configured properly, (2) unable to start or communicate to the "Java Server" because of permissions or firewall.
    Note that this is a separate connectivity map from using ADO or ADO.NET.
    Sincerely,
    Ted Ueda

  • Total JDBC Connections

    I have deployed an application to Apps Server 9.0.4.
    I am using oracle.jdbc.pool.OracleConnectionPoolDataSource. I have closed all the connections, however Open JDBC Connections is always 0 and Total JDBC Connections is increasing.
    My inactivity time out is 60 seconds.
    Is this normal or something wrong somewhere?
    Any help is highly appreciable.
    Thanks

    The Total number of connections figure indicates the total number of connections that have been opened since OC4J was started.
    The Open number of connections figure indicates the total number of connections currently open.
    Since you say that the open connections figure stays below 10, this suggests that you do not have a connection leak, but your inactivity time out is too low, and therefore your connections are being closed before they can be reused - hence the large total number of connections.
    Good luck.

  • JBO-3003 Application pool, Error JDBC connection

    Hi, I'm trying to run a simple webapp but get this error:
    JBO-30003: The application pool (model.RoomReservationsAppModuleLocal) failed to checkout an application module due to the following exception:
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.DMLException, msg=JBO-26061: Error while opening JDBC connection.
    Anyone know what to do?
    Regards ,
    Ketil
    I

    Hi Erik,
    The solution of having the two root ApplicationModules share a single JDBC connection violates some assumptions of the BC4J architecture and could result in some strange race conditions in JDBC.
    We should focus your solution on how the panels are released. It ought to be possible to release the BindingContainer for the panel without releasing the underlying DataControl. With this solution you would only require one root ApplicationModule and one JDBC connection.
    How are you releasing the ADF and BC4J references when you close the panel? I would expect you to be invoking release on the DCBindingContainer instance only. If you are already doing this then what is causing the commit/rollback?
    Hope this helps,
    JR

  • Local only connection on multiple wirelesss connections

    I've seen several posts to this affect, but no resolutions.  I have a WRT110, one wired connection which works fine and multiple wireless connections.  Only one wireless connection can be active at a time.  If connection A is active, and connection B comes on-line, connection B takes the internet connection and connection A is left as Local Access Only (but still connected to the router).  After connection B goes off-line, connection A can reestablish internet connectivity after a short period of time.
    Any thoughts? 

    I would suggest you to readjust the wireless settings of the router...On the Linksys Setup Page try doing the following settings.
    Under the Wireless tab..
    - Set the Radio Band to Standard-20MHz and change the Standard channel to 11-2.462GHz
    Under Advance Wireless tab..
    - Change the Beacon Interval to 75,Change the Fragmentation Threshold to 2304,Change the RTS Threshold to 2304.
    Now,try to connect both the laptop...

  • JDBC Connection Encoding

    i have oracle database server with NLS_CHARACTERSET=AR8ISO8859P6 (ISO-8859-6)
    and my jdbc connection is
    public sqlj.runtime.ref.DefaultContext getConnectionContext() throws SQLException
    Properties props = new Properties();
    props.put("charSet","ISO-8859-6");
    props.put("user","oasis");
    props.put("password","*****");
    return Oracle.getConnection("jdbc:oracle:thin:@128.55.0.11:1521:dvlp320t",props);
    when i retrieve String attribute it appear as ???
    what is the problem?

    Try asking on the JDBC forum

  • Servlets/JDBC - Connect to database ONCE and not in every servlet - How?

    Hello, I'm using servlets and JDBC.
    In every servlet , i connect to the database and then i close the connection, but this is not ptactical.
    I would like to connect to the database once (at the beginning) when container starts and then close the connection.
    How am i supposed to do that?
    Thanks, in advance!

    Bad idea. Don't do that. The connection will timeout sooner or later (depends on DB used, it's usually around 30 mins) and your application will crash.
    You should always acquire and close the connection (and statement and resultset!) in the shortest possible scope. To improve connecting performance just use connection pooling.
    Create a DAO class which does all the task and just instantiate and assign it as Servlet class variable during Servlet's init() method. For more insights and code samples start here: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    To go back to your fundamental question, doing some stuff during startup and shutdown of webapp, you could use the ServletContextListener for this. But again, do NOT do this to get hold of an external resource such as a connection! It's receipt for trouble.

Maybe you are looking for

  • Lost photos / camera roll after restore and update.

    As the title says , I recently had to restore my iphone 3gs due to having problems with MAIL (problem fixed now.) but after doing a full backup and restore on the phone and update to the iOS 4 ( i think>) , I lost all of the photos that I had in the

  • Insert data into oracle based on sql server data(here sql server acting as source to oracle and destination to oracle)

    Source is Oralce. Destination is SQL Server. Requirement - I have to fetch sql server server data (empid's) based emp table  and send this as input data to oracle to fetch and empid's are common. I cannot use merge or loopkup or for each as oracle ha

  • Error when trying to print...

    i just set up a dual 800 quicksilver with 10.4.4 server and have a hp 7130 all-in-one plugged in via USB. I started the print server with no problems, and can add the printer as a shared printer on an ibook. but when i try to print on the ibook it ta

  • 3.12 post element text appearing on new line

    I have an icon and some javaScript behind it to clear the content of the item, which on moving to 3.12 is moved onto the next line: http://apex.oracle.com/pls/otn/f?p=41395:10 Is there a simple way of avoiding this please so that it all appears on th

  • DVDs created in Elements 8 do not work on standalone players

    Hi, I've been using Elements 7 on Windows 7 before Elements 8 was released. The source of video is a SD HDD-camcorder and for all the projects I created 4.7 gb dvd-folders, then using a seperate dvd-writing software to burn to discs. Now since Elemen