NSURLDownload/Connection "cancel" method

Does anyone know whether sending a "cancel" message to an NSURLDownload or NSURLConnection object results in the object being released? I'm hoping so, because otherwise I have the following problem:
I implement the (NSURLRequest *)download:willSendRequest:redirectResponse: delegate method to cancel downloads that are being redirected to the wrong place. The implementation looks like this:
- (NSURLRequest *)download:(NSURLDownload *)dl willSendRequest:(NSURLRequest *)req redirectResponse:(NSURLResponse *)resp
// check new request's URL's host and see whether it's okay
if (host-is-not-okay) { [dl cancel]; }
return req;
The problem is this: if I end up canceling the download, I never receive a downloadDidFail or downloadDidFinish message from the download object, which are the usual signal to release the object. But I can't release the object at the time I cancel, because I'm in the middle of a method that returns a value to that object.
So I'm hoping that the cancel method results in the object being released. Can anyone confirm this? And if not, can anyone suggest a solution to this problem?
Thanks,
Eliza

Alternatively you could just close the connection from another thread.

Similar Messages

  • Cancel method in JDBC!

    Has anyone ever implemented the "cancel" method on the Statement class in JDBC?
    On that has anyone cancelled the Connection or the Statement object while carrying out the cancel?

    Alternatively you could just close the connection from another thread.

  • TIP 02: Easy Connect Naming Method in 10g by Joel Pèrez

    Hi OTN Readers!
    Everyday I get connection on Internet and one of the first issues that
    I do is to open the OTN main page to look for any new article or any
    new news about the Oracle Technology. After I open the main page of
    OTN Forums and I check what answers I can write to help some people
    to work with the Oracle Technology and I decided to begin to write some
    threads to help DBAs and Developers to learn the new features of 10g.
    I hope you can take advantage of them which will be published here in
    this forum. For any comment you can write to me directly to : [email protected]
    Please do not replay this thread, if you have any question related to
    this I recommend you to open a new post. Thanks!
    The tip of this thread is: Easy Connect Naming Method
    Joel Pérez
    http://otn.oracle.com/experts

    Let's go to test it removing the BASE1 service of the listener.ora file
    # listener.ora Network Configuration File: C:\oracle\product\10.1.0\db_1\NETWORK\ADMIN\listener.ora
    # Generated by Oracle configuration tools.
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = BASE2)
          (ORACLE_HOME = C:\oracle\product\10.1.0\db_1)
          (SID_NAME = BASE2)
    LISTENER =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = oracle10g)(PORT = 1521))
      )and Now, I am going to reload the listener service in order to
    apply the change to the enviroment.
    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.
    C:\>
    C:\>lsnrctl stop
    LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on 20-APR-2004 13:20
    :35
    Copyright (c) 1991, 2004, Oracle.  All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle10g)(PORT=1521)))
    The command completed successfully
    C:\>lsnrctl start
    LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production on 20-APR-2004 13:20
    :39
    Copyright (c) 1991, 2004, Oracle.  All rights reserved.
    Starting tnslsnr: please wait...
    TNSLSNR for 32-bit Windows: Version 10.1.0.2.0 - Production
    System parameter file is C:\oracle\product\10.1.0\db_1\network\admin\listener.or
    a
    Log messages written to C:\oracle\product\10.1.0\db_1\network\log\listener.log
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle10g)(PORT=1521)))
    STATUS of the LISTENER
    Alias                     LISTENER
    Version                   TNSLSNR for 32-bit Windows: Version 10.1.0.2.0 - Produ
    ction
    Start Date                20-APR-2004 13:20:41
    Uptime                    0 days 0 hr. 0 min. 2 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   C:\oracle\product\10.1.0\db_1\network\admin\listener.o
    ra
    Listener Log File         C:\oracle\product\10.1.0\db_1\network\log\listener.log
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
    Services Summary...
    Service "BASE2" has 1 instance(s).
      Instance "BASE2", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    C:\>Joel Pérez
    http://otn.oracle.com/experts

  • Multiple Data Source (for FAILOVER) in Easy Connect Naming method

    Hi All,
    I was wondering if there is a way to specify multiple addresses as part of data source property in the connection string when trying to connect to Oracle with Easy Connect Naming method? this is basically for failover scenario.
    I know its straight forward, if i use Connect Descriptor. But not sure how to do it with EZConnect
    For ex. this is what I want to achieve with EZConnect
    sales.us.example.com=
    (DESCRIPTION=
    (ADDRESS_LIST=
    (LOAD_BALANCE=off)
    (FAILOVER=ON)
    *(ADDRESS=(PROTOCOL=tcp)(HOST=sales1-server)(PORT=1521))*
    *(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521)))*
    (CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))
    I appreciate your suggestions...
    Thanks

    You might get better answers in one of the DB forums from a generic fail-over perspective as EZconnect isn't specific to ODP.NET.
    I don't know if there's a way to do it or not with EZConnect version of the connect string, but you can certainly provide the fully qualified connect string without using tnsnames.ora..
    constring = "data source=(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=off)(FAILOVER=ON)(ADDRESS=(PROTOCOL=tcp)(HOST=sales1-server)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com))); user id=scott;password=tiger"
    Hope it helps,
    Gres

  • Oci_connect using easy connect naming method needs listener??

    Hi,
    I was thinking that using the easy connect naming method in oci_connect does not require a running local tnslsnr!? Am I wrong?
    I tried:
    $db = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = my-ora-host.example.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = my-service.example.com)))';
    // $db = '//my-ora-host.example.com:1521/my-service.example.com';
    $ora_conn = oci_connect('test', 'test', $db);
    Using both versions of the 'db' I receive the error:
    mod_fcgid: stderr: PHP Warning: oci_connect(): ORA-12541: TNS:no listener in ....
    I am using a self compiled PHP 5.3.8 using Oracles instantclient 11.2.0.3.0 (on Linux, 32bit).
    There are NO special environment variables ( like ORACLE_HOME or TNS_ADMIN), because I was thinking that I don't need them...
    Am I wrong? Is a running tnslsnr always required? Or am I doing wrong in specifying the connection string?
    Any help is appreciated!
    chuan

    The connection strings are fine. They only control how PHP attempts to connect to the DB. The DB will need a listener started so that those incoming requests are handled. Use: 'lsnrctl start' on the DB machine.

  • Cancel() method in "Timer" class

    Hi there,
    I'm just a bit wondering what's the problem with the following code. if i comment out the t.cancel() method, the program will print out "OK!". but if i don't comment it out, the program will print out nothing, although it compiles perfectly. by the way, i can't tell the difference between putting t.cancel() there and putting it within "public void run()" and after that "system.out.println("OK!");" method. I think t.cancel() can be called in any place in the program.
    any comments will be very much appreciated.
    Eileen2
    import java.util.*;
    public class Thread1
         private Timer t;
         public Thread1()
              t = new Timer();
              t.schedule(new Task(), 4000);
    //          t.schedule(new Task(), 2000);
              t.cancel();
         private class Task extends TimerTask
              public void run()
                   System.out.println("OK!");
         public static void main(String[] args)
              System.out.println("This program is to test how threads work...");
              new Thread1();

    What you describe is exactly what I would expect that would happen. By calling cancel() on the timer, you discard any scheduled tasks, so your Task.run() will never be executed and you will not see the "OK!". Note that the call to schedule() returns immediately. It doesn't wait until the task will execute.
    Your question is not very clear. What do you want to know specifically about the behaviour of your program? What did you expect it to do and what is the difference between what it really does and what you expected?
    Jesper

  • User connection cancelled (0x115)

    I keep getting a user connection cancelled (0x115) message about every five minutes.  I think it is because I turned off my wireless sync feature with Verizon.  How do I turn off this error message
    Post relates to: Centro (Verizon)

    Hello and welcome to the Palm forums.
    Is there a box to check off "dont show again?"
    Post relates to: None

  • Connection canceling

    HI, sorry for my English.
    Here is my problem,
    I make application wich using HttpConnection, and I want to release cancel option for user (if loading data takes long time), but there are situations where application blocks after user click cancel command. in commandAction I close active connection, and change current display. If anyone has experiance with this help me.
    Best regards, Thank you.

    When you have an existing wireless network for your Internet connection, life will be much easier if you configure the Airport Express to "Join" your existing wireless network.
    Then you will be able to stream AirTunes and browse the Internet without having to switch networks.
    "Hard Reset" the AirPort Express by holding in the reset button until the amber light begins to blink more quickly and keep holding the reset button in for another 4-5 seconds when this occurs, then release the reset button.
    Allow 40-45 seconds for the AirPort Express to restart...the amber light will be blinking slowly at this time.
    Open AirPort Utility and click Continue to follow the guided setup to configure your AirPort Express to "Join" the wireless network that the Netgear router is providing.
    The tricky part about this will be that you will need to know the exact type of wireless security that your Netgear router is using so that you can enter the correct setting on the AirPort Express to allow it to "join" the network correctly. If the security setting is not correct, the AirPOrt Express will not be able to join the Netgear wireless network and you will need to start over again with the "Hard Reset" to try the configuration again.
    If you are not sure what type of security your Netgear router is using, you should contact your ISP or consult the documentation that came with the device for more information.
    BTW, the advice that you received from the person at the ISP about one network "overpowering" the other was total nonsense. Hope you get a more knowledgeable person on the next try.
    Post back if you need more help with the "Join" configuration for the AirPort Express. The key will be knowing exactly what type of security that the Netgear router is using.

  • If Connection  cancelled once...

    Try this...
    I am connected to connection1 and I am in SQL worksheet.
    I wanted to have another worksheet
    So I click on SQL Worksheet icon and by mistake click on another connection from drop down. It asks me for password , I cancelled it. It says "An error has ocurred ..." OK.
    I click on SQL worksheet icon again select the desired connection ..
    But it just does not connect now.. It repeats the same error box again and again..
    --Sanjeev                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    We had a bug on something like this with cancelling a connection from the Navigator and then not being able to open another connection. That one was fixed but I think we have the same issue with the connections under the icon. Thanks for pointing it out. I will go reopen that old bug.
    -- Sharon

  • Re: External Connections StartListening method

    If someone hasn't already done it, then I'd try taking any example C code
    from GNU, MSDev, etc for a platform you want to have the UDP listener
    running on and compile and wrapper into a forte Class. If the listener code
    isn't thread safe, you'll want to make sure you put the service object in a
    partition by itself, else the other services wont get to do any work while
    it's waiting for messages.
    -Jim
    At 03:34 PM 12/18/98 , Hopia, Jay CWT-MSP wrote:
    In the Forte ONLINE help, the StartListening method states, "The
    StartListening method performs initial set up for the specified port number,
    and then waits for connections".
    What suggestions does anyone have for working with connection-less messages
    (i.e. UDP, datagrams) that are configured to be sent to a specific port
    number for an IP address.
    Thanks
    -Jay
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    Jim Rice mailto:[email protected]
    Forte Software, Inc. http://www.forte.com
    Partner Tech Specialist Work#: 301-721-1910
    Upcoming Partner Events http://www.forte.com/events/frameset_partners.html
    Mainframe Forte http://www.forte.com/events/
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    You need to configure your home router to forward port xxyxx on the internet side to port yyyyy on home computer Z.
    Most home routers allow you to do this.
    How you do this depends on which home router you have. You could do a Google search with your router name, model, and the words "Port Forward". That should most likely turn up instructions from someone else that has been through this before with your model router.

  • Where to include connection processing methods?

    In an architecture which uses JSPs as the presentation layer, and contains objects representing each table of an Oracle database (one object per table), should the connection processing be included in the JSPs, or should it be included within the method of each database object that prepares the SQL statement?
    By connection processing, I mean methods for establishing the connection, returning a reference to it, and closing it.

    You should not include that type of logic in the JSP at all! It's usually not clean to do that. You should separate that portion of the code and put them inside the DAO perhaps...

  • External Connections StartListening method

    In the Forte ONLINE help, the StartListening method states, "The
    StartListening method performs initial set up for the specified port number,
    and then waits for connections".
    What suggestions does anyone have for working with connection-less messages
    (i.e. UDP, datagrams) that are configured to be sent to a specific port
    number for an IP address.
    Thanks
    -Jay
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Folks,
    I solved the problem. It looks like a socket implementation difference
    between 16 bit and 32 bit versions of Microsoft OS.
    I was expecting a 1Meg Binary Data and so I was trying to read 1 Meg at
    one shot. It seems like, since the buffer some where along the line (
    may be at the server) can handle only a max of 14K of data, the reader
    on the PC closed the connection when it didn't recieve all the 1Meg of
    data at 1 shot.
    When I changed the length I was expecting to 14K or less, it started
    working.
    Enjoy!!!
    Venkat J Kodumudi
    Price Waterhouse LLP
    Internet: [email protected]
    Internet2: [email protected]
    -----Original Message-----
    From: Venkat Kodumudi
    Sent: Tuesday, February 03, 1998 8:02 AM
    To: '[email protected]'
    Subject: External Connections
    Hi Forte users,
    I am trying to use the External Connections class on a Win 95 and a
    Win 3.11 environment. I am running Forte 2.0.F.4 client and 2.0.H.11
    server. I am trying to connect from the client to a C program through
    a Socket connection.
    Ironically, on a Win 95 and 3.11 machine, the client connection seems
    to close itself if there is nothing to read on the pipe. Has any one
    noticed this?
    Do we have to keep doing conn.open every time we try to use the
    connection? What else can we do?
    Thanks in Advance.
    Venkat J Kodumudi
    Price Waterhouse LLP
    Internet: [email protected]
    Internet2: [email protected]

  • Connection cancellation error with Azure

    Hello!
    From night to day started getting the error below when I run my application on the local machine. Publishing the application on Azure have no problems.
    I researched this error and in some places say it is temporary. Try again later. Others say it can be in zone function time. Modified the machine time and did not work.
    The level of application did not modify anything. Continue with the same version of the SDK (2.3). Just follow the development of new features in the application. I did not update any components.
    Follow the below error:
    Erro de Servidor no Aplicativo '/'.
    Foi forçado o cancelamento de uma conexão existente pelo host remoto
    Descrição: Ocorreu uma exceção sem tratamento durante a execução da atual solicitação da Web. Examine o rastreamento de pilha para obter mais informações sobre o erro e onde foi originado no código. 
    Detalhes da Exceção: System.Net.Sockets.SocketException: Foi forçado o cancelamento de uma conexão existente pelo host remoto
    Erro de Origem: 
    Exceção sem tratamento foi gerada durante a execução da atual solicitação da Web. As informações relacionadas à origem e ao local da exceção podem ser identificadas usando-se o rastreamento de pilha de exceção abaixo.
    Rastreamento de Pilha: 
    [SocketException (0x2746): Foi forçado o cancelamento de uma conexão existente pelo host remoto]
    System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) +6610791
    System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) +56
    [IOException: Não é possível ler os dados da conexão de transporte: Foi forçado o cancelamento de uma conexão existente pelo host remoto.]
    System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) +230
    System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) +13
    System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) +116
    [WebException: A conexão subjacente estava fechada: Erro inesperado em um envio.]
    System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +2240362
    System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) +14
    System.Net.WebClient.UploadBitsRequestCallback(IAsyncResult result) +86
    [DataCacheException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:Unable to complete authorization request for connecting to the caching endpoint. Please try again after sometime. If the issue persists, contact Microsoft support. ]
    Microsoft.ApplicationServer.Caching.AcsTokenManager.ThrowLastAcsException(Exception exception) +265
    Microsoft.ApplicationServer.Caching.AcsTokenManager.GetOrRefreshToken(TimeSpan timeout) +778
    Microsoft.ApplicationServer.Caching.SocketClientChannel.TryAuthorizeMessage(IAuthorizedChannel channel, IVelocityRequestPacket packet) +76
    Microsoft.ApplicationServer.Caching.SocketClientChannel.Send(EndpointID endpoint, IVelocityRequestPacket packet) +395
    [DataCacheException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:Unable to complete authorization request for connecting to the caching endpoint. Please try again after sometime. If the issue persists, contact Microsoft support.]
    Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +292
    Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +878
    Microsoft.ApplicationServer.Caching.<>c__DisplayClass5.<Initialize>b__2(RequestBody req) +83
    Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func`2 delegate, EndpointID& destination) +34
    Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable`1 servers) +367
    Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +400
    Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +61
    Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +13
    Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +65
    Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +83
    Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +148
    Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.ResetItemTimeout(HttpContext context, String id) +13
    System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +622
    System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +285
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
    Informações sobre a Versão: Microsoft .NET Framework Versão:4.0.30319; Versão do ASP.NET:4.0.30319.34212

    Hi TChiang!
    Thanks for help!
    The value for parameter "usedevelopmentstorege' is 'true'. See below my ServiceConfiguration.Local.cscfg with some values changed:
    <?xml version="1.0" encoding="utf-8"?>
    <ServiceConfiguration serviceName="X.WindowsAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-01.2.3">
    <Role name="X.Presentation.Ext.Net">
    <Instances count="1" />
    <ConfigurationSettings>
    <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
    <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
    <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="username" />
    <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="XYZ" />
    <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2014-02-07T23:59:59.0000000-02:00" />
    <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.NamedCaches" value="{&quot;caches&quot;:[{&quot;name&quot;:&quot;default&quot;,&quot;policy&quot;:{&quot;eviction&quot;:{&quot;type&quot;:0},&quot;expiration&quot;:{&quot;defaultTTL&quot;:0,&quot;isExpirable&quot;:false,&quot;type&quot;:0},&quot;serverNotification&quot;:{&quot;isEnabled&quot;:false}},&quot;secondaries&quot;:0}]}" />
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel" value="1" />
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.CacheSizePercentage" value="30" />
    <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ConfigStoreConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
    <Certificates>
    <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="ABC" thumbprintAlgorithm="sha1" />
    </Certificates>
    </Role>
    </ServiceConfiguration>
    ErInfo

  • Checking credentials with "connection.openProxySession" method

    Our project has a WebLogic instance with a connection pool, which hits an Oracle database. When users authenticate, we want to verify their credentials with the database. Previously, this was done circumventing the connection pool, and opening a direct connection to the Oracle database to verify their credentials. For performance reasons, this is not ideal, since opening an Oracle connection is slow. There would be a performance benefit if we could verify a user's credentials by proxy-connecting with their username/password. However, I can't get it to work correctly.
    So far, I've written the following java code to try and verify a user's credentials:
    void testCreds(DataSource connectionPoolDataSource, String username, String password) throws SQLException {
      System.out.println("Testing credentials " + username + "/" + password + "...");
      Connection connection = connectionPoolDataSource.getConnection();
      try {
        OracleConnection oracleConnection = DaoUtils.getOracleConnection(connection);
        try {
          Properties paramProperties = new Properties();
          paramProperties.put(OracleConnection.PROXY_USER_NAME, username);
          paramProperties.put(OracleConnection.PROXY_USER_PASSWORD, password);
          oracleConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, paramProperties);
          oracleConnection.close(OracleConnection.PROXY_SESSION);
          System.out.println("Credentials are valid");
        } catch (Exception e) {
          System.out.println("Credentials are invalid " + e.getClass() + ")");
      } finally {
        connection.close();
    }This works OK, until it's called with an invalid credential pair. Then, the connection is "poisoned" and won't work again, producing the following error if createStatement() is called:
    Caused by: java.sql.SQLException: Closed Connection
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
         at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:3006)I've tried various ways to "unpoison" the connection, such as closing the proxy session, or opening a new proxy session, but I'm out of ideas. In the meantime the best workaround I can think of is to circumvent the connection pool, and directly connect to the database, as we were doing before - but, we can proxy connect to verify a user's credentials, and if we have a problem (maybe the username/password was invalid, or the account is expired) we discard the connection and reconnect. However It seems like a hairy kludge for what should be a simple problem.
    I'm running WebLogic 10.3.2, Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production, and Java 1.6.0_12.
    Edited by: Aaron Pieper on Jun 30, 2010 12:20 PM (removed closeProxyConnection typo)

    "Statement Cache Size" was already at zero. Enabling "Test Connections On Reserve" had a slightly positive effect, although a confusingly inconsistent one. I created a simple utility to test whether I was getting a "valid connection" from the datasource or not:
    void testDataSource(DataSource ds) {
      try {
        System.out.print("Testing data source: ");
        new SimpleJdbcTemplate(ds).queryForInt("select 1 from dual");
        System.out.println("OK");
      } catch (Exception e) {
        System.out.println("BAD (" + e.getClass() + ")");
    }and then tried calling it:
    testDataSource(ds);
    testCreds(ds, "myuser", "mypassword");
    testDataSource(ds);
    testDataSource(ds);This helped me test the behavior of "Test Connections On Reserve". So as long as I pass in valid credentials, it works OK. If I pass in invalid credentials, the second testDataSource() call fails, with the "closed connection" error mentioned before. "Test Connections On Reserve" doesn't help to prevent this. Surprisingly, the third testDataSource() call works OK if "Test Connections On Reserve" is on. I guess this means that the functionality works (WebLogic removes the bogus connection from the pool) but only after you call GetConnection twice.
    So basically, for some reason, openProxySession poisons a connection - but not in a way that WebLogic recognizes. However, after you make a call (select 1 from dual) on that poisoned connection, it breaks the connection even more - and WebLogic removes it from the pool. With this knowledge, I can create a new version of testCreds:
    void testCreds(DataSource connectionPoolDataSource, String username, String password) throws SQLException {
      Connection connection = connectionPoolDataSource.getConnection();
      System.out.println("Testing credentials " + username + "/" + password + "...");
      try {
        OracleConnection oracleConnection = DaoUtils.getOracleConnection(connection);
        try {
          Properties paramProperties = new Properties();
          paramProperties.put(OracleConnection.PROXY_USER_NAME, username);
          paramProperties.put(OracleConnection.PROXY_USER_PASSWORD, password);
          oracleConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, paramProperties);
          oracleConnection.close(OracleConnection.PROXY_SESSION);
          System.out.println("Credentials are valid");
        } catch (Exception e) {
          try {
            oracleConnection.createStatement().execute("");
          } catch (Exception ignored) {
          System.out.println("Credentials are invalid " + e.getClass() + ")");
      } finally {
        connection.close();
    }This works, but it's a little silly. Basically, after Oracle "poisons" the connection with the bad openProxySession call, we execute any SQL statement we want. The statement is ignored, but executing it results in the "closed connection" error above. After this call, WebLogic recognizes the connection as bad, and purges it from the pool.
    A simpler solution would be to "unpoison" the connection - to restore the connection to the state it was in before the openProxySession() call was executed. Is there any way to do that?
    Edited by: Aaron Pieper on May 12, 2010 11:52 AM (java formatting)

  • New Connection Cancelled for no good reason

    Hello I'm posting here in a bit of desperation, hopefully someone can help. I'm with Virgin Media and got a "come back to BT" letter so I phoned up, liked the deal and signed up, install at the end of the month.
    On Monday night, I downloaded 2 programmes iPlayer and realised I'd downloaded over 3Gb so maybe a 10Gb allowance wouldn't be enough, I spent ages trying to get through to change to option 2. When I finally got through, I was told the BB install had been cancelled, this turns out to be due to the phone side being unable to port my number from Virgin - odd as it's been with Virgin then off to BT (Orange BB) then back to Virgin and now unable to go to to BT? I was told the address on BT is different from the address Virgin hold for me, I've checked with both and they are identical....right down to the post code.
    The result is I have a cancelled order and even re-submitting it isn't looking likely to get anywhere. I've been trying to track down an email address for BT to try and follow up - I really don't want to spend another 30 minutes on the phone listening to the ringing tone.
    The only good thing out of it so far is that Virgin have price matched so my choices now are:
    BT unlimited calls (inc 0845/0870), 5.5 MB, 10Gb allowance, BT Openzone and FON 
    Virgin: unlimited calls, 10Gb BB, no other extras
    Personally I like the Openzone and FON but think 10Gb these days isn't enough and the deal I was offered won;t discount option 2 so I would have to pay the extra for Option 3 which then gets me back to the VM price which I didn't want to pay in the first place!
    Ahhhgggghhh! CAn I ever escape from Virgin!

    Hi Johnny_ boy,
    Welcome to the forum.  I can help you with this.
    Please drop me an email to [email protected], include your full address, contact telephone number and any order numbers that you have received from BT, I will check from my end to see what has happened to your order and if need be, I can get a new order placed.
    Cheers
    Sean
    BTCare Community Manager
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

Maybe you are looking for

  • How many e-mails can i send through Bex Broadcaster?

    Dear Experts I would like to know to how many e-mail address i can send a query through "broadcast e-mail" function with BEx Broadcaster. In other words, what's the maximum number allowed of recipients? I'm using BI version 7.0. Thank you in advance

  • Is it even possible?

    is it possible to change where you print out to in java? as in physical printer (not print stream). on mac box, osx, windows, unix, anything?!? it doesnt seem anyone knows or acknowledge this. is it possible at all?] thanks

  • Show 'Text' Document contents  instead of using Document Links

    I have a requirement from my customer that requires comments to be stored and display both on the planning layout and display instantly in query. I am aware that documents which type other than text is stored in BIN form, so my first approach is just

  • WBS element wise POs

    Guru can I get the name of the table which has a link between WBS element in PS to PO placed placed i.e.PO number I have tried to find it in se11 but could not be found out. Atul

  • Trimming the fat - moving and deleting files to save space.

    I have a bit of a dilemma. I have a large number of applications that require to be installed on my startup disk. Thanks to large audio libraries and plugins, it just about fills it up. I was fortunate enough to have put in a second internal HD (prop