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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package sun.jdbc does not exist" Watch "package sun.jdbc does not exist" New topic
Author

package sun.jdbc does not exist

javed iqbal
Greenhorn

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 :



Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
conn=DriverManager.getConnection("jdbc dbc:newdsn","scott","tiger");

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




newdsn is my dsn name

please help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
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
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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

So change into and all should be fine.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
David O'Meara
Rancher

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package sun.jdbc does not exist
 
Similar Threads
sun.jdbc is not available
package not found
servlet compilation error.
Compiling errors
package java.nio.file does not exist