wood burning stoves 2.0*
The moose likes JDBC and the fly likes Cannot Load Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Cannot Load Driver" Watch "Cannot Load Driver" New topic
Author

Cannot Load Driver

wasif akbar
Greenhorn

Joined: May 02, 2001
Posts: 11
Below is my code:

package com.teoco.GenSequences;
import java.sql.*;
public class DBConnect
{
public static void main(String args[])
{
// Loading a driver
try
{
Class.forName("oracle.jdbc.odbc.OracleDriver");
}
catch(ClassNotFoundException e)
{
System.err.println("Driver could not be loaded" + e.getMessage());
}

// Defining a URL
String url = "jdbc racle:thin:@dl20,bt51,bt51";

// Establish a connection and create a statement
try
{
//Create a connection object
Connection dbConn = DriverManager.getConnection(url);
//Create a statement object
Statement dbStmt = dbConn.createStatement();
//Execute a query
String queryOne = "Select invoice_seq_id from invoice where rownum < 10";
ResultSet dbRes = dbStmt.executeQuery(queryOne);
while(dbRes.next())
{
String inv = dbRes.getString(0);
System.out.println(inv);
}
dbConn.close();
}
catch(SQLException e)
{
System.err.println("SQLException: " + e.getMessage());
}
}
}

When I execute this file, I keep getting the following error:
Driver could not be loaded oracle.jdbc.odbc.OracleDriver
SQLException: No suitable driver
This error initially led to believe something with my classpath. Here is my classpath and path variable settings:
CLASSPATH=C:\;C:\ORACLE\ORA81\JDBC\LIB\classes12.zip;C:\ORACLE\ORA81\JDBC\LIB;C:
\ORACLE\ORA81\JDBC\LIB\classes12.zip;C:\jdk1.3\bin;C:\jdk1.3\lib
Path=C:\oracle\ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32
;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Rational\common;C:\Program Fil
es\Rational\Rational Test
I thought I fixed any issues with the classpath, yet I still recieve this error. Any help would be greatly appreciated.
asnmurthy
Greenhorn

Joined: Aug 01, 2000
Posts: 7
Hi Could you please send me your code in mail to my email address?
Regards,
Murthy
A.Murthy@gecapital.com
------------------
Thanks & Regards,
Murthy


Thanks & Regards,<br />Murthy
venugopal askani
Greenhorn

Joined: Aug 20, 2001
Posts: 16
Hi
U seem to be using both stuff together.
Either use a JDBC ODBC bridge or use a thin client for JDBC connection. In the driver u are specifying a JDBC-ODBC bridge and then in connection u r using thin connection. Please refer to the following site. http://developer.java.sun.com/developer/onlineTraining/Database/JDBCShortCourse/jdbc/jdbc.html#jdTalking
or to the JDBC tutorial site http://java.sun.com/docs/books/tutorial/jdbc/index.html
Regards
Askani
Surya Bahadur
Ranch Hand

Joined: Sep 28, 2000
Posts: 88
Hi
Too Many mistakes
If you want to use thin driver the Jdbc Url should be of the form
jdbc racle:thin:@machineName:1521:sid
In the class.forName statement try putting
oracle.jdbc.odbc.OracleDriver instead of oracle.jdbc.driver.OracleDriver.
As far as possible try using thin drivers instead of the odbc drivers to access oracle.
Surya

[This message has been edited by Surya Bahadur (edited August 20, 2001).]
[This message has been edited by Surya Bahadur (edited August 20, 2001).]
[This message has been edited by Surya Bahadur (edited August 20, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot Load Driver
 
Similar Threads
Running Tomcat as service; JDBC not working now
jdbc oracle hell......
jdbc oracle hell
problem with connection
JDBC driver - java lang ClassNotFoundException