title: Error creating bean ... could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
body: <p>I have written code to run a query using JDBC on Spring but I get an exception (see below)</p>
  
  <p>Here's my context.xml</p>
  
  <pre><code> &lt;bean id="dataSource" 
         class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
     &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/&gt;
     &lt;property name="url" value="jdbc:oracle:thin:@Mohsen-PC:1521:mydb"/&gt;
     &lt;property name="username" value="system"/&gt;
     &lt;property name="password" value="123"/&gt;    
   &lt;/bean&gt;
  
   &lt;bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"&gt;
     &lt;property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/&gt;
   &lt;/bean&gt;
  
   &lt;bean id="nativeJdbcExtractor" 
       class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"/&gt;
  
   &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
     &lt;property name="dataSource" ref="dataSource"/&gt;
   &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>main.java</p>
  
  <pre><code>import javax.sql.DataSource;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  import org.springframework.jdbc.core.JdbcTemplate;
  
  class Main {
  
    public static void main(String args[]) throws Exception {
  
      ApplicationContext ac = new ClassPathXmlApplicationContext("context.xml");
  
      DataSource dataSource = (DataSource) ac.getBean("dataSource");
  
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
  
      System.out.println(jdbcTemplate.queryForList("select EMPLOYEE_ID from EMPLOYEE", 
                                                    Long.class));
    }
  }
  </code></pre>
  
  <p>The exception I see is:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'dataSource' defined in class path resource [context.xml]: 
    Error setting property values; nested exception is 
    org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: 
    Property 'driverClassName' threw exception; nested exception is 
    java.lang.IllegalStateException: Could not load JDBC driver class 
    [oracle.jdbc.driver.OracleDriver] at 
    org.springframework.beans.factory.support.
                               AbstractAutowireCapableBeanFactory.applyPropertyValues(
                                                  AbstractAutowireCapableBeanFactory.java:1396)
  </code></pre>
  
  <p>EDIT: cut remainder of stack trace as the above exception is sufficient to illuminate the problem.</p>
  
  <p>What is going wrong here?</p>