Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

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: 4109
72
Hibernate Fedora Chrome
  • 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: 72657
317
  • 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.
 
What are you doing in my house? Get 'em tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic