Issue
I'm trying to connect the database with Netbeans with the help of oracle 10g. I have downloaded odjbc7.jar file and added it in the ORACLE THIN driver in db services. Still, I'm getting this class not found exception. (I am using Apache netbeans).
enter code here
import java.sql.*;
public class jdbclass {
public static void main(String args[]) throws ClassNotFoundException, SQLException
{
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String uname="sh";
String passwd="ara";
String query="select pizza_type from pizza";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url,uname, passed);
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(query);
String name=rs.getString("pizza_type");
rs.next();
System.out.print(name);
st.close();
con.close();
}
}
Solution
- You should use
ojdbc14.jar
as mentioned at https://docs.oracle.com/cd/E19830-01/819-4721/beanh/index.html - Make sure you have added the jar in the classpath as mentioned at How do I set the classpath in NetBeans?
Answered By - Arvind Kumar Avinash