简体   繁体   中英

Exception in thread “main” java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver In netbeans

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();

          }

        }
  1. You should use ojdbc14.jar as mentioned at https://docs.oracle.com/cd/E19830-01/819-4721/beanh/index.html
  2. Make sure you have added the jar in the classpath as mentioned at How do I set the classpath in NetBeans?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM