Hi Jose,
----- Original Message -----
From: "Jose Maria Lopez Lagunas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 13, 2002 2:10 PM
Subject: Re: Help : Jdbc Descriptor
> Hi.
>
> Could it be possible to get the following behaviour?
>
> I have a client/server application. The server has the persistence
> layer. I set the user and password of JDBC from info that the client
> sends. Since there can be several clients with different usernames and
> passwords, could it be possible to set the different user/passwords
and
> using them acordingly.
>
> To clear that, I'll show some of the code.
> When a client connects the server creates a new Controller class (this
> class is from my application). This Controller class creates a new
> instance of OJB and opens a new database:
>
> ...
> ojb = (org.apache.ojb.odmg.OJB) OJB.getInstance();
> db = ojb.newDatabase();
> db.open("repository.xml",Database.OPEN_READ_WRITE);
>
> DescriptorRepository dr =
> DescriptorRepository.getInstance(ojb.getCurrentPBKey());
> jd = dr.getDefaultJdbcConnection();
> jd.setUserName(lth.getUsuario());
> jd.setPassWord(lth.getPw());
> ...
>
> So different clients interact with different Controller classes
without
> interferring each other.
>
> I'm having some problems when there are some clients running with
> different usernames. I'm using the singlevm broker. Is there any
chance
> to use the same repository with different user/pw values or should I
use
> the C/S broker to achieve that?
Hope I get you right, initial point was:
Using one database with different
users and you do not declare a valid user in the repository.
With 0.9.7 version, OJB use a default PBKey (PB instance) for
internal operations (e.g. when using hi/lo sequence manager).
To make this possible, do first
manipulate the default jdbcConnectionDescriptor on startup of your app,
as Max explained:
jcd = DescriptorRepository.getInstance().getDefaultJdbcConnection().
jcd.setUserName(myDefaultUser)
jcd.setPassWord(myDefaultPassword)
Handle different users:
- PB-api
Use different PBKey's to obtain PB instances.
-ODMG-api
Try
db.open("repository.xml#user2#password2",Database.OPEN_READ_WRITE);
Hope this works for you.
I'm currently working on the metadata handling stuff, thus next release
this should be possible without problems ;-)
regards,
Armin
>
> Thank you in advance.
>
> Jose Maria
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>