You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Paul Spencer <pa...@mindspring.com> on 2008/11/10 20:55:55 UTC

How to maintain a schema per user?

I have an application that requires a logged in user be restricted to a 
schema within the database.  For the sake of illustration, the 
application is an address book and their is one schema per user.  The 
database structure of the table and views within each schema are exactly 
same.

My questions:

1) How do insure that a logged in user will only access the data in 
their schema?

2) How can a new schema be automatically created when user is created?

Paul Spencer





Re: How to maintain a schema per user?

Posted by David Blevins <da...@visi.com>.
On Nov 10, 2008, at 2:35 PM, Paul Spencer wrote:

> Dain,
> I am using OpenJPA.  Do you know if, and how, they support per user  
> connections?

OpenJPA will use whatever DataSources we give it.  You might be able  
to use the Commons DBCP PerUserPoolDataSource as Dain suggests but  
it'll take some patching to get it wired in.  This is the class that  
creates the DataSources inside OpenEJB    
org.apache.openejb.resource.jdbc.DataSourceFactory

http://svn.apache.org/viewvc/openejb/tags/openejb-3.1/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java?view=markup

You might be able to patch it to create PerUserPoolDataSource instead.

-David


>
>
> Paul Spencer
>
>
> Dain Sundstrom wrote:
>> Assuming you are using straight JDBC or a persistence framework  
>> designed for per-user connections, I believe that the  
>> org.apache.commons.dbcp.datasources.PerUserPoolDataSource pool can  
>> do what you want, but I've never used per-user pools myself.  Also,  
>> I bet that c3p0 (http://sourceforge.net/projects/c3p0/) can do it  
>> also.
>> -dain
>> On Nov 10, 2008, at 11:55 AM, Paul Spencer wrote:
>>> I have an application that requires a logged in user be restricted  
>>> to a schema within the database.  For the sake of illustration,  
>>> the application is an address book and their is one schema per  
>>> user.  The database structure of the table and views within each  
>>> schema are exactly same.
>>>
>>> My questions:
>>>
>>> 1) How do insure that a logged in user will only access the data  
>>> in their schema?
>>>
>>> 2) How can a new schema be automatically created when user is  
>>> created?
>>>
>>> Paul Spencer
>>>
>>>
>>>
>>>
>
>


Re: How to maintain a schema per user?

Posted by Paul Spencer <pa...@mindspring.com>.
Dain,
I am using OpenJPA.  Do you know if, and how, they support per user 
connections?

Paul Spencer


Dain Sundstrom wrote:
> Assuming you are using straight JDBC or a persistence framework designed 
> for per-user connections, I believe that the 
> org.apache.commons.dbcp.datasources.PerUserPoolDataSource pool can do 
> what you want, but I've never used per-user pools myself.  Also, I bet 
> that c3p0 (http://sourceforge.net/projects/c3p0/) can do it also.
> 
> -dain
> 
> On Nov 10, 2008, at 11:55 AM, Paul Spencer wrote:
> 
>> I have an application that requires a logged in user be restricted to 
>> a schema within the database.  For the sake of illustration, the 
>> application is an address book and their is one schema per user.  The 
>> database structure of the table and views within each schema are 
>> exactly same.
>>
>> My questions:
>>
>> 1) How do insure that a logged in user will only access the data in 
>> their schema?
>>
>> 2) How can a new schema be automatically created when user is created?
>>
>> Paul Spencer
>>
>>
>>
>>
> 
> 


Re: How to maintain a schema per user?

Posted by Dain Sundstrom <da...@iq80.com>.
Assuming you are using straight JDBC or a persistence framework  
designed for per-user connections, I believe that the  
org.apache.commons.dbcp.datasources.PerUserPoolDataSource pool can do  
what you want, but I've never used per-user pools myself.  Also, I bet  
that c3p0 (http://sourceforge.net/projects/c3p0/) can do it also.

-dain

On Nov 10, 2008, at 11:55 AM, Paul Spencer wrote:

> I have an application that requires a logged in user be restricted  
> to a schema within the database.  For the sake of illustration, the  
> application is an address book and their is one schema per user.   
> The database structure of the table and views within each schema are  
> exactly same.
>
> My questions:
>
> 1) How do insure that a logged in user will only access the data in  
> their schema?
>
> 2) How can a new schema be automatically created when user is created?
>
> Paul Spencer
>
>
>
>