How to add the ojdbc jar to my project and use it

49,790

Solution 1

You will have to add the jar to your Classpath. You can do that in eclipse by right clicking on the Project --> Build Path --> Configure Build Path

Under Libraries tab, click Add Jars and give the Jar (oracle jdbc driver).

Oracle JDBC Driver download here

Solution 2

Ok. finally The solution is to add the jar file into the Web-Inf/lib directory because I have a Dynamic web application. Thank you all.

Share:
49,790
Elad
Author by

Elad

Updated on August 12, 2020

Comments

  • Elad
    Elad almost 4 years

    I need some help with the eclipse.

    I have a project which need to connect to oracle databases so i have the ojdbc jar file and a simple project.

    try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+this.host+":"+this.port+":"+this.db,this.user,this.pass);
            Statement stmt = conn.createStatement();
            ResultSet rset = stmt.executeQuery(query);
    
            while (rset.next())
            {
                retStr += rset.getString(1) + ',';
            }
            stmt.close();
            conn.close();
        }
    

    and I got an exception that the oracle.jdbc.driver.OracleDriver is not exists. how do I add the jar to my project and use it?

    I did this step and I still get the exception. You will have to add the jar to your Classpath. You can do that in eclipse by right clicking on the Project --> Build Path --> Configure Build Path