aspose file tools*
The moose likes JBoss/WildFly and the fly likes query datasource with jndi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "query datasource with jndi" Watch "query datasource with jndi" New topic
Author

query datasource with jndi

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi guys,
I hope you can help me. i installed a datasource to a sybase database. When I start the jboss server (v. 3.0.6)I
get the following message:
2003-05-08 10:39:54,861 INFO [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.contentBoxDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/contentBoxDS'

When i try now to query this datasource via the following code from a servlet in the same vm:
DataSource ds = null;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,resource.getString(INITIAL_CONTEXT));
p.put(Context.PROVIDER_URL,resource.getString(PROVIDER_URL));
p.put(Context.URL_PKG_PREFIXES,resource.getString(URL_PKG_PREFIXES));
p.put("jnp.socketFactory",resource.getString(SOCKET_FACTORY));
p.put("jnp.timeout",resource.getString(TIMEOUT));
p.put("jnp.sotimeout",resource.getString(SOTIMEOUT));
try{
Context ctx = new InitialContext(p);
ds = (DataSource)ctx.lookup("java:/contentBoxDS");
}catch(Exception e){
...
}

i get the message:

javax.naming.NameNotFoundException: contentBoxDS not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)

do you have any idea ?

Thx in advance
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: query datasource with jndi