• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stored Procedure java code error

 
Srikanth Ravuri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am new to java. I am trying to call data from Oracle using java code but got few errors. Can you please help me where I am going wrong.

Thanks in advance.

Code:





Error:

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.srikanth.bank.dao.EmpDAO.main(EmpDAO.java:19)
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin @localhost:1521:XE
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.srikanth.bank.dao.EmpDAO.main(EmpDAO.java:29)



Please help me where I am going wrong.

 
Anand Bhatt
Ranch Hand
Posts: 189
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have classes12.jar file in your application path?
 
Srikanth Ravuri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anand Bhatt wrote:Do you have classes12.jar file in your application path?


Thanks Anand for the reply.

I am new to java. I am using eclipse to call the stored procedures. As you said I downloaded classes12.jar file and uploaded my java lib folder and still I couldn't see that on eclipse. Any suggestion of where I am doing the mistake.

Please help.

Thank you,
 
Campbell Ritchie
Sheriff
Pie
Posts: 49823
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Please always put code in code tags (Since you are new I have edited your post and you can see how much better it looks) and indent your code correctly.

If you didn't update your classpath for the project on Eclipse®, that .jar will be invisible to your application. I am not quite sure how to do it, but try
  • right-click project name
  • import
  • General
  • Archive File
  • Browse for file
  • Import into a folder
  • Can't promise that will work. You should be able to find some sort of help or tutorial for Eclipse┬« which will help you.
     
    Tom Reilly
    Rancher
    Posts: 618
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Actually, it's:
    1. Right click on the project
    2. Select Properties
    3. Select Java Build Path
    4. Select the Libraries tab
    5. Click the Add External JARs button
    6. Navigate to, and select classes12.jar
     
    Srikanth Ravuri
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tom Reilly wrote:Actually, it's:
    1. Right click on the project
    2. Select Properties
    3. Select Java Build Path
    4. Select the Libraries tab
    5. Click the Add External JARs button
    6. Navigate to, and select classes12.jar


    Thank you Tom

    I got hold up with DB connectivity error saying:


    any suggestion at to keep me on a right track.

    Thank you
     
    Anand Bhatt
    Ranch Hand
    Posts: 189
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You are on track now:

    This error is thrown if a user wants to log on a database but lacks the create session system privilege.
    In order to give someone this privilege, use:
    grant create session to the_user;
     
    Srikanth Ravuri
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Anand Bhatt wrote:You are on track now:

    This error is thrown if a user wants to log on a database but lacks the create session system privilege.
    In order to give someone this privilege, use:
    grant create session to the_user;


    Thanks Anand for quick response.

    I have a new problem now. I can print 1st row of the data and the rest it stops with an error message





    Here is my new java code.




    Any comments or suggestions on where I went wrong.

    Thank you,

     
    Tom Reilly
    Rancher
    Posts: 618
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A few comments:
    1. You only get back one set of output parameters. Your code suggests that you expect multiple sets because you attempt to get them in a loop.

    2. Here's a link to some Oracle documentation. It says:
    After all values have been retrieved from ResultSet objects (using ResultSet.getXXX methods), and after it has been determined that there are no more update counts, values from OUT parameters can be retrieved (using CallableStatement.getXXX methods).

    3. Despite the comment in the code that says "close the connection", you are not closing your connection. Do you see the error?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic