Solved

Dynamic Data Source For DB Control

Posted on 2006-11-22
10
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
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

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

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

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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