title: ERROR: No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe
body: <p>This is my first trial application in Hibernate
  I am getting following error</p>
  
  <blockquote>
    <p>ERROR: No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe
    Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Could not open connection
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
        at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1363)
        at com.model.HibernetTest.main(HibernetTest.java:24)
    Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:703)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190)
        at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:192)
        at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:278)
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
        ... 5 more</p>
  </blockquote>
  
  <p>Here is my hibernate.cfg.xml</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;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
  
      &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@localhost:1521:xe&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;sample&lt;/property&gt;
      &lt;property name="hinernate.connection.password"&gt;root&lt;/property&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
  
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;mapping class="com.model.Student" resource="com/model/Student.hbm.xml" /&gt;
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have added odbc jar in my classpath but still I am getting error saying Driver not found. I tried following JDBC connection class and it works great.</p>
  
  <pre><code>public class OracleJDBCExample {
  
  public static void main(String[] args) {
  
      try {
  
          Class.forName("oracle.jdbc.driver.OracleDriver");
  
      } catch (ClassNotFoundException e) {
  
          System.out.println("Where is your Oracle JDBC Driver?");
          e.printStackTrace();
          return;
  
      }
  
      System.out.println("Oracle JDBC Driver Registered!");
  
      Connection connection = null;
  
      try {
  
          connection = DriverManager.getConnection(
                  "jdbc:oracle:thin:@localhost:1521:xe", "sample", "root");
  
          PreparedStatement ps=connection.prepareStatement("select * from Employee");
          System.out.println("*******");
          ResultSet rs=ps.executeQuery();
          System.out.println("---&gt;"+rs.toString());
          if(rs.next()) {
              System.out.println("---&gt; "+rs.getString(1));
          }
          rs.close();
          ps.close();
  
      } catch (SQLException e) {
  
          System.out.println("Connection Failed! Check output console");
          e.printStackTrace();
          return;
  
      }
  
      if (connection != null) {
          System.out.println("You made it, take control your database now!");
      } else {
          System.out.println("Failed to make connection!");
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please help me understand what is wrong with the code?</p>