-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: java.sql.SQLException: No suitable driver
PostPosted: Wed Mar 09, 2005 2:51 pm 
Newbie

Joined: Fri Feb 11, 2005 7:21 am
Posts: 3
I have a problem with hibernate over MySQL. I can't connect with the database, but I think that my driver is ok. Can anyone help me, please??

Hibernate version: 2.1.7

Mapping documents:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- connection to oracle database -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:@138.4.4.236:3308:mailBBDD</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">riza812</property>

<!-- other properties -->
<property name="hibernate.show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- connection pooling -->
<!-- hibernate provides C3PO connection pooling, but this is not suitable for production envs -->
<!-- thus, DBCP (org.apache.commons.dbcp; commons-dbcp-1.2.jar) or other connection pools should be used -->
<property name="hibernate.c3po.min_size">5</property>
<property name="hibernate.c3po.max_size">20</property>
<property name="hibernate.c3po.timeout">1800</property>
<property name="hibernate.c3po.max_statements">50</property>

<!-- <property name="hibernate.cglib.use_reflection_optimizer">true</property> -->

<!-- Mapping files -->
<mapping resource="MAILOperators.hbm.xml"/>
<mapping resource="MAILProfile.hbm.xml"/>
<mapping resource="MAILOperations.hbm.xml"/>
<mapping resource="MAILCustomer.hbm.xml"/>
<mapping resource="MAILIssue.hbm.xml"/>
<mapping resource="MAILEvent.hbm.xml"/>
<mapping resource="MAILAccount_Data.hbm.xml"/>
<mapping resource="MAILEvent_Type.hbm.xml"/>
<mapping resource="MAILUser_Personal_Data.hbm.xml"/>

</session-factory>

</hibernate-configuration>



Code between sessionFactory.openSession() and session.close():

try {
Session hibSession = hibernateSessionFactory.openSession();
Query queryProfiles=hibSession.createQuery("from MAILProfile pf order by pf.id");
List dbProfilesList=queryProfiles.list();
if (dbProfilesList.size()==0){
hibSession.close();
logger.debug("There was any profile");
}
Object[] dbProfilesArray=dbProfilesList.toArray();
Set dbProfilesSet=new HashSet();
for (int i=0; i<dbProfilesArray.length; i++){
MAILProfile profile=(MAILProfile)dbProfilesArray[i];
dbProfilesSet.add(profile);
}
if (dbProfilesSet.size()==0){
hibSession.close();
logger.debug("There was a cast exception");
}
hibSession.close();
return dbProfilesSet;
}
catch(HibernateException e){
e.printStackTrace();
}
return null;

Full stack trace of any exception that occurs:

?ERROR [util.JDBCExceptionReporter]: No suitable driver
?ERROR [util.JDBCExceptionReporter]: Cannot open connection
?java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3302)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3282)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
net.sf.hibernate.JDBCException: Cannot open connection
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:281)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3302)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3282)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at BBDD.MAILDelegate.listProfiles(MAILDelegate.java:342)
at MAILTests.viewProfiles(MAILTests.java:26)
at MAILTests.main(MAILTests.java:12)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
... 14 more
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at BBDD.MAILDelegate.listProfiles(MAILDelegate.java:342)
at MAILTests.viewProfiles(MAILTests.java:26)
at MAILTests.main(MAILTests.java:12)
DEBUG [BBDD]: There was an exception: java.lang.NullPointerException

Name and version of the database you are using: MySQL 4.1.9


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 3:44 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
Have you added mysql-connector-java-3.1.6-bin.jar to your project directory?


Top
 Profile  
 
 Post subject: I'm using 3.1.7 mySQL driver...
PostPosted: Thu Mar 10, 2005 7:09 pm 
Newbie

Joined: Fri Feb 11, 2005 7:21 am
Posts: 3
Yes, I'm using the latest mySQL driver and I think that it's in the application classpath (I'm working with NetBeans IDE), but it doesn't work :(

Thanks
Joaquín López Rizaldos


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 10:34 am 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
I don't know if this will help, but I saw a related post:
http://forum.hibernate.org/viewtopic.php?t=939885

The error was with hibernate.connection.url

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 5:30 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
I faced a similar problem . I am using WSAD and it was not able to find the hibernate.cfg.xml,hibernate.properties files in the classpath. I put the files at the top of the JavaSource (default source) directory hierarchy and it worked fine.

Hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.