"jitesh_popat" wrote : Hi Scott,
|
| Thanks a lot for your reply.
|
| Agreed, I was able to bind the datasource to global JNDI. But while trying
to get it from a remote client, I directly do not get back
"javax.sql.DataSource" instance, instead I get "javax.naming.Reference" object.
Why is this? In case of weblogic I can directly get a DataSource remotely.
|
| Further, after spending lot of effort, I somehow got the DataSourec in a
contrived way using the following code (Honestly speaking, this is a cheap copy
of org.jboss.resource.adapter.jdbc.remote.DataSourceFactory):
|
| Object obj = context.lookup("jdbc/OracleDS");
| javax.naming.Reference ref = (javax.naming.Reference)obj;
| BinaryRefAddr proxyAddr = (BinaryRefAddr)ref.get("ProxyData");
| byte[] proxyBytes = (byte[])proxyAddr.getContent();
| ByteArrayInputStream bi = new ByteArrayInputStream(proxyBytes);
| ObjectInputStream ois = new ObjectInputStream(bi);
| Object instance = ois.readObject();
| if (instance instanceof javax.sql.DataSource){
| // System.out.println("I am happy");
| ds = (javax.sql.DataSource)instance;
| }
|
| However, now when I try to execute a JDBC statement as follows, I get an
"java.lang.reflect.UndeclaredThrowableException":
|
| Connection con = ds.getConnection();
| Statement st = con.createStatement(); // exception is thrown in this line.
|
| Please help.
|
| Regards,
| Jitesh Kumar Popat
|
Hi jitesh,
I was able to get the datasource fairly straightforward as scott pointed
out in jboss 4.0. Here's my test code snippet (Oracle 9i db),
Object raw = initialcontext.lookup("ds/myDataSource");
DataSource ds= (DataSource)
PortableRemoteObject.narrow(raw,DataSource.class);
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("select * from test_table");
I doubt this works on anything less than jboss 4.0, if i'm wrong about this
someone please correct me. Hope this helps.
Cheers,
Steven Peh
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3865497#3865497
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3865497
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user