• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in MySQL Connection

 
Sabarish Venkat
Ranch Hand
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caused by SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.driver'


Include the driver for MySQL to your code and it will work.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before posting please CarefullyChooseOneForum
 
Sabarish Venkat
Ranch Hand
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry, i did not get your question..
 
Sabarish Venkat
Ranch Hand
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Sabarish Venkat
Ranch Hand
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic