title: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL postgres://username:password@localhost:5432/dbname
body: <p>I have deployed two Spring roo application on Tomcat 7 server both have database connection while hitting any service of application I am getting below exception</p>
  
  <pre><code>Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'postgres://username:password@localhost:5432/db'
  java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getDriver(DriverManager.java:278)
      at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
      at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
      at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:279)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:124)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
  </code></pre>
  
  <p>Please find below database base configuration </p>
  
  <p>Application 1</p>
  
  <p>application-Context.xml </p>
  
  <pre><code>&lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
      &lt;property name="driverClassName" value="${database.driverClassName}"/&gt;
      &lt;property name="url" value="${database.url}"/&gt;
      &lt;property name="username" value="${database.username}"/&gt;
      &lt;property name="password" value="${database.password}"/&gt;
      &lt;property name="testOnBorrow" value="true"/&gt;
      &lt;property name="testOnReturn" value="true"/&gt;
      &lt;property name="testWhileIdle" value="true"/&gt;
      &lt;property name="timeBetweenEvictionRunsMillis" value="1800000"/&gt;
      &lt;property name="numTestsPerEvictionRun" value="3"/&gt;
      &lt;property name="minEvictableIdleTimeMillis" value="1800000"/&gt;
      &lt;property name="validationQuery" value="SELECT version();"/&gt;
  &lt;/bean&gt;
  &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
  &lt;/bean&gt;
  &lt;tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/&gt;
  &lt;bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory"&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Application 1. Database.properties</p>
  
  <pre><code>database.driverClassName=org.postgresql.Driver
  database.url=jdbc\:postgresql\://localhost\:5432/db
  database.username=username
  database.password=password
  </code></pre>
  
  <p>Application 2 </p>
  
  <p>application-Context.xml </p>
  
  <pre><code>&lt;bean class="java.net.URI" id="dbUrl"&gt;
      &lt;constructor-arg value="postgres://username:password@localhost:5432/db"/&gt;
  &lt;/bean&gt;
  &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
      &lt;property name="driverClassName" value="org.postgresql.Driver"/&gt;
      &lt;property name="url" value="#{ 'jdbc:postgresql://' + @dbUrl.getHost() + ':' + @dbUrl.getPort() + @dbUrl.getPath() }"/&gt;
      &lt;property name="username" value="#{ @dbUrl.getUserInfo().split(':')[0] }"/&gt;
      &lt;property name="password" value="#{ @dbUrl.getUserInfo().split(':')[1] }"/&gt;
      &lt;property name="testOnBorrow" value="true"/&gt;
      &lt;property name="testOnReturn" value="true"/&gt;
      &lt;property name="testWhileIdle" value="true"/&gt;
      &lt;property name="timeBetweenEvictionRunsMillis" value="1800000"/&gt;
      &lt;property name="numTestsPerEvictionRun" value="3"/&gt;
      &lt;property name="minEvictableIdleTimeMillis" value="1800000"/&gt;
      &lt;property name="validationQuery" value="SELECT version();"/&gt;
  &lt;/bean&gt;
  &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
  &lt;/bean&gt;
  &lt;tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/&gt;
  &lt;util:properties id="regex.properties" location="classpath:META-INF/spring/regex.properties"/&gt;
  &lt;bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory"&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Please advice how can I resolve my Problem..</p>