Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes No suitable driver found for jdbc:oracle:thin:@localhost:1521:CON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "No suitable driver found for jdbc:oracle:thin:@localhost:1521:CON" Watch "No suitable driver found for jdbc:oracle:thin:@localhost:1521:CON" New topic
Author

No suitable driver found for jdbc:oracle:thin:@localhost:1521:CON

Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

My FirstCode in jdbc

error :
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbcracle:thin:@localhost:1521:CON
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.cls.demo.JdbcDemo.main(JdbcDemo.java:35)

1)what is this thin driver ?
jdbcracle:thin:@localhost:1521:CON

what does this say ?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

The Thin driver is a jdbc library that allows you to connect to an Oracle database without needing Oracle client software.

You can download it from Oracle.


OCUP UML fundamental and ITIL foundation
youtube channel
Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

Why i am keep getting this Exception ?? What's Wrong

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc: oracle:thin:@localhost:1521:CON
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.cls.demo.JdbcDemo.main(JdbcDemo.java:35)
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

You get this error because you did not make the oracle jdbc thin driver library available when running your program.

Download the Oracle jdbc library.
add it to the classpath when running your program.

This line of code seems odd : Class class1 = ClassLoader.getSystemClassLoader().loadClass("oracle.jdbc.driver.OracleDriver");
Where did you learn to load a driver class that way?

Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

Jan Cumps wrote:You get this error because you did not make the oracle jdbc thin driver library available when running your program.

Download the Oracle jdbc library.
add it to the classpath when running your program.

I have Added.
Jan Cumps wrote:This line of code seems odd : Class class1 = ClassLoader.getSystemClassLoader().loadClass("oracle.jdbc.driver.OracleDriver");
Where did you learn to load a driver class that way?


No,why so?




Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

I was expecting to see : Class.forName ("your driver class");
(and with JDBC 4 drivers you can completely skip loading the driver)
Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

It Worked fine!now!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: No suitable driver found for jdbc:oracle:thin:@localhost:1521:CON