Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can't connect database in bean  RSS feed

ken123 lai
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have download mssqlserver2000 jdbc driver , and
include them into classpath, while i connect database in java application, it works perfect,
but when i connect it from bean, it output error:
"unable to connect database:access denied", i had added the with jdbc drivers, and the bean also works ok while using cloudscape.
can anybody help me, thanks!!
the code framework as follow:
public void setEntityContext(EntityContext context) {
this.context = context;
try {
Context ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection("sa","");
} catch (NamingException e){
throw new EJBException("namingexception:"+e.getMessage());
catch (SQLException e){
throw new EJBException("sql error: " + e.getMessage());
catch (Exception e) {
throw new EJBException("Unable to connect to database. " +
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!