Forums Register Login

problem with jdbc connect database in bean

+Pie Number of slices to send: Send
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 default.properties 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. " +
e.getMessage());
}
}
+Pie Number of slices to send: Send
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!!
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 955 times.
Similar Threads
JDBC connection and transactions
Using datasource for login bean & login page?
Static Method for Database Connection
can't connect database in bean
an easy test question relating to Bean Management Persistent
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:52:39.