Big headache with URL connection

Hi, guys.
i wrote an applet that measures response time of some html components, like gifs! The applet should return this wasted time by the actionperform method be executed, since this method opens a url connection with a html component. So it might return the final response time, but the result is always 0 !!! Please, could anybody help me?
Regards Euclides.
public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
long valor;
Integer valornovo;
String valor1,tam1,tarefa1;
JTextField aux;
tam1 = (String)ivjJComboBox1.getSelectedItem();
tarefa1 = (String)ivjJComboBox2.getSelectedItem();
valor = mandabala(tam1,tarefa1);
valor1 = Long.toString(valor);
//delayField = new JTextField(Long.toString(delay), 6);
//valor1 = Long.toString(valor);
ivjJTextField1.setEnabled( true );
ivjJTextField1.setText(valor1);
validate();
public long mandabala(String param, String param1) {
long time;
long time1;
BufferedInputStream in;
java.net.HttpURLConnection conn;
java.net.URL url;
url = null;
if (param == "100")
byte[] buffer = new byte[99990000];
try {
url = new java.net.URL("http://10.0.135.15/teste.gif");
// url = constructURL("http://10.0.135.15/performance/teste.gif");
conn = (HttpURLConnection)url.openConnection();
time = System.currentTimeMillis();
//conn("http://www.dataprev.gov.br/performance/teste.gif");
//conn("http://10.0.135.15/performance/teste.gif");
conn.connect();
time1 = System.currentTimeMillis();
in = new BufferedInputStream(conn.getInputStream());
int x = 0;
while((x = in.read(buffer))!=-1)
timedif = System.currentTimeMillis() - time;
in.close();
catch(Exception e) {
System.out.println("Erro de conexao");

I read it really quickly, so I apologize if you've checked this already...
Your while loop is not executing the statement you are using to compute the timediff variable. The while loop in.read() method returns with a value of say '63000' when the .gif file is read. Since 63000!=-1 the loop exits immediately without executing the statement (System.currentTime()) in the middle.
To correct this, you should do the following.
long timediff=0;
long starttime=System.currentTimeInMillis();
int character=0;
while( (character=in.read()) != -1 );
timediff = System.currentTimeINMillis() - starttime;
//return timediff;

Similar Messages

  • Big headache with ActionPerform control

    Hi, guys.
    i wrote an applet that measures response time of some html components, like gifs! The applet should return this wasted time by the actionperform method be executed, since this method opens a url connection with a html component. So it might return the final response time, but the result is always 0 !!! Please, could anybody help me?
    Regards Euclides.
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
         long valor;
         Integer valornovo;
    String valor1,tam1,tarefa1;
    JTextField aux;
         tam1 = (String)ivjJComboBox1.getSelectedItem();
         tarefa1 = (String)ivjJComboBox2.getSelectedItem();
         valor = mandabala(tam1,tarefa1);
         valor1 = Long.toString(valor);
         //delayField = new JTextField(Long.toString(delay), 6);
         //valor1 = Long.toString(valor);
         ivjJTextField1.setEnabled( true );
         ivjJTextField1.setText(valor1);
         validate();
    public long mandabala(String param, String param1) {
         long time;
         long time1;
         BufferedInputStream in;
         java.net.HttpURLConnection conn;
         java.net.URL url;
         url = null;
         if (param == "100")
              byte[] buffer = new byte[99990000];
              try {
                        url = new java.net.URL("http://10.0.135.15/teste.gif");
                   // url = constructURL("http://10.0.135.15/performance/teste.gif");
                   conn = (HttpURLConnection)url.openConnection();
                        time = System.currentTimeMillis();
                        //conn("http://www.dataprev.gov.br/performance/teste.gif");
                        //conn("http://10.0.135.15/performance/teste.gif");
                        conn.connect();
                        time1 = System.currentTimeMillis();
                        in = new BufferedInputStream(conn.getInputStream());
                        int x = 0;
                        while((x = in.read(buffer))!=-1)
              timedif = System.currentTimeMillis() - time;
                        in.close();
              catch(Exception e) {
                                       System.out.println("Erro de conexao");
                   

    I did the best thing, i guess: i have taken the "if combobox" command away from the source code and then, i runned the test again. The problem stopped, so my problem relates with combobox object! IAM NOT USING THE ITEMLISTENER INTERFACE! Show i use it?
    Thanks again, Euclides.

  • Big Headache with N70 and nokia maps

    I have recently come accross nokia maps and i think it is such an excelent idea. But when i was following the steps on how to get downloaded maps on to my n70 i hit a big brick wall. Suposedly i need to put my phone into data mode, and as i have found that is not an option. I also know that i would work if i had a mmc card reader. unfortunately i dont.
    so is there any type of work around for this problem.
    plz help as i am not the only 1 with this problem

    or even better intergrate this into pc suit so that no matter how it is connected. you will always be able to use maps. Nokia have an excelent idea here but they havn't quite got it right. SO TO THE NOKIA PEOPLE OUT THERE, ANSWER THE EMAILS I SENT YOU OR POST SOMETHING ON THIS TOPIC plz

  • BIG problem with digital connect

    I need help!!
    I have logitech z5500 digital and x-fi extreme music and I can't find a way to connect them digitaly. I use optical cable 3.5mm to opt and when they are connected speakers screen says (no digital data) and there is no sound. This is sp/dif so why isn't it working?Please help,which cable shoul'd I use?

    You're not alone... https://discussions.apple.com/thread/3391947?tstart=0

  • Screen freezes with message ' connecting url' when  I attempt to go to itunes store

    screen freezes with message ' connecting url' when  I attempt to go to itunes store. windows 7 64 bit.

    Hey there Dan256162,
    I understand that you are receiving a specific error code when attempting to connect to the iTunes Store, error 0x80090318. I have an article for you that references this code and links you to another article for troubleshooting to address this issue. Here is the article that references the error code:
    iTunes: Possible iTunes Store errors - Apple Support
    http://support.apple.com/en-us/HT203174
    And here is the linked troubleshooting article that will help you resolve the issue:
    Apple software on Windows: May see performance issues and blank iTunes Store - Apple Support
    http://support.apple.com/en-us/TS4123
    Take care, and thanks for visiting the Apple Support Communities.
    Cheers,
    Braden

  • Big problem with Nokia E60 and EAP-PEAP connection

    At our University we have Wlan now.
    The Lan based on the standart 802.11 b/g with 54 Mbit/s
    The Authentifikation based on the standart 802.1x (Peap) with the connection WPA/TKIP.
    My Firmware:
    V3.0633.09.04
    20-11-06
    RM-49
    Nokia E60
    My Configuration:
    Connection Name: FH-Hof
    Data Bearer:Wireless LAN
    WLAN netw.Name: FHHof
    Network status: Hidden
    WLAN netw.mode: Infrastructure
    WLAN security Mode: WPA/WPA2
    WLAN security settings:
    WPA mode: EAP
    TKIP-Security: allowed
    EAP plugin settings:EAP-PEAP
    User Cert: not defined
    CA Cert: CA-FH-Hof
    username in use: User configured
    username: aschmidt
    real in use: user configured
    realm: FH-Hof
    Allow PEAPv0: yes
    Yes for v1 and v2
    EAP: EAP-mschapv2
    Username: aschmidt
    prompt password: Yes
    password: entered my password
    Extended Settings:
    IPv4-Settings: No Changes
    IPv6-Settings: No Changes
    Proxserver-Address: proxy.fh-hof.de
    Prxy-Port-Number: 3128
    If I started to try the connection I have to enter my Username and my password. After that the handy asked me about my username and password again after a time.
    Now it takes circa one minute and the connection failed.
    The Error-Message ist: No Connection! WPA authentification failed.
    My´account is not blocked.
    Have I to enter any Ciphers?
    Thanks for every help and sorry for my bad English!
    EDIT: Removed non english linkMessage Edited by sailer_one on 27-Apr-200710:07 AM
    Message Edited by sailer_one on 27-Apr-200710:07 AM
    Message Edited by sailer_one on 27-Apr-200710:12 AM
    Message Edited by ajak on 27-Apr-2007 10:21 AM

    also try change "WLAN security Mode" from WPA to 802.1x
    I think Nokia referrs to WPA as WPA-PSK, but when you say TKIP then it also could be 802.1x as TKIP is the encryption used.
    So infact your wireless domain might be a 802.1x/EAP-PEAP/MS-CHAPv2 network.Message Edited by mbil on 30-Apr-200702:58 PM

  • Change url connection to socket

    hello i have a problem about a socket connection can you help me
    i want to change url connection to socket connection
    here is
              java.net.URL url = new java.net.URL("http://64.74.75.74/approot/webapp/ZOR/bare");
              connection = new sun.net.www.protocol.http.HttpURLConnection(url, " ", 0);
              connection.setRequestMethod("POST");
              connection.setDoInput(true);
              connection.setDoOutput(true);
              connection.setUseCaches(false);
              java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(connection.getOutputStream());
              out.writeObject(getTextFieldGiden().getText());
              out.flush();
              out.close();
              return (String) (new java.io.ObjectInputStream(connection.getInputStream()).readObject());how can i change it to
    socket connection because i must write it in c++
    thank you very much

    why are you replaying if you don' t have a solution peter?
    i have a big c++ project and in it somewhere must do the job the code i send in java do.
    İ also want to say i dont want it's c++ code ,i want to know how it can be with java sockets.

  • IIS Reverse Proxy with URL rewrite.

    Hi all, hoping to leverage the wealth of knowledge contained here.
    Any assistance would be very welcome.
    I'm having an issue getting a reverse proxy and URL rewrite working in IIS 7.0.
    I need to redirect all requests with a specific virtual directory suffix only.
    ie; https://domain.test.com/outbound/Content/query_etc
    With /Outbound/ being the trigger.
    This should be redirected to http://10.10.10.10/inbound/Content/query_etc
    While at the same time, requests without the /outbound/ suffix should be handled locally.
    I have configured the reverse proxy as described in a few articles, and have had no luck.
    Here's a snippet from my (sanitized) web.config at the site level.
    <rewrite>
    <outboundRules>
    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
    <match filterByTags="A" pattern="^http(s)?://10.10.10.10/inbound/(.*)" />
    <action type="Rewrite" value="https://domain.test.com/outbound/{R:2}" />
    </rule>
    <preConditions>
    <preCondition name="ResponseIsHtml1">
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
    </preConditions>
    </outboundRules>
    <rules>
    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="^outbound/(.*)" />
    <action type="Rewrite" url="http://10.10.10.10/inbound/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
    </rule>
    </rules>
    </rewrite>
    To me, this looks correct, yet it doesn't work.
    With this, I get the normal 404 - Error Code 0x80070002, with the text indicating the local directory doesn't exist, so.... not being picked up by the filter for redirection.

    Hi Andrew,
    Looking at your requirements it appears you need Reverse Proxy To Another Site/Server.
    By using URL Rewrite Module together with
    Application Request Routing module you can have IIS 7 act as a
    reverse proxy.
    It seems like URL Rewrite can't re-route the request somewhere else out of the server.
    Even when you rewrite the url the actual connection remains with the server. Hence if your original server doesn't have /inbound/Content/query_etc  it will fail with 404.
    Hosting multiple domain names under a single account using URL Rewrite.
    It’s a common desire to have a single IIS website that handles multiple sites with different domain names.
    References:
    How to create a url alias using IIS URL Rewrite:
    http://blogs.technet.com/b/mspfe/archive/2013/11/27/how-to-create-a-url-alias-using-iis-url-rewrite.aspx
    Reverse Proxy with URL Rewrite v2 and Application Request Routing:
    http://www.iis.net/learn/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing
    Regards,
    Satyajit
    Please“Vote As Helpful”
    if you find my contribution useful or “MarkAs Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Issues with my connection when gaming (Insurgency)

    Hello,
    I just bought the MSI GT72 2QE. I am very pleased with de specs like the Geforce GTX 980m and the i4710hq but there is an issue that is bothering me some days now. When i am playing my beloved game Insurgency, i get ping spikes all the time. So i followed up some instruction on uninstalling the Killer software suite and just installing the drivers when i encountered the next problem. My Killer Wireless-n/a/ac 1525 Wireless Network Adapter couldn't find the drivers in the 'drivers only' package. But i did my best to find other drivers and accomplished after 5 hours full of frustration. So that is done but still doesn't solve my problem.
    I don't know what to do anymore and I'm starting to think that maybe my Killer Wireless-n/a/ac 1525 Wireless Network Adapter is the issue. Maybe this is a hardware issue. I contacted the store where i bought it and they will contact me in 48 hours with a possible solution but the guy said that after all my effort it seems like a hardware issue indeed. You guys are my last hope or my laptop will be gone for 3 weeks at the factory.
    Video of ping:
    nl.tinypic.com/r/ztisd1/8
    I hope someone has the solution.
    Excuse me for my incorrect English, it's not my native language.
    Bye!

    Thanks for your reply.
    I'm glad (and I'm not glad for the others..) that I'm not the only one. But it's not because there are more devices connected to my router because I am the only one now and I'm still having this problem while my other laptop doesn't have any problems at all. I've tried everything so far now. Resetting my router, restarting my router, reinstalled windows, reinstalled drivers, got rid of the software suite, turned off firewalls, virusscanners etc. Everything.
    I thought it was only with Insurgency but it's also bugging me with Battlefield 4.
    So i have tried and done everything i could find on every forum on the internet. Still I don't get the download/upload/connection I am used to when using wireless. When i am in my room, which is 10m away from the wireless router, my download speed is max 1200 kb/s where I would easily get 2300 kb/s. Also when playing online games I am having big issues with my latency/ping. It goes from 60 to 200 to 400 and back every 15/20 seconds. I also own a Asus laptop and I don't have any issues at all with the wireless connection. When I am in my room there are no problems at all. I am starting to think that the Killer Wireless adapter is just a f*cked up thing. I bought a laptop (GT72 with 980m) for €2300 but I am having all these issues with the connection. It makes me really frustrated.
    Longer vid of ingame netgraph:
    nl.tinypic.com/r/97mjae/8
    I am hoping that there is something that solves my issues. I'm starting to think that another wireless network adapter from another brand is the only option. Is there an option to change the wireless network adapter on my laptop because I will if I can. This piece of sh*t needs to be replaced.
    Bye

  • Issues with JDBC Connection Pooling

    Hi all,
    I'm experiencing some unexpected behaviour when trying to use JDBC Connection Pooling with my BC4J applications.
    The configuraiton is -
    Web Application using BC4J in local mode
    Using Default Connection Stagegy
    Stateless Release Mode
    Retrieving Application Modules using Configuration.createRootApplicationModule( am , cf );
    Returning Application Modules using Configuration.releaseRootApplicationModule( am, false );
    Three application modules
    AppModuleA - connects to DatabaseConnection1
    AppModuleB - connects to DatabaseConnection2
    AppModuleC - connects to DatabaseConnection2
    My requirement is to -
    Use App Module Pooling and have individual pool for each Application Module
    Use JDBC Pooling and have individual pool for each Database connection
    Note: All configuration was achieved in design mode (i.e. right clicking AppModule->Configurations...)
    1. Initial approach -
    In the configuration for each Application Module I specified the connection type as 'JDBC Datasource' and specified to approriate datasource.
    Tried setting doConnecitonPooling to 'true' as well as 'false'
    In the data-sources.xml I specified all the appropriate info including min-connections and max-connections.
    I would expect, with the above config that BC4J would use OC4J's built in JDBC connection pooling.
    2. Second approach -
    In the configuration for each Application Module I specified the connection type as JDBC URL.
    In the configuration I specified doConnectionPooling = 'true' as well as the max connection, max available and min available
    What I experienced in both cases was that the max connections seem to be ignored as the number of connection as reported by the database (v$session) was exceeded by more than 10.
    In addition to this once the load was removed the number of JDBC connecitons did not drop (I would have expected it to drop to max available connections)
    My questions are -
    1. When specifying to use a 'JDBC Datasource' style of connection, is it in fact OC4J that is then responsible for pooling JDBC connections? And in this case should BC4J's doConnectionPooling parameter be set to true or false?
    2. Are there any known issues with the use of the JDBC Conneciton Pool as stated by the above to approaches?

    Thanks for the additional info. Please see my comments. below.
    Sorry should have been more specififc -
    1. Is each application pool using a different JDBC user? You mentioned DatabaseConnection1 and DatabaseConnection2
    above; are these connections to different schemas / users? If so, BC4J will create a separate connection pool for each
    JDBC user. Each connection pool will have its own maximum pool size.
    Each 'DatabaseConnection' refers to a different database, actually hosted on a seperate physical server, different
    schema and different user.BC4J will maintain a separate connection pool for each permutation of JDBC URL / schema. If each user is connecting
    to a different DB instance then I would expect no greater than 10 DB sessions. However, if a DB instance is hosting
    more than user then I would expect greater than 10 DB sessions (though still no more than 10 DB sessions per user).
    2. Are all the v$session sessions related to the JDBC clients? There should be at least one additional database
    session which will be related to the session that is querying v$session.
    When querying the v$session table I specifically look for connections from the user in quesiton and from the machine
    name in question and in doing so eliminate the database system's connections, as well as the query tools'
    connection. One area I'm not sure about is the connection BC4J uses to write to its temporary tables. I am using
    Stateless release mode and have not explicetly stated to save to the database but I'm wondering if it still does if so
    and how does it come into the equation with max connections?BC4J's internal connections are also pooled and the limits apply as mentioned above. So, if you have specified
    internal connection info for a schema which is different than the users above I would expect the additional conns.
    One helpful diagnostic tool, albeit programmatic, might be to print the information about the connection pools after
    your test client(s) have finished. This may be accomplished as follows:
    // get a reference to the BC4J connection pool manager
    import oracle.jbo.server.ConnectionPoolManagerFactory;
    import oracle.jbo.server.ConnectionPoolManagerImpl;
    import oracle.jbo.pool.ResourcePool;
    import java.io.PrintWriter;
    import java.util.Enumeration;
    // get the ConnectionPoolManager. assume that it is an instance of the supplied manager
    ConnectionPoolManagerImpl mgr = (ConnectionPoolManagerImpl)ConnectionPoolManagerFactory.getConnectionPoolManager();
    Enumeration keys = mgr.getResourcePoolKeys();
    PrintWriter pw = new PrintWriter(System.out, true);
    while (keys.hasMoreElements())
    Object key = keys.nextElement();
    ResourcePool pool = (ResourcePool)mgr.getResourcePool(key);
    System.out.println("Dumping pool statistics for pool: " + key);
    pool.dumpPoolStatistics(pw);
    }

  • On certain pages, a big circle with an arrow inside it takes the foreground in the bottom left corner, and I can't get rid of it.

    This image is something new on my screen, probably since the last Fx update or so.
    I think this big-circle-with-an-arrow-inside may be a sign indicating that I need to download something, or that something is available for download. I see it on sites featuring various media, such as on some of Amazon's digital music pages and also on some of IMDb's pages.
    Further regarding any downloads, I don't know if this circle refers to a plugin, or a media file, or if, in fact, either.
    I have no idea what the circle with an arrow is trying to tell me, nor do I know how to get rid of it. It takes over the forefround of the corners where it resides, rendering any links beneath it inoperable. At the very least, I would just like to make it go away.
    Thanks for any help you may offer :-)

    Thanks for your interest in my problem. I'm sending along a screenshot.
    FYI, when I tapped on the arrow, a new tab opened at the following location:
    chrome://fvd.single/content/fennec_streams_list.html?url=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fdmusic%2Fcloudplayer%2Fplayer%3Fie%3DUTF8%26ref_%3Dnav_youraccount_cldplyr%23searchSongs%2FsearchTerm%3Dgood%2Bvibrations
    The page at this address is empty (all white) except for a small blue bar in the upper right corner that says "Download 5.3 1MB."
    Again, my thanks.

  • Time Machine, Migration Assistant, and a BIG headache

    Set up my new rMBP from a time machine backup on external and worked great. I removed some applications from the dock that didn't transfer over successfully (i.e. Word 2004). I didn't include iTunes during the transfer.  Once time machine restore was complete, everything on the rMBP worked great.  I wanted to get my iTunes from the external and so I used the Migration Assistant to copy over JUST the music.  I unchecked all the boxes except Music.  Took over 1 hour just to copy over 30GB of music and so I was suspicious...
    After completion, I see that it copied over my music, BUT
         - all Documents gone
         - applications previously deleted WERE BACK (i.e. Word 2004)
    Went back to my old 2010 MBP to do another time machine backup, and signed into Mail....
    Signed into Mail on the rMBP....
    Got an email that my apple ID was used to sign into iCloud....
    Then now rMBP Mail can't access ANY of my email accounts....
    What in the world happened?  I just wanted to copy over my Music and now it's a BIG headache.....
    I knew I should have avoided Migration Assistant and should have transferred over Music upon initial setup of the rMBP....
    Tried to restore the rMBP from time machine but cannot b/c the time machine backup was done under snow leopard....
    So uninstalled Mavericks and reinstalling....1 hour wait to download...
    Then (hopefully) will restore from time machine (make sure to include Music this time)....which takes about 2 hours....
    So 3 hours just to get Music, when it should just be a simple copy/paste job....
    On the bright side, I got a Samsung display and so I'm happy with that...the display is sharp, evenly bright, and no creaking case

    Hey hp12c,
    Thanks for the question. The following article may provide the information you are looking for:
    Mac Basics: Time Machine
    http://support.apple.com/kb/HT1427
    Restoring specific files or folders
    Choose Enter Time Machine from the Time Machine menu and the restore interface appears. You can literally see your windows as they appeared "back in time."
    You can use the timeline on the right side of the window to reach a certain point back in time (the timeline shows the times of all backups on your backup drive). If you don’t know exactly when you deleted or changed a file, you can use the back arrow to let Time Machine automatically travel through time to show you when that folder last changed.
    Note: Dates in pink indicate the data resides on your Time Machine backup device. Dates in white indicate the data resides on your Mac. In OS X Mountain Lion and Lion, portable Macs have the feature of local snapshots. See this article for details.
    You can also perform a Spotlight search in the Time Machine Finder Window search field to find a file. Simply type the Spotlight search field and use the back arrow to have Time Machine search through your backups to find what you are looking for.
    Before you restore a file, you can also use Quick Look to preview a file to make sure its the one you want. Highlight the file and press the Space Bar to bring up a quick look.
    To restore, select the file/folder and click the "Restore" button. The file will automatically be copied to the desktop or appropriate folder.  If the file you are restoring has another file in the same location with the same name, you will be prompted to choose which file to keep or keep both.
    Thanks,
    Matt M.

  • TS1398 I have the ipad retina display version - I have a BIG issue with this when out and about that on about 50% of the time will it see my HTC mobile WiFi hotspot - rebooting either, or both devices doesn't cure the problem it drives me MAD!!!!

    I have the ipad retina display version - I have a BIG issue with this when out and about, that only about 50% of the time will it see my HTC mobile WiFi hotspot - rebooting either, or both devices doesn't cure the problem it drives me MAD!!!!
    The HTC hotspot works fine with everything else I connect to it.
    Also - ipad will not connect to my HTC via bluetooth. Again, I can connect to everything else with my HTC other than my ipad.
    I have to say this is my first venture into Apple products and I have always wanted to get away from my windows based laptop to get a MacBook, the problems I have had (flash player etc) & continue to have (as above) are putting me right off swapping over. I HATE technology that doesn't work and my ipad has been hard work!

    I stated my ipad as being an ipad2, but I now think it is a 3??? It was new Jan this year and is the 64gb retina display version.
    I really would like to get to the bottom on this problem wit mobile hotspots as it is sitting on my desk next to me now and I cannot get it to connect to my HTC mobile hotspot!!!! It might be taking a flying lesson soon at this rate!!! Grrrrrrr...........

  • Problem with creating Connection pool and JNDI, driver is not detected

    Hi,
    I have an issue with creating Connection Pool and JNDI.
    I'm using:
    - JDK 1.6
    - OS: Linux(ubuntu 8.10)
    - Netbeans IDE 6.5.1
    - Java EE 5.0
    - Apache Tomcat 6.0.18 Its lib directory contains all necessary jar files for Oracle database driver
    - Oracle 11g Enterprise
    My problem is that the Oracle database driver is not detected when I want to create a pool (it works pretty well and is detected without any problem when I create ordinary connection by DriverManager)
    Therefore after running:
    InitialContext ic = new InitialContext();
    Context context = (Context)ic.lookup("java:comp/env");
    DataSource dataSource = (DataSource)context.lookup("jdbc/oracle11g");
    Connection connection = dataSource.getConnection();and right after dataSource.getConnection() I have the following exception:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at servlets.Servlet1.doPost(Servlet1.java:47)
    at servlets.Servlet1.doGet(Servlet1.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
    ... 17 more
    My application context file (context.xml) is:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/WebApplication3">
      <Resource auth="Container"
                      driverClassName="oracle.jdbc.OracleDriver"
                      maxActive="8"
                      maxIdle="4"
                      name="jdbc/oracle11g"
                      username="scott"
                      password="tiger"
                      type="javax.sql.DataSource"
                      url="jdbc:oracle:thin:@localhost:1521:database01" />
    </Context>and my web.xml is:
        <resource-ref>
            <description>Oracle Datasource example</description>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
    ...I found similar threads in different forums including sun, such as
    http://forums.sun.com/thread.jspa?threadID=567630&start=0&tstart=0
    http://forums.sun.com/thread.jspa?threadID=639243&tstart=0
    http://forums.sun.com/thread.jspa?threadID=5312178&tstart=0
    , but no solution.
    As many suggest, I also tried to put context directly in the server.xml (instead of my application context) and referencing it by <ResourceLink /> inside my application context but it didn't work and instead it gave me the following message:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '   ' for connect URL 'null'
    Has anyone succeeded in creating a connection pool with JNDI by using Tomcat 6 or higher ? If yes, could kindly explain about the applied method.
    Regards,

    Hello again,
    Finally I managed to run my application also with Tomcat 6.0.18. There was only two lines that had to be modified
    in the context.xml file (the context of my application project and not server's)
    Instead of writing
    <Context antiJARLocking="true" path="/WebApplication2">
        type="javax.sql.DataSource"
        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    </Context>we had to write:
    <Context antiJARLocking="true" path="/WebApplication2">
        type="oracle.jdbc.pool.OracleDataSource"
        factory="oracle.jdbc.pool.OracleDataSourceFactory"
    </Context>- No modification was needed to be done at server level (niether server.xml nor server context.xml)
    - I just added the ojdbc6.jar in $CATALINA_HOME/lib (I didn't even need to add it in WEB-INF/lib of my project)
    - The servlet used to do the test was the same that I presented in my precedent post.
    For those who have encountered my problem and are interested in the format of the web.xml and context.xml
    with Tomcat 6.0, you can find them below:
    Oracle server: Oracle 11g Enterprise
    Tomcat server version: 6.0.18
    Oracle driver: ojdbc.jar
    IDE: Netbeans 6.5.1
    The context.xml file of the web application
    <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/WebApplication2">
        <Resource name="jdbc/oracle11g"
                  type="oracle.jdbc.pool.OracleDataSource"
                  factory="oracle.jdbc.pool.OracleDataSourceFactory"
                  url="jdbc:oracle:thin:@localhost:1521:database01"
                  driverClassName="oracle.jdbc.OracleDriver"
                  userName="scott"
                  password="tiger"
                  auth="Container"
                  maxActive="100"
                  maxIdle="30"
                  maxWait="10000"
                  logAbandoned="true"
                  removeAbandoned="true"
                  removeAbandonedTimeout="60" />
    </Context>The web.xml of my web application
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <resource-ref>
            <description>Oracle Database 11g DataSource</description>
            <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
            <res-auth>Container</res-auth>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
        </resource-ref>
        <servlet>
            <servlet-name>Servlet1</servlet-name>
            <servlet-class>servlets.Servlet1</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Servlet1</servlet-name>
            <url-pattern>/Servlet1</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>Ok, now I'm happy as the original problem is completely solved
    Regards

  • Problem with JBDC connection to mysql in tomcat

    hi ,
    can anyone plz help me?..
    iam new to JSP. iam trying to impelement a application in JSP with JDBC connection using tomcat. Database is MYSQL .
    iam getting the following error:
    org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Server connection failure during transaction.
    Attempted reconnect 3 times. Giving up.)"
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Server connection failure during transaction.
    Attempted reconnect 3 times. Giving up.)"
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:81)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    THIS IS MY APPLICATION:
    <html>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <sql:query var="rs" dataSource="jdbc/TestDB">
    select id, foo, bar from testdata
    </sql:query>
    <html>
    <head>
    <title>DB Test</title>
    </head>
    <body>
    <h2>Results</h2>
    <c:forEach var="row" items="${rs.rows}">
    Foo ${row.foo}
    Bar ${row.bar}
    </c:forEach>
    </body>
    </html>
    Following is the context file called "DBtest.xml" stored in webapps/DBtest/META-INF folder( i have a same copy of the file in /conf/Catelina/localhost)
    <Context path="/DBTest" docBase="DBTest"
    debug="5" reloadable="true" crossContext="true">
    <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
    maxActive="100" maxIdle="30" maxWait="10000"
    username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
    </Context>
    i have following web.xml file in webapps/DBtest/WEB-INF
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    <description>MySQL Test App</description>
    <resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/TestDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    i have been refering to the internet form past 3 days and making lot of changes.but,there is no use.
    plz guide me
    thanks

    Perhaps a stupid question: is MySQL running and listening on port 3306? The problem is not always in the webapp. Perhaps you can create a small test class that uses Driver to make a connection to your database.

Maybe you are looking for

  • Change column width in report

    After creating a report using table 'dept', I have updated that dept table and increased the width of the column dname from 14 to 20. I would like to know how to change the width of the dname column in the report that I created earlier so that it can

  • Help! X-Fi 16gb and Napster-to-Go Problem

    Help! X-Fi 6gb and Napster-to-Go Problem5 ?Help please! Until yesterday I have been happily using my Creative Zen X-Fi 6GB along with my Napster to Go subscription. I sync my player using Windows Media Player - I use Windows Vista. Following syncroni

  • Text flips in cartoon caption

    Using the Shapes feature, there is a cartoon caption shape. When I put text in one of these and flip it to fit alongside the "speaker", the text ends up flipped as well. This happens whether I flip the shape before or after I add text. Can anyone fig

  • Photo album sharing on iMac/ iPad

    My wife and I share the same iMac but with different log-ins.  At the moment my wife has to log in, as me to see the family photo albums.  I am trying to find a way of sharing my photo albums so my she may see them when she uses her log in.  I am thi

  • 0x00000e9 when intalling windows on SSD

    Hey guys, im having trouble installing windows on my Macbook pro. Recently my harddisk broke down, so i had to buy a new one. A friend of mine recommended an SSD so i bought one, and installed osx on it without problems. Then, through bootcamp, i try