This content has been marked as final.
Show 3 replies
-
1. Re: Refering to a datasource wih its ENC name
marcusdidiusfalco Oct 24, 2007 5:46 AM (in response to marcusdidiusfalco)OK found out the error myself:
jboss.xml should be<?xml version="1.0" encoding="UTF-8"?> <jboss> <enterprise-beans> <session> <ejb-name>TestBean</ejb-name> <resource-ref> <res-ref-name>jdbc/FencingDS</res-ref-name> <jndi-name>java:/DefaultDS</jndi-name> </resource-ref> </session> </enterprise-beans> </jboss>
(I did not use the jndi-name element) -
2. Re: Refering to a datasource wih its ENC name
marcusdidiusfalco Oct 24, 2007 7:48 AM (in response to marcusdidiusfalco)Ok the Bean is now deployed, but it seems I can get a connection from the datasource, but somehow I cannot work with it:
ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/FencingDS"); System.out.println(ds.toString()); Connection con = (Connection) ds.getConnection(); System.out.println("Connection is closed: " + con.isClosed()); System.out.println(con.toString() + " " + con.getCatalog()); Statement stmt = con.createStatement(); ResultSet resultSet = stmt.executeQuery("SELECT * FROM fencer"); while (resultSet.next()) { System.out.println(resultSet.getString("firstName")); System.out.println(resultSet.getString("lastName")); }
I know that the Select should work, because I have copied it from thy MySQL console.13:41:21,109 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.1.GA/server/defau lt/deploy/GeneralTest.jar 13:41:25,656 INFO [STDOUT] org.jboss.resource.adapter.jdbc.WrapperDataSource@13 dc4d5 13:41:25,656 INFO [STDOUT] Connection is closed: false 13:41:25,656 INFO [STDOUT] org.jboss.resource.adapter.jdbc.WrappedConnection@17 b650a null 13:41:25,656 ERROR [STDERR] java.sql.SQLException: Table not found in statement [SELECT * FROM fencer]
When I change the lookup toDataSource ds = (DataSource) ctx.lookup("java:FencingDS");
everything works fine.
So I guess, I still have some problem with the mapping of the jndi-Names.
Can somebody help me out with this problem please?
Thanks,
Hans -
3. Re: Refering to a datasource wih its ENC name
shelly.mcgowan Oct 26, 2007 1:13 PM (in response to marcusdidiusfalco)From the trace it looks like the Tables were not created in the DB.