wood burning stoves 2.0*
The moose likes Groovy and the fly likes Error in MySQL Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Error in MySQL Connection" Watch "Error in MySQL Connection" New topic
Author

Error in MySQL Connection

Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

Hi all,

I have created a sample application with MySQL as a backend. I did all the configurations for MySQL like changing the values in DataSource.groovy file. When i run the application i get an error lik this



Can anyone tel how to solve this issue
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Caused by SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.driver'


Include the driver for MySQL to your code and it will work.


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Before posting please CarefullyChooseOneForum
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

Thank you, it got worked... but where it is stored ??? when i say path like jdbc:mysql//localhost:3306/db_name, if i see the db_name file nothing inside. By default where it will be stored
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

I am sorry, i did not get your question..
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

k let me tell it clear.. i have configured in datasource file with jdbc://mysql/localhost/db_name. Now the db_name is the database name that should be created and updated with corresponding columns. Am not getting any error but i want to know where the database is created. If its in my system am sure it doesnt created since i analysed my all sql files. so where the databse file is created this is my question. hope you got now
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Unless you write code to create a database schema, it will not be created for you by the connection alone. You would need to do that yourself and then your JDBC code connects to said schema so you can perform operations on it. You should read the basic JDBC Tutorial so that you understand what you're doing.


GenRocket - Experts at Building Test Data
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

George i think you dint get me yet. My database connection is working well without any error i can view and add some data also. My question is i cant see the values what am adding and viewing in the mysql browser. Do the grails store the values am adding somewhere.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Sabarish Venkat wrote:George i think you dint get me yet.


Who is George?

Sabarish Venkat wrote:My database connection is working well without any error i can view and add some data also. My question is i cant see the values what am adding and viewing in the mysql browser. Do the grails store the values am adding somewhere.


What "mysql browser" are you using? How can you be sure the values are saving if you can't see the data? Grails fails silently if there are validation errors. You're probably going to have to show us at the very least a Domain class and the Controller code where you are populating and saving the data.

You also might want check for validation errors (if you're not already) in the controller to see what is happening. Or you can add failOnError: true to the save() method and it will throw an exception if validation fails.
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

Sorry Gregg i dint see your name properly .. Am saying about MySQL Query Browser to view the schemas.. I can see the output in browser without any errors. using scaffold i can add dynamic data also no errors am seeing but in the case like if i want to take back up the application how can i take without seeing it. am getting doubt whether data are saving are not also
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

Else can anyone give a sample app connecting with MYSQL as an example so that i will be clear how it works exactly what mistake am doing.
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 136

Hi gregg and all i got it worked ... what the mistake i did is in buildconfig.groovy the dependencies of MySQL should be runtime 'mysql:mysql-connector-java:5.1.16' . I dint do this earlier. Also the data i viewed and stored is in tempDB that i was not aware thinking that it is inserting inside. Now everything got cleared. Thanks to one and all.

Regards,
Sabi
 
jQuery in Action, 2nd edition
 
subject: Error in MySQL Connection