Solved

Dynamic Data Source For DB Control

Posted on 2006-11-22
10
214 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
Independent Software Vendors: 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!

 
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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WS 8.5 - Associating Application With Shared Reference Library 4 226
some methods private some are not 8 230
method reurn 7 86
how to pass values from bean to JSF page 4 102
-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 …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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