Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to connect to database using session bean

Status
Not open for further replies.

nkmb

Programmer
May 10, 2006
33
0
0
US
Hi,

I am learning J2ee.I want to know is there any way to connect to the database using session bean,if yes,could u please tell me the process.

Thanks,
nkmb
 
The same way you would connect to a database in any Java application - use JDBC (google it).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Hi,

I wrote the code for connecting db through session bean.
I am getting following error while doing ejbc.

<error>
java weblogic.ejbc db.jar

ERROR: ejbc found errors while parsing the descriptor for db.jar:



ERROR: Error from ejbc: Error parsing file 'META-INF/weblogic-ejb-jar.xml' at li
ne: 16 column: 28. The content of element type "weblogic-enterprise-bean" must
match "(ejb-name,(entity-descriptor|stateless-session-descriptor|stateful-sessio
n-descriptor|message-driven-descriptor)?,transaction-descriptor?,iiop-security-d
escriptor?,reference-descriptor?,enable-call-by-reference?,clients-on-same-serve
r?,(run-as-identity-principal|run-as-principal-name)?,create-as-principal-name?,
remove-as-principal-name?,passivate-as-principal-name?,jndi-name?,local-jndi-nam
e?,dispatch-policy?,remote-client-timeout?)".


ERROR: ejbc couldn't load descriptor from jar
</error>

i am sending my weblogic.xml and ejb-jar.xml

<code>

<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'<ejb-jar>
<enterprise-beans>
<session>
<display-name>HelloWorld</display-name>
<ejb-name>statelessSession</ejb-name>
<home>examples.HelloHome</home>
<remote>examples.Hello</remote>
<ejb-class>examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
</enterprise-beans>
</ejb-jar>

<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN'
'<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>statelessSession</ejb-name>
<enable-call-by-reference>True</enable-call-by-reference>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/test</res-ref-name>
<jndi-name>mysqlpool</jndi-name>
</resource-description>
</reference-descriptor>
<jndi-name>HelloHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

somebody please help me.


thanks,
nkmb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top