You are here

Oracle and java.sql.SQLException: No suitable driver

Strange problem, just one part of simple code, works on my XP system, but not on Windows2003.

  1. Connection connection=null;
  2. try{
  3. connection = DriverManager.getConnection ("jdbc:odbc:thin@192.168.2.107:1521:Schemaname", "username", "password");
  4. PreparedStatement pstmt = con.prepareStatement ("Select * from sometable");
  5. ResultSet rset = pstmt.executeQuery();
  6. ....................

Very simple SQL code for one servlet, but when i run it in Tomcat, i got this exception:

  1. java.sql.SQLException: No suitable driver found for
  2. jdbc:oracle:thin:@192.168.2.107:1521:Schemaname at java.sql.DriverManager.getConnection(Unknown Source)at java.sql.DriverManager.getConnection(Unknown Source) at
  3. org.xmlBlaster.util.queue.jdbc.JdbcConnectionPool.addConnectionToPool(JdbcConnectionPool.java:362)
  4. at
  5. ............

In my XP system, i copied classes12.jar under my project's lib folder in
Tomcat\webapps\myproject\WEB-INF\lib
and the servlet works fine.

But under other Window2003 system, same Tomcat version, same Java version, I also copied the classes12.jar in the same lib folder. But the servlet has always this exception. Strange, no idea. I have tried to copied classes12.jar under ${java_home}/lib/ext, did not work.

And later i found official solution from Oracle website for this:

"then you probably have not added the Oracle JDBC driver ZIP file to your CLASSPATH environment variable. Either use:

[Oracle Home]/jdbc/lib/classes111.zip(for JDK 1.1)
or:
[Oracle Home]/jdbc/lib/classes12.zip(for JDK 1.2)

Furthermore, you need to ensure that your JDBC driver is registered with the java.sql.DriverManger.
If you are using the server-side (kprb) JDBC driver, or if you used one of the methods connect() or getConnection() on oracle.sqlj.runtime.Oracle to obtain a SQLJ connection context, then this will happen automatically.
Otherwise you need to register the Oracle JDBC driver, for example as follows:

java.sql.DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Under windows2003 i can not add classes12.zip to the environment variable, i only used the code in servlet, this really sovled this problem, but i dont understand why under my XP system, servlet can still work without this registerDriver code. I have also not set the classes12.zip into CLASSPATH environment under XP. Where is the difference.......

Ref:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/faq.html#nosuitabledriver

Blog: 

Comments

"But under other Window2003 system, same Tomcat version, same Java version, I also copied the classes12.jar in the same lib folder. But the servlet has always this exception. Strange, no idea. I have tried to copied classes12.jar under ${java_home}/lib/ext, did not work. "
Thanks for the information

Great theme about Open Source WebGIS Projects. People will see this at the research papers writing services and buy essay papers or already written essay finished by writing services’ writers.

Hi,
You have shared a good information here in this blog. Thanks for sharing this amazing work and keep up the good work.

Buy Essays

Hi,
Great post! You have shared good piece of information here in the blog.

Assignment UK

Hi,
I haven’t any word to appreciate this post.....Really I am impressed from this post.

Coursework Help

Thanks for this , works great if you use the default XP Start menu. I could'nt get it to work with the Classic Start menu
though. Any chance of a fix ?

I am using JDBC connection pooling to read a large data set and after about an hour or so into the result set processing I get the exception stated blow on all the connections in the pool and the process dies.. What is causing this?

Hi,

Thanks for the help. I got rid of this issue by adding classes12.jar in my classpath env. variable and project folder. I also have to add the java.sql.DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); line in my code.

Thanks once again.

Regards,
Sunny

That's a strange problem indeed {:jawdrop:} . I'd never figured out that solution, thanks for the article for future references I'll check your blog.

great site vigrx plus

Great post, thank you for sharing.
Ngan hang

I am using following code to Connect with my oracle database...

static final String connect_string = "jdbc:rdbThin://192.168.0.25:1701/DBNAME:XYZ.RDB";
static final String userName = "uername";
static final String password = "password";
..................
public void openConnection() throws SQLException {
Connection con = null;

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection (connect_string, userName, password);
}
..................

This results in following error while running it...

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
..................

I copied "classes12_g.jar" file under lib directory in WEB-INF directory.

So please kindly help me for the same... {:(}

Hi
I have got the same problem that Window2003 system, same Tomcat version, the same version of Java, I also copied classes12.jar in the same lib. But still this servile exception...how can solve it?
Alex
Roulette Payouts

I think my valuable input would appreciate your efforts. Almeda University

I'm not easily impressed. . . but that's imrpsesing me! :)

Check that off the list of things I was conuesfd about.