Does a datasource object always have one Driver and url for it's connections?
(and the username and password can change)

If so than i find that stupid, because it is possible that i must access multiple 
databases
from my applications.
And in struts i can only define one. (at this time i can't even change 
usernames/passwords but that doesn't matter to me)

What i would like to do is this:

<data-source>
    <connection
        name=postgresql
        default= true
        autoCommit="false"
        description="Example Data Source Configuration of postgres"
        driverClass="org.postgresql.Driver"
        maxCount="4"
        minCount="2"
        password="mypassword"
        url="jdbc:postgresql://localhost/mydatabase"
        user="myusername"
    />

    <connection
        name=sybase
        default= false
        autoCommit="false"
        description="Example Data Source Configuration of sybase"
        driverClass="com.sybase.jdbc.jdbc2.SybDriver"
        maxCount="4"
        minCount="2"
        password="mypassword34"
        url="jdbc:xxxx/xxx/xxxx"
        user="myusername3242"
    />
<data-source/>

(or define some more connections for postgres with different usernames)

Then the GenericDataSource doesn't have the url/user/password properties and a 
ArrayList to store connections
But 2 Hashmap:
One fore storing the information for every connections in a properties object.
The second for storing the connections object that get's shared (hashmap with 
ArrayList Objects)

The haskey is the name of the connection.

Then you have 4 getConnections()

getConnection() from datasource, which returns the default one with default username 
and password.
getConnection(String user, String password) return the default one with that username 
password.
getConnection(String name) which returns the connection with that name with default 
username and password.
getConnection(String name, String user, String password) returns the connection with 
that name with that username password.

Then you have one GenericDataSource for all your connections.

Ofcourse you can also program it to have multiple GenericDataSources for every 
connection but
i preffer the first way.

What do you guys think?

Johan Compagner

P.S. i am willing to implement this and give it to struts ofcourse.


Reply via email to