File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes problem with jdbc connect database in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem with jdbc connect database in bean" Watch "problem with jdbc connect database in bean" New topic

problem with jdbc connect database in bean

ken123 lai

Joined: Apr 12, 2002
Posts: 3
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. " +
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
ken123 lai
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

I agree. Here's the link:
subject: problem with jdbc connect database in bean
It's not a secret anymore!