title: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${driver}'
body: <p>I am a beginner in spring. Here is my <strong>beans.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
                          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  
  &lt;bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="location" value="DB.properties" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" &gt;
          &lt;property name="driverClassName" value="${driver}"/&gt;
          &lt;property name="url" value="${url}"/&gt;
          &lt;property name="username" value="${uname}"/&gt;
          &lt;property name="password" value="${pwd}"/&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>And DB.properties is given below:</strong></p>
  
  <pre><code>#database connection propertiess
  driver=com.mysql.jdbc.Driver
  url=jdbc:mysql://localhost:3306/Payment
  uname=root
  pwd=renu@193
  </code></pre>
  
  <p><strong>I am getting this error given below:</strong></p>
  
  <pre><code>        Apr 04, 2014 11:07:25 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
  INFO: Loading XML bean definitions from class path resource [beans.xml]
  org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${driver}'
      at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
      at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
      at com.student.spring.test.RunClass.main(RunClass.java:22)
  Caused by: java.lang.ClassNotFoundException: ${driver}
  
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
      ... 3 more
  </code></pre>
  
  <p>I know what is this error. This error is about class BasicDataSource.  This class is not found...... but i already included the required jars in build path in my project.
  Jars is as given below......
  a)/home/praveen/Downloads/commons-dbcp-1.4.jar
  b)/home/praveen/Downloads/org.apache.commons.pool.jar</p>
  
  <p>I have read some where that may be the version of jars causing the problem... and interfering with each other.....</p>
  
  <p>The jars are already available in project build path.... Please help me to solve this problem. Any help would be appreciated by me....</p>
  
  <p><strong>The RunClass.java is given below:</strong></p>
  
  <pre><code>package com.student.spring.test;
  
  import java.sql.Connection;
  import java.sql.SQLException;
  
  import org.apache.commons.dbcp.BasicDataSource;
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  @SuppressWarnings("deprecation")
  public class RunClass {
      public static void main(String[] args) {
          Resource resource = new ClassPathResource("beans.xml");
          BeanFactory factory = new XmlBeanFactory(resource);
  
  
          BasicDataSource bds = (BasicDataSource) factory.getBean("myDataSource");        
          Connection connection;
          try {
              connection = bds.getConnection();
              System.out.println(bds.getDriverClassName());
              System.out.println(bds.getUrl());
              System.out.println(bds.getUsername());
              System.out.println(bds.getPassword());
              connection.close();
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>