Datasource problames + accessing the, outside of a container  
Author Message
hjc





PostPosted: 2005-7-15 21:54:00 Top

java-programmer, Datasource problames + accessing the, outside of a container Hi,

I'm completely new to J2EE and currently struggling with datasources.

We have a Oracle database we'd like to access via jboss. I've set it up as a
datasource using the oracle-xa-ds.xml fiel as an example. This appears to
have worked, in as much as we can now see it via JNDIView .

I'm having no luck actually using it however.

To test I created a servlet containg the following code :-

try
{
ic = new InitialContext();
ic.addToEnvironment("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
ic.addToEnvironment("java.naming.provider.url","jnp://localhost:1099");
ic.addToEnvironment("java.naming.factory.url.pkgs","org.jboss.naming.client");
ic.addToEnvironment("j2ee.clientName", "test");
}
catch (NamingException e)
{
out.println("Could not create JNDI " + "context: " +
e.toString());
}

try
{

DataSource ds = (DataSource) ic.lookup("java:XAOracleDS":);
con = ds.getConnection();
}
catch (Exception ex)
{
out.println("Unable to connect to database. " + ex.getMessage());
}

This fails telling me that test is not bound.

What am I doing wrong?

Our eventual plan is to have applications access this datasource from
outside of jboss. I've seen a couple of posts now suggesting that this might
not be possible. Can anyone confirm if this is the case?

Thanks

hjc


 
hjc





PostPosted: 2005-7-16 14:23:00 Top

java-programmer >> Datasource problames + accessing the, outside of a container >
> Our eventual plan is to have applications access this datasource from
> outside of jboss. I've seen a couple of posts now suggesting that this
> might not be possible. Can anyone confirm if this is the case?
>

We finally got this sorted after we added

<use-java-context>false</use-java-context>

to our datasource. We haven't tested it yet, but we think this should let us
access the datasource from outside of jboss as we'd hoped to do.

We've no idea why it made everything else start working, we're just
grateful.


hjc