It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Confuguring mySql for entity beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Confuguring mySql for entity beans" Watch "Confuguring mySql for entity beans" New topic
Author

Confuguring mySql for entity beans

KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
Hi All,
I am using MySql as database for trying out entity bean examples.
Can anybody tell me how to use information about MySql in deploymenttool, so that my bean will make use of tables in MySql.

Thanks and Regards,
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3205
    
    2
It is not clear what exactly you are trying to do. Which IDE/deployment tool/appserver are you using?

Regardless, you will need mysql jdbc driver added to your server's classpath (if it is not there already). Just drop the jar in its lib folder.

Next, from the admin GUI of the app server, configure a connectionpool and datasource that uses your database. While creating datasource, use the JNDI name that you have used in your persistence.xml. For example, if you have used <jta-data-source>jdbc/ejbplus</jta-data-source> in persistence.xml, use name the datasource as ejbplus.

If you want to create entities corresponding to existing tables in your database, you will need to configure a database connection (that points you the database that you want) in your IDE and then use its GUI to generate the entities for the tables. You will still need to configure datasource in appserver when you deploy the application.

HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
KRK Gowda
Ranch Hand

Joined: Nov 02, 2004
Posts: 132
Hi Paul,
Thanks for reply
I am using J2EE RI. I had copied MySql from my friend's PC. I think i didnt copied any drivers for MySql. In that case, i will download driver.
I dont know (my friend too) username and password for MySql. He was starting database and running command Mysql -console from bin folder in MySql directory, and we get MySql prompt.
How to provide information about MySql to Entity Bean while deploying in the deploytool of J2EE RI?


Thanks and Regards,
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3205
    
    2
You can download the driver from http://www.mysql.com/products/connector/j/

Originally posted by KRK Gowda:
[QB]Hi Paul,
I dont know (my friend too) username and password for MySql. He was starting database and running command Mysql -console from bin folder in MySql directory, and we get MySql prompt.
[QB]


So are you able to run mysql the same way on your machine? Are you able to fire sqls on mysql cmd window? (e.g. try "show databases"). If you are able to do that, that means your db is working and you are using default username and password which, if I remember correctly, is "root" and password is empty. Anyhow, just create a new user from the mysql command window:
mysql> GRANT ALL ON *.* TO gowda@localhost IDENTIFIED BY 'mypassword';

Use this user name and password and follow the steps described in my previous post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confuguring mySql for entity beans
 
Similar Threads
Entity Beans must use CMP?
ejb server provide persistence means ?
Entity Bean and DAO
i am tring to create Entity bean connect to mysql Database using GlassFish Tools-Help
Txn not automatically rolling back after RemoteException