There's something I'm not understanding about datasources.

I have a utility class that includes the following method:

  public static Connection getConnection() throws SQLException {
    try {
      InitialContext ic = new InitialContext();
      DataSource ds = (DataSource)ic.lookup("java:/mysql");
      
      return(ds.getConnection());
    }
    catch (NamingException e) {
      // Log exception
      throw(new SQLException("Datasource not found: " +
                             e.getMessage()));
    }
  }
  
When called from an entity bean, this method works fine.  However,
when called from outside an entity bean, I get:

NamingException: mysql not bound

The jboss server.log reports that java:/mysql is bound (I also know
it is bound because it works from the entity bean):

[mysql] Starting
[mysql] XA Connection pool mysql bound to java:/mysql
[mysql] Started

The class that is calling this method also uses the entity bean that
uses the same method and the entity bean works fine.

Is there something I need to do in my non-entity bean code that the
entity bean is doing for me?

Thanx.

Norton

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to