Ok folks... 

Here's what I have found out. Contrary to what I believed, it seems
the Orion console uses another trick than a DataSource to run SQL 
commands on the server: the executeSQL method of the
ApplicationAdministrator
class. I have managed to run commands from my client program using this 
snippet :

java.util.Properties p = new java.util.Properties();

p.put("java.naming.factory.initial",
      "com.evermind.server.ApplicationClientInitialContextFactory");
p.put("java.naming.provider.url", "ormi://server/application");
p.put("java.naming.security.principal", "admin");
p.put("java.naming.security.credentials", "yoursecret");

ctx = new InitialContext(p);

ApplicationAdministrator appAdmin = (ApplicationAdministrator)
     context.lookup("java:comp/Administrator");

RowSet rs = appAdmin.executeSQL("jdbc/pooled/MyDS", "SELECT * FROM
TestTable");

This returns a serializable rowset from the server... That's it. Not
portable,
very disappointing. I really hoped DataSources would work from the
client side.
It seems you can only do it through the appadmin. PLEASE CORRECT ME IF
I'M WRONG :)

On another note, this line retrieves the list of all datasources for an
application

List sources = appAdmin.getDataSources();       

this is a List of DataSourceConfig objects, NOT DataSource. DSC contain
info about 
the various JNDI locations, username, password etc. all the properties
defined 
in data-sources.xml

Hope this turns out helpful to some of you!

Cheers,

Daniel

Reply via email to