• Post Reply Bookmark Topic Watch Topic
  • New Topic

oracle package not found error  RSS feed

 
Lalit Vora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting error package oracle.jdbc.driver.OracleDriver not found.

I kept ojdbc14.jar in the same folder where i have my class.

bt i have not mentioned it in calsspath. Can you please guide me
Other question is orcl is my database name is that ok?





import java.sql.*;
import oracle.jdbc.driver.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
("jdbc racle:thin:@ajv-insp-2500:1521 rcl", "scott", "tiger");
// @machineName ort:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from stock");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lalit Vora:
I kept ojdbc14.jar in the same folder where i have my class.

bt i have not mentioned it in calsspath.

It doesn't matter if the JAR file is in the same folder as your class. But it DOES matter that you don't have it in your classpath. So, make sure the JAR is in your classpath. Start your application like this:

java -classpath .;ojdbc14.jar mypackage.MyClassName

Explanation: You set the classpath with the "-classpath" option on the command line. ".;ojdbc14.jar" means: include the current directory (indicated by ".") and the file ojdbc14.jar in the classpath.

If you're doing this on Linux or Unix, you need to use : instead of ; to separate the elements in the classpath.
 
Lalit Vora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jesper,

Thanks its running. Actually, it was running through
java -classpath .;classes12.jar dbAccess i am getting class not found error in when i use ojdbc14.jar but it compiled when i used ojdbc14.jar why it is so? Is there any problem ?

I also want to know like I got code run in this way but in real life I have this class written and this resultset should open in jsp, Now i want to know that when depending upon parameter from index.jsp i will fire query and i should get resultset how this class will run to get data.

I mean here we are using java -classpath .;classs12.jar dbAccess to run there we wont have that option. What settings should i do?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!