Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

connecting to DB

  Asked By: Kiswar    Date: Oct 19    Category: Java    Views: 786
  

I use struts, hibernate and mysql, can someone help connecting to
mysql. which .jar files needed.


hibernate.properties:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///testmysql
hibernate.connection.username
hibernate.connection.password

error in IE:
java.lang.RuntimeException: net.sf.hibernate.HibernateException:
JDBC Driver class not found: com.mysql.jdbc.Driver
at general.ConnectionFactory.(ConnectionFactory.java:36)
at general.ConnectionFactory.getInstance
(ConnectionFactory.java:45)
at general.UserService.checkUsername(Userservice.java:41)
at general.UserForm.validate(USerForm.java:29)
...

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Sebastien Anderson     Answered On: Oct 19


You should download MySQL's JDBC Driver (Connector/J) and copy its JAR file to your classpath.

 
Answer #2    Answered By: Hu Chalthoum     Answered On: Oct 19

u can download mysql  JDBS DRIVER from here
dev.mysql.com/downloads/connector/j/5.1.html

 
Answer #3    Answered By: Danny Perkins     Answered On: Oct 19

thanks for answering, know i get this error. how can I introduce
location of my DB in DATA folder in mysql  to hibernate?


java.lang.RuntimeException:
net.sf.hibernate.exception.SQLGrammarException: Cannot open
connection
at general.UserService.checkUsername(Userservice.java:70)
at general.UserForm.validate(USerForm.java:29)
at org.apache.struts.action.RequestProcessor.processValidate
(RequestProcessor.java:919)
at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:204)
...
Caused by: net.sf.hibernate.exception.SQLGrammarException: Cannot
open connection
at net.sf.hibernate.exception.SQLStateConverter.convert
(SQLStateConverter.java:58)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert
(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.BatcherImpl.convert
(BatcherImpl.java:328)
...
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
Access denied for user ''@'%' to database 'testmysql'
at com.mysql.jdbc.SQLError.createSQLException
(SQLError.java:1027)
at com.mysql.jdbc.SQLError.createSQLException
(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
...


is J2ee(struts,...) opensource?
which j2ee framework now is used?
does tomcat4,struts,hibernate,mysql match together well?

 
Answer #4    Answered By: Riley-jack Johnson     Answered On: Oct 19

I think you have no privilege (access) to DB.
Check your username and password in hibernate  configs.

 
Answer #5    Answered By: Kawthar Malik     Answered On: Oct 19

thanks it was username's error.............

 
Didn't find what you were looking for? Find more on connecting to DB Or get search suggestion and latest updates.




Tagged: