If you are using glassfish 3.1, try to do the following :
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.put(Context.PROVIDER_URL,
"service:jmx:rmi://HOSTNAME:8686/jndi/rmi://HOSTNAME:8686/jmxrmi");
try
Context ctx = new InitialContext(props);
Object ref =
ctx.lookup("jdbc/__default");
DataSource ds =
(DataSource)PortableRemoteObject.narrow(ref, DataSource.class);
Connection con = ds.getConnection();
} catch(Exception ex) {
}
In the above, you could also substitute Context.PROVIDER_URL with
IIOP://localhost:3700.
Compile the program, and include $S1AS_HOME/lib/gf-client.jar in your
classspath while executing. Hope this helps.
--
[Message sent by forum member 'sm157516']
View Post: http://forums.java.net/node/784040