[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Refering to a datasource wih its ENC name
MarcusDidiusFalco
do-not-reply at jboss.com
Wed Oct 24 07:48:05 EDT 2007
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 at 13
| dc4d5
| 13:41:25,656 INFO [STDOUT] Connection is closed: false
| 13:41:25,656 INFO [STDOUT] org.jboss.resource.adapter.jdbc.WrappedConnection at 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 to
anonymous wrote : DataSource 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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098265#4098265
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098265
More information about the jboss-user
mailing list