Solved

Dynamic Data Source For DB Control

Posted on 2006-11-22
10
211 Views
Last Modified: 2013-12-10
Hi,

Just wondering whether it is possible to do or not.

I am currently using Database Control and WebLogic Workshop 8.1. As you know that Database Control is bind to one DataSource. However, I have one problem where I need to dynamically set the DataSource based on the user's login. The problem is actually there are multiple roles in the Oracle DB that we used so one user may be assigned to certain role only. I am thinking to maybe setup 4 DataSource and 4 Connection Pools for the 4 available roles in our Oracle DB. However, now I am confused on how to let the DB Control know on which DataSource to be used?

Thanks and I hope that it is clear.

David

0
Comment
Question by:suprapto45
  • 5
  • 4
10 Comments
 
LVL 16

Author Comment

by:suprapto45
ID: 17994660
If that is rather impossible, please do let me know your thought of the possible solution

David
0
 
LVL 35

Expert Comment

by:girionis
ID: 18001693
Hello suprapto45,

yes you can do it. There is a file called DynamicProperties.xsd (it is generated automatically with a process project, or you can write your own) which defines all the possible properties you can set for a control. You can even write your own schema and define your own properties in there. Then parse this schema, create an XML bean and set it to the database control by using its setProperties() method. If you need some sample code let me know.
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 450 total points
ID: 18001803
Here is how we do it with an email control

1) We have defined our own properties in a file called EmailProperties.xml which has the following format

<?xml version="1.0" encoding="UTF-8"?>
<email xmlns="<namespace location>">
      <to><to email address here></to>
      <cc><data here></cc>
      <bcc><data here></bcc>
      <subject><data here></subject>
      <body><data here></body>
      <attachment><data here></attachment>
</email>

2) We load this file up in a EmailDocument using

EmailDocument emailDoc = EmailDocument.Factory.parse(<path to the file above>)

The EmailDocument is the XML Bean created from the shcema above.

3) We set all the properties we need using

Email email = emailDoc.getEmail();
email.setTo(...);
emaii.setSubject(...);

4) We set this properties document to the control

emailControl.setProperties(emailDoc);

Then the next email sent is sent to the the recipient and the properties defined in the control.

I haven't done something similar with a database contriol but I *think* i should be the same.

If you have any more questions let me know.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 35

Expert Comment

by:girionis
ID: 18001822
By the way we had a similar problem in the past and we solved it in the database layer. The db knew what user this is and what data can this user see and would return the data accordingly.
0
 
LVL 10

Assisted Solution

by:ECollin
ECollin earned 50 total points
ID: 18003703
Hi,

unfortunatly, the solution provided by gironis is not available for database controls...

Resolve your problem at the database layer or in the sql code by introducing where clauses related to users.


Emmanuel
0
 
LVL 16

Author Comment

by:suprapto45
ID: 18003801
Hi girionis and ECollin,

Thanks appreciate that. I will have a look at those things tommorow. Although that it may not solve the problem directly, it may lead to some solution ;)
0
 
LVL 16

Author Comment

by:suprapto45
ID: 18005371
ECollin,

Can you explain more about this?
>>"Resolve your problem at the database layer or in the sql code by introducing where clauses related to users."

I will have a look at what girionis suggested soon.

David
0
 
LVL 35

Accepted Solution

by:
girionis earned 450 total points
ID: 18006310
> I will have a look at what girionis suggested soon.

If this doesn't work as Ecollin mentioned, you could try Dynamic Binding: http://edocs.bea.com/workshop/docs81/doc/en/core/index.html. If this still doesn't work then you could go an alternative way. Define a few controls for different datasources and then have if statements in your code. These statement should test for user's role and then return the proper control.  You will need an interface common to all controls so each control is of the same type.

>Can you explain more about this?
>>>"Resolve your problem at the database layer or in the sql code by introducing where clauses related to users."

(S)he probably means that the database should be able to tell you what user can see what data. You will need to have a table that indicates all the users and their roles. Then in each of the other tables (that hold the business data) you should have a column that links to the users table with the roles (let's call it "allowedRole"). When you query the database you should do something like

SELECT role FROM <users table> WHERE username='<username'>
SELECT * FROM sales WHERE allowedRole='role'

By doing so you will only get back the data relevant to the user's role.

0
 
LVL 16

Author Comment

by:suprapto45
ID: 18014575
Thanks girionis and ECollin.

girionis deserves more points here.

David
0
 
LVL 35

Expert Comment

by:girionis
ID: 18017647
:)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
questions about oracle weblogic cluster 4 181
java.util.concurrent.Callable way of creating threads 2 105
error when deploying 23 776
Using Tomcat as raspberry pi java app server 13 166
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question