Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic Data Source For DB Control

Posted on 2006-11-22
10
Medium Priority
?
218 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 1800 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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 1800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
Verbose logging is used to diagnose garbage collector problems. By default, -verbose:gc output is written to either native_stderr.log or native_stdout.log.   It is also possible to redirect the logs to a user-specified file. This article will de…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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