-
1. Re: JBoss 3.0, JDBC and DataSource
jmoring Jun 29, 2002 10:56 PM (in response to asharzaman)Use hsqldb-service.xml as an example. Is is in the deploy directory under the default configuration.
Jim -
2. Re: JBoss 3.0, JDBC and DataSource
javaguy Jun 30, 2002 6:10 PM (in response to asharzaman)asharzaman,
You can find the example configuration in the %JBOSS_HOME%/docs/example/jca/db2-service.xml and go from there. I have not worked with DB2 but so far I was able to get the Oracle and MySQL working fine.
JG -
3. Re: JBoss 3.0, JDBC and DataSource
asharzaman Jun 30, 2002 6:59 PM (in response to asharzaman)Thanks for the reply everyone. I made the changes and the server says that the Data Source was bound. When I try to lookup the DS, I get NameNotFoundException. When I try to lookup other beans in the JNDI, I have no problems.
Any suggestions?
Thanks
Ashar -
4. Re: JBoss 3.0, JDBC and DataSource
javaguy Jun 30, 2002 9:55 PM (in response to asharzaman)asharzaman,
Do you have an example of how you call it? Please post it, we might be able to help you debug or solve the problem.
JG -
5. Re: JBoss 3.0, JDBC and DataSource
asharzaman Jun 30, 2002 10:42 PM (in response to asharzaman)JavaGuy,
Thanks for your reply. When the server starts, I get that the data source was bound to JNDI. Here is the message:
20:38:23,067 INFO [Ashar] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/Ashar'
Here is my test Code
import javax.ejb.*;
import javax.naming.*;
import java.util.*;
public class JBossClient {
private Context getInitialContext() {
String url = "jnp://localhost:1099";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS,
password == null ? "" : password);
}
return new InitialContext(properties);
} catch (Exception e) {
System.out.println("Unable to connect to JBoss server at " + url);
e.printStackTrace();
}
return null;
}
public JBossClient() {
Context ctx = getInitialContext();
try {
Object o = ctx.lookup("Ashar");
// Object o = ctx.lookup("java:/Ashar");
// Object o = ctx.lookup("MyBean"); // Works
System.out.println("done");
} catch(Exception ex) {
System.out.println(ex.toString());
}
}
public static void main(String[] args) {
JBossClient j = new JBossClient();
}
}
Again, Thank you for your help.
Ashar Zaman -
6. Re: JBoss 3.0, JDBC and DataSource
javaguy Jul 1, 2002 12:53 AM (in response to asharzaman)asharzaman,
From what I saw in you code that should have worked fine with the:
.
.
.
Object o = ctx.lookup("java:/Ashar");
.
.
.
I cast mine to Datasource and get a connection with it to test using a simple query.
JG -
7. Re: JBoss 3.0, JDBC and DataSource
davidjencks Jul 1, 2002 8:40 AM (in response to asharzaman)It's not 100% clear where you are running your client, but you can only access the java: context within the jboss vm. So you should test your datasource from a session bean or an mbean.
-
8. Re: JBoss 3.0, JDBC and DataSource
asharzaman Jul 1, 2002 3:08 PM (in response to asharzaman)What you are talking about is Remote vs. Local interfaces (I think). Well, I should be able to do a lookup. If I can lookup any other bound object from JNDI (remote), it is not any different. Well, I don't know what else to do. Again, thanks for everybody's help.
Ashar -
9. Re: JBoss 3.0, JDBC and DataSource
tbfmicke Jul 1, 2002 5:46 PM (in response to asharzaman)Not to presume too much but I think he meant what he wrote :-)
As you have seen a datasource named DefaultDS (for example) is put in JNDI with the name java:/DefaultDS.
But (I think this is something specific for JBoss) anything in the java: namespace can only be found when it is looked up from inside JBoss. So as he said... try the lookup from inside an EJB or servlet and it should succeed.
I guess that the reasoning here is that it might be a security problem to give out a connection to a database to anybody that can get the right JNDI name...
Regards
Mikael -
10. Re: JBoss 3.0, JDBC and DataSource
asharzaman Jul 1, 2002 7:21 PM (in response to asharzaman)Mikael and David,
I really appreciate your help. You were correct when you suggested that anything bound to java:/ tree can only be looked up from within the JBoss JVM.
Again, I want to thank everyone for their help with this problem.
Ashar -
11. Re: JBoss 3.0, JDBC and DataSource
javaguy Jul 2, 2002 3:28 PM (in response to asharzaman)asharzaman,
Sorry for not reading the message correctly.
JG -
12. Re: JBoss 3.0, JDBC and DataSource
buster Jul 2, 2002 9:47 PM (in response to asharzaman)But how do you get a PooledDataSource, or a ConnectionPool.
Thanks -
13. Re: JBoss 3.0, JDBC and DataSource
rschiavi Jul 18, 2002 5:47 PM (in response to asharzaman)
a simple question, i see the db2-service.xml, but like, where does it go?
i used 2.x and can't figure out this new setting up a datasource dance.
thanks!
rich -
14. Re: JBoss 3.0, JDBC and DataSource
rschiavi Jul 18, 2002 8:39 PM (in response to asharzaman)
So, if you can only access "java:/" bound JNDI in the jboss jvm, how can you bind a datasource so a remote client (say a junit test harness app) can access those JNDI things?
Thanks,
Rich