Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

connecting to DB

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

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

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

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
at general.UserService.checkUsername(Userservice.java:41)
at general.UserForm.validate(USerForm.java:29)



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

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?

net.sf.hibernate.exception.SQLGrammarException: Cannot open
at general.UserService.checkUsername(Userservice.java:70)
at general.UserForm.validate(USerForm.java:29)
at org.apache.struts.action.RequestProcessor.processValidate
at org.apache.struts.action.RequestProcessor.process
Caused by: net.sf.hibernate.exception.SQLGrammarException: Cannot
open connection
at net.sf.hibernate.exception.SQLStateConverter.convert
at net.sf.hibernate.exception.JDBCExceptionHelper.convert
at net.sf.hibernate.impl.BatcherImpl.convert
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
Access denied for user ''@'%' to database 'testmysql'
at com.mysql.jdbc.SQLError.createSQLException
at com.mysql.jdbc.SQLError.createSQLException
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.