• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Connecting to DB with user supplied credentials.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Connecting to DB with user supplied credentials.


  • Subject: Re: Connecting to DB with user supplied credentials.
  • From: "Daniele Corti" <email@hidden>
  • Date: Wed, 11 Jun 2008 16:41:32 +0200

But, were you connected to a DB before calling
EOUtilities.connectWithModelNamed?

On Wed, Jun 11, 2008 at 4:37 PM, Henrique Gomes <email@hidden> wrote:
>
> Sorry, the stack trace for the NPE is this:
>
> EC creation: First failed!!java.lang.NullPointerException
> java.lang.NullPointerException
>        at
> com.webobjects.eoaccess.EODatabaseContext.forceConnectionWithModel(EODatabaseContext.java:1139)
>        at
> com.webobjects.eoaccess.EOUtilities.connectWithModelNamed(EOUtilities.java:840)
>        at XXXX.components.Main.doLogin(Main.java:68)
>
> I wonder if I'm missing something on the EOModel or dictionary....
>
> On Jun 11, 2008, at 3:23 PM, Henrique Gomes wrote:
>
>> Hello,
>>
>> In my first WO project, I need to connect to the db using the credentials
>> that users provide on the login page. At most 10-20 users will be using it
>> simultaneous so there won't be scalability problems (I hope).
>>
>> Anyway I tried the following, storing the editing context on the session
>> but for some reason the first try always fails with a NPE?? and the second
>> succeeds?? I can leave it like that but don't feel comfortable with it. Am I
>> on the wrong path here?
>>
>>                        EOEditingContext editingContext =
>> session().defaultEditingContext();
>>                      // A session was already created. Can I start with
>> this EC?
>>
>>                        NSMutableDictionary userLogin = new
>> NSMutableDictionary();
>>
>>                        userLogin.setObjectForKey(login, "username");
>>                        userLogin.setObjectForKey(password, "password");
>>                        try {
>>
>>  EOUtilities.connectWithModelNamed(editingContext, "Rima",
>>                                                userLogin);
>>                        } catch (JDBCAdaptorException e) {
>>                                // wrong password, server down , etc...
>>                                setMensagem(e.getMessage());
>>                                return null;
>>                        }
>>                        catch (Exception e1) {
>>                                //Why???
>>                                NSLog.out.appendln("First failed!!" +
>> e1.getClass().getName());
>>                                try {
>>
>>  EOUtilities.connectWithModelNamed(editingContext, "Rima",
>>                                                        userLogin);
>>                                } catch (Exception e2) {
>>                                        //this never happens !?!?
>>                                        NSLog.out.appendln("Second
>> Exception!!" + e2.getClass().getName());
>>                                }
>>                        }
>>
>>
>>
>> Here is the output:
>>
>> [2008-6-11 14:25:19 WEST] <WorkerThread12> Using JDBCPlugIn
>> 'PostgresqlPlugIn' for JDBCAdaptor@14936307
>> [2008-6-11 14:25:19 WEST] <WorkerThread12>  connecting with dictionary:
>> {plugin = "PostgresqlPlugIn"; username = "hmng"; driver = ""; password =
>> "<password deleted for log>"; URL = "jdbc:postgresql://server/db"; }
>> EC creation: First failed!!java.lang.NullPointerException
>> java.lang.RuntimeException: EC creation
>>        at XXXX.components.Main.doLogin(Main.java:78)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:585)
>>        at
>> com.webobjects.foundation.NSKeyValueCoding$ValueAccessor$1.methodValue(NSKeyValueCoding.java:636)
>>        at
>> com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKeyValueCoding.java:1134)
>>        at
>> com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey(NSKeyValueCoding.java:1293)
>>        at
>> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1686)
>>        at
>> com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCoding.java:447)
>>        at
>> com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java:212)
>>        at
>> com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:1754)
>>        at
>> com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent(WOKeyValueAssociation.java:50)
>>        at
>> com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:144)
>>        at
>> com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105)
>>        at
>> com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
>>        at
>> com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:1078)
>>        at
>> com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1357)
>>        at
>> com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1736)
>>        at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedPage(WOComponentRequestHandler.java:206)
>>        at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:298)
>>        at
>> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332)
>>        at
>> com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:369)
>>        at
>> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:442)
>>        at
>> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1678)
>>        at
>> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
>>        at
>> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
>>        at java.lang.Thread.run(Thread.java:613)
>>
>> [2008-6-11 14:25:23 WEST] <WorkerThread12> fetching JDBC Info with
>> JDBCContext@14974519
>> [2008-6-11 14:25:23 WEST] <WorkerThread12>  connecting with dictionary:
>> {plugin = "PostgresqlPlugIn"; username = "hmng"; driver = ""; password =
>> "<password deleted for log>"; URL = "jdbc:postgresql://server/db"; }
>> [2008-6-11 14:25:38 WEST] <WorkerThread12>  === Begin Internal Transaction
>> [2008-6-11 14:25:38 WEST] <WorkerThread12>  evaluateExpression:
>> <com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT ....
>> [2008-6-11 14:25:38 WEST] <WorkerThread12> 1 row(s) processed
>> [2008-6-11 14:25:38 WEST] <WorkerThread12>  === Commit Internal
>> Transaction
>>
>> WO 5.4.1, Leopard, PostgresqlPlugiIn updated recently...
>>
>>
>> Best regards,
>>
>> ---
>> Henrique Gomes
>>
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>



--
Bill Watterson  - "There is not enough time to do all the nothing we
want to do."
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Connecting to DB with user supplied credentials.
      • From: Henrique Gomes <email@hidden>
References: 
 >Connecting to DB with user supplied credentials. (From: Henrique Gomes <email@hidden>)
 >Re: Connecting to DB with user supplied credentials. (From: Henrique Gomes <email@hidden>)

  • Prev by Date: Re: Connecting to DB with user supplied credentials.
  • Next by Date: DON'T PANIC (Was: Maven vs Ant)
  • Previous by thread: Re: Connecting to DB with user supplied credentials.
  • Next by thread: Re: Connecting to DB with user supplied credentials.
  • Index(es):
    • Date
    • Thread