title: Hibernate - No Suitable driver found for jdbc:mysql//*
body: <p>I am trying to run hibernate in a Java project that is referenced by a web project. Simple enough except that I can't get hibernate to connect to my database. I have a lot of people describing this problem and getting tons of answers however none seem to work for me.</p>
  
  <p>This is how my <b>hibernate.cfg.xml</b> looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;!-- Database connection settings --&gt;
       &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
       &lt;property name="hibernate.connection.url"&gt;jdbc:mysql//localhost:3306/dbname&lt;/property&gt;
       &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
       &lt;property name="hibernate.connection.password"&gt;commander&lt;/property&gt;
  
       &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;50&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Enable Hibernate's automatic session context management --&gt;
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
      &lt;!-- Enable the second-level cache  --&gt;
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.EhCacheProvider&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;mapping resource="com/amakena/profile/mapping/Credentials.hbm.xml"/&gt;
      &lt;mapping resource="com/amakena/profile/mapping/Profile.hbm.xml"/&gt;
      &lt;mapping resource="com/amakena/profile/mapping/City.hbm.xml"/&gt;
      &lt;mapping resource="com/amakena/profile/mapping/Country.hbm.xml"/&gt;
      &lt;mapping resource="com/amakena/profile/mapping/Gender.hbm.xml"/&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I debugged the code to <b>DriverManagerConnectionProvider</b> class, the exception is thrown attempting the <b>getConnection()</b> method</p>
  
  <pre><code>Connection conn = DriverManager.getConnection(url, connectionProps);
  </code></pre>
  
  <p>I checked the url and connectionProps and they are the ones in hibernate.cfg.xml</p>
  
  <p>I have added <i>mysql-connector-java-3.1.14-bin</i> in my tomcat \lib folder and I can see it in eclipse under Libraries>Apache Tomcat v6.0>. I also added it to my %Javahome%\lib\ext and my CLASSPATH variable (which I know is useless by I am kindda desperate). </p>
  
  <p>I made sure my driver is installed properly by running the following code just before the <b>session.beginTransaction()</b> which in turn leads to <b>DriverManagerConnectionProvider.getConnection()</b>   </p>
  
  <pre><code>Class.forName("com.mysql.jdbc.Driver");
  Properties connectionProperties = new Properties();
  connectionProperties.put("user", "root");
  connectionProperties.put("password", "root");
  DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname", connectionProperties); 
  </code></pre>
  
  <p>I noticed that emitting the first line causes the same exception.</p>
  
  <p>Exception thrown</p>
  
  <pre><code>WARNING: Method execution failed: 
  org.hibernate.exception.JDBCConnectionException: Cannot open connection
  at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
  at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
  at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
  at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
  at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at     org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:345)
  at $Proxy0.beginTransaction(Unknown Source)
  at com.amakena.profile.dao.CredentialsDao.hydrate(CredentialsDao.java:45)
  at com.amakena.profile.ProfileManager.login(ProfileManager.java:19)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
  at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
  at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
  at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
  at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
  at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
  at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  at java.lang.Thread.run(Unknown Source)
  
  Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/dbname
  at java.sql.DriverManager.getConnection(Unknown Source)
  at java.sql.DriverManager.getConnection(Unknown Source)
  at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
  at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
  ... 37 more
  WARNING: --Erroring: batchId[24] message[org.hibernate.exception.JDBCConnectionException: Cannot open connection]
  </code></pre>
  
  <p>I appreciate all the help I could get. Thanks in advance.</p>
  
  <p>Versions Used: Tomcat v6.0 - Hibernate 3.6.6 - Java 6 - Eclipse 3.5.2 R35x  </p>