×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to connect to database using session bean

How to connect to database using session bean

How to connect to database using session bean

(OP)
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
    

RE: How to connect to database using session bean

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

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
http://www.primrose.org.uk

RE: How to connect to database using session bean

(OP)
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'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<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'
'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
<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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close