reset password
Author Message
raylongma1018
Posts: 81
Posted 11:27 Jul 10, 2015 |

Hi Dr.Sun

When I work on step 3 on the spring and hibernate from scratch and follow your step and try to test on your codes 

When I click run on servers and go to the http://localhost:8080/springmvc/users.html page to see if it is working 

but i produces the following error:

 HTTP Status 500 - Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.GenericJDBCException: Could not open connection; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection

I wonder if this is has something to do with my dependencies?

I can commit my project to the cs3 server if you want to check why it happens?

raylongma1018
Posts: 81
Posted 12:02 Jul 10, 2015 |

on this step I also look at your code for spring-mvc and test it, and yours is working, so I believe it shouldn't be my computer's probelm.

I try to compare with your code with my code to see if there is any differences. I even borrow your dependencies setting from your pom.xml to my pom.xml, but unfortunately it is still not working. 

The only difference I can see is that your spring-mvc project has the JPA-Content that stores the persistance.xml, but my project which followed by your toturial do not. we store it in META-INF folder which your code also store in there too. 

and I see the error has something to do with the persistance, this is all I know

raylongma1018
Posts: 81
Posted 14:07 Jul 10, 2015 |

quick question:

so for step 3 on the spring and hibernate from scratch part if I am able to use hbm2ddl.java to create csjobs.ddl under the scripts folder generated by the jpa annotation. Does that means my hibernate is working? 

I am kinda have trouble testing your codes in your toturial. maybe I missed something. If I am able to generate the sql statement inside the csjobs.ddl, does that means I don't have to worry about failure of testing your codes in the tutorial?

cysun
Posts: 2935
Posted 14:48 Jul 10, 2015 |

Read the error messages carefully. There should be information there that tells you why the connection could not be opened. Most common problems are related to database account and privileges. In particular, make sure you have a csjobs database, a csjobs database user, and the csjobs database user owns the csjobs database as well as all the tables inside.

Hbm2ddl scans the classes and use the annotations found in the classes to create some DDL statements. That's all it does. So hbm2ddl being successful doesn't mean everything else will work.