dcsimg
Session bean connecting a database
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nei_San
Posted On:   Saturday, January 12, 2002 10:05 PM

Hi there, I'm trying to make a session bean connect to a DataSource used by my Entity Beans. I'm using JBuilder5 and Borland Application Server. Here is the code in my SessionBean: InitialContext ic = new InitialContext(); DataSource datasource = (DataSource)ic.lookup("java:comp/env/jdbc/DataSource"); System.out.println("Datasource=" + datasource.toString()); Connection dbConnection = datasource.getConnection(); Statement stmt = dbConnection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT ID FROM PUBLICATION"); rs.next(); System.out.println(rs.getString("   More>>

Hi there,



I'm trying to make a session bean connect to a DataSource used by my Entity Beans. I'm using JBuilder5 and Borland Application Server.



Here is the code in my SessionBean:



InitialContext ic = new InitialContext();


DataSource datasource = (DataSource)ic.lookup("java:comp/env/jdbc/DataSource");


System.out.println("Datasource=" + datasource.toString());


Connection dbConnection = datasource.getConnection();


Statement stmt = dbConnection.createStatement();


ResultSet rs = stmt.executeQuery("SELECT ID FROM PUBLICATION");


rs.next();


System.out.println(rs.getString("ID"));



I have already put a reference to this DataSource in the Deployment Descriptor but I get the following error message:



[Microsoft][ODBC Driver Manager] Data
source name not found and no default driver specified



But with the CMP Entity Beans the DataSource works.



I would appreciatte any help. Thanks in advance.



Nei.

   <<Less

Re: Session bean connecting a database

Posted By:   Bozidar_Dangubic  
Posted On:   Sunday, January 13, 2002 05:43 AM

so this session bean has a reference to this DataSource in the deployment descriptor, right? and both the CMP that works with this DataSource and Session bean that does not work with this data source are deployed in the same EJB container?
About | Sitemap | Contact