• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

java.sql.SQLException: No suitable driver

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting this exception while deploying my application on Tomcate version:5.5.26
Application type: Web based(Spring).
java version: 1.6
Database: Oracle 10g Exp.
Driver: ojdbc6 (from oracle site for java 1.6)
I am attaching jdbc.properties file. And It is running perfeclty fine from inside Eclipse(3.5.1). I have a test class to check the problem.
Real Exception :
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL '"jdbc:oracle:thin:@localhost:1521:orcl"'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

java code: It running fine. Problem is only from Tomcat deployment.
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
String userName = "orbgang";
String password = "admin";

Class.forName("oracle.jdbc.driver.OracleDriver");
java.sql.Driver driver = null;
driver = DriverManager.getDriver(url);

System.out.println("Driver name::"+driver.getMajorVersion());

java.sql.Connection connection = DriverManager.getConnection(url, userName, password);

Statement statement = connection.createStatement();

ResultSet resultSet = statement.executeQuery("select * from COUNTRIES");

while(resultSet.next()) {

System.out.println("countries Name !!"+resultSet.getString("COUNTRY_NAME"));
}
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is oracle jdbc driver in your classpath.
 
Brijesh kumar Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
But why I need that driver in classpath ? Because my application is Web project. All the required libs are in WEB-INF/lib folder. And problem is coming when I am deploying that application on Tomcat.

Thanks,
Brijesh Singh
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brijesh kumar Singh wrote:But why I need that driver in classpath ? Because my application is Web project. All the required libs are in WEB-INF/lib folder. And problem is coming when I am deploying that application on Tomcat.


Have you put the driver jar file in server's "lib" or applications's "lib" directory? If so, do you have any connection factory configuration ?
 
Brijesh kumar Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. all the libs files are in req. lib folder. I am using Spring framework. I have configured the connection factory in properties files as:
jdbc.properties:

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url="jdbc:oracle:thin:@localhost:1521"
jdbc.username=orbgang
jdbc.password=admin
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect

and the content of applicationcontext.xml is :

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/orbgangsn/domain/OrganizationType.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
</props>
</property>
</bean>
 
Marshal
Posts: 80751
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use the CODE button, and click "disable smilies in this post". Both will make your posts easier to read.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic