-
1. Re: Implementing custom datasource
vickyk May 16, 2008 5:33 AM (in response to unnis)"unnis" wrote:
Is there a way to change this using configuration. like when i am doing data source look up I should get the instance of CustomDatasource. What ever jboss implements using WrapperDataSource, I will implement in my Custom datasource also ( With some extra things ) .
Any pointers or help is appreciated
Thanls & Regards
Unni
You would need to develop your own custom JDBC resource adapter which you should not be doing unless you have a valid reason to do so .
Go and grab Jboss Admin book and read the JCA chapter , you can find out the sample outbound JCA application there .
http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch7.chapt.html
Also google a bit you should be able to see the sample jca/jdbc resource adapter implementation somewhere. -
2. Re: Implementing custom datasource
unnis May 16, 2008 6:37 AM (in response to unnis)Dear vicky,
Thanks for your reply.
Jboss is already providing JDBC resource adaptor called "jboss-local-jdbc.rar".
What might be the following properties in jboss-local-jdbc.rar/META-INF/ra.xml
<managedconnectionfactory-class>org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory</managedconnectionfactory-class>
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
<connectionfactory-impl-class>org.jboss.resource.adapter.jdbc.WrapperDataSource</connectionfactory-impl-class>
<connection-interface>java.sql.Connection</connection-interface>
<connection-impl-class>org.jboss.resource.adapter.jdbc.WrappedConnection</connection-impl-class>
can we change the property "connectionfactory-impl-class" and rebuild the rar
Thanks & Regards
unnis -
3. Re: Implementing custom datasource
adrian.brock May 16, 2008 11:51 AM (in response to unnis)"unnis" wrote:
can we change the property "connectionfactory-impl-class" and rebuild the rar
Thanks & Regards
unnis
No you build your own rar and deploy it as a tx-connection-factory
instead of a local-tx-datasource.
I suspect your CustomDataSource isn't really a resource adapter
(since you don't have implementations of the other required classes).
In which case you should ignore the -ds.xml and use an MBean to
instantiate and bind your datasource into JNDI.
But that's not really a topic for this forum, it's not JCA if there's no resource adapter. -
4. Re: Implementing custom datasource
adrian.brock May 16, 2008 11:52 AM (in response to unnis)"adrian@jboss.org" wrote:
"unnis" wrote:
can we change the property "connectionfactory-impl-class" and rebuild the rar
Thanks & Regards
unnis
No you build your own rar and deploy it as a tx-connection-factory
instead of a local-tx-datasource.
local-tx-datasource is just a tx-connection-factory with some hardwiring
to use our rar and easier xml config of the config properties. -
5. Re: Implementing custom datasource
unnis May 19, 2008 1:32 AM (in response to unnis)Dear adrian,
Thanks for the reply. My exact requirement is the following.
Based on the user profile I need to connect multiple databases. All of my databases will reside in same mysql server and is having same structure.I can't use multiple datasource and multiple connection pool, since the number of databses is more. So my plan is to have a single datasource and swich the database using setCatalog() jdbc method.
My application does the data source lookup in the following ways
1) Direct JNDI lookup in EJB
2) Using Hibernate
3) Using KODO-JDO
In all the above cases I am using same JNDI name ( mySqlDS) .
How can I achive this ???
I feel that database switching has to be done before giving the connection to the client ( EJB/Hibernate/jdo) . So this has to be done at DataSource level so that ds.getConnection() should return the proper connection with proper catalog set.
If I am using CustomDataSource , Inside CustomDataSource is there a way to access values from EJbContext ???
Thanks & Regards
unnis -
6. Re: Implementing custom datasource
unnis May 20, 2008 1:04 AM (in response to unnis)Hello:
Am I missing anything obvious or haven't followed any standards in posting the question ?
thanks and regards,
unnis -
7. Re: Implementing custom datasource
adrian.brock May 21, 2008 12:36 PM (in response to unnis)If the connections are not equivalent then they are not a pool.
However there is something called "re-authentication support" in JCA
which our datasources don't currently implement
http://jira.jboss.org/jira/browse/JBAS-1429 -
8. Re: Implementing custom datasource
unnis May 24, 2008 12:38 AM (in response to unnis)If the connections are not equivalent then they are not a pool.
The connections are equivalent , URL, user name , password are same only. only thing that i want to switch the database .
Thanks & regards
unnis