aspose file tools
The moose likes Beginning Java and the fly likes package sun.jdbc does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package sun.jdbc does not exist" Watch "package sun.jdbc does not exist" New topic

package sun.jdbc does not exist

javed iqbal

Joined: Dec 30, 2007
Posts: 2
I have tried to set the connection with my database (oracle) but every time I run the code I get the following error.

Error: package sun.jdbc does not exist

even though I have set the environment variables

the code is :

conn=DriverManager.getConnection("jdbc dbc:newdsn","scott","tiger");

rs=stmt.executeQuery("select * from emp");

newdsn is my dsn name

please help
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41060
Welcome to the Ranch.

You are not trying to get a class from sun.jdbc. You are trying to get a class from sun.jdbc.odbc.
Suggest you edit your post and click on "disable smilies in this post" at the bottom left. That will get rid of the !
Rob Spoor

Joined: Oct 27, 2005
Posts: 19905

Class.forName requires a String, not a class name itself.

So change into and all should be fine.

How To Ask Questions How To Answer Questions
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

...Unless you're not using a Sun JRE (eg IBM, HP etc) in which case the sun packages do not exist.

The extended lesson here is that the JdbcOdbc bridge is a dog and you're better connecting with a Type-4 (native Java) driver than relying on the bridge which isn't really supported and definitely not meant for production.
Don't get me started about those stupid light bulbs.
subject: package sun.jdbc does not exist