• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.ClassCastException error

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to store a word document in Oracle database.
I am using Oracle9i. But, I get the error as:

java.lang.ClassCastException
I tried creating a querystring, qstring like
String qString = "select resume from Resumes where emp_id = 9004 for update";
oracle.jdbc.driver.OracleResultSet ors = (OracleResultSet)stat.executeQuery(qString);
res.next();
BLOB blob = ors.getBLOB("resume");

But, it was of no help. I've included the code below. I've marked the place where the error is shown. Please help. Thanks in advance.

[ March 14, 2005: Message edited by: seema prakash ]
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't look like you're using an oracle driver:


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");



What jdk version are you using? java.sql.ResultSet has a getBlob() method
in 1.4.2: ResultSet API
 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I connect to the oracle driver by issuing the following statement:

conn = DriverManager.getConnection("jdbc racle:thin:@localhost:2030 rcl","SYSTEM","password");



But, the error now is:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)

I am compiling the code using NetBeans IDE which supports JDK1.4 and higher versions and the JDK installed with Oracle9i is JDK 1.3. Does this have to do something with the error?
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have an oracle driver?

I have an oracle 9i client installed and in the jdbc/lib directory there are some driver jars.

Or you may be able to download the latest drivers from Oracle driver download page.

classes12.zip for jdk 1.2/1.3
ojdbc14.jar for jdk 1.4

Add the jar to your classpath.
 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for guiding me. Yes, I do have the driver installed When I installed oracle9i database, Personal Edition.I do have the jdbc/lib directory which has all the different jars. I ahve included the classes12.jar and the ojdbc14.jar in my classpath too.
 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help. I got it working. I had problem with the driver connection. Now it works with the following lines:
DriverManager.registerDriver((Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
conn = DriverManager.getConnection("jdbc racle:thin:@DCXHEILER:1521 rcl","SYSTEM","password");//making the connection.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic