views:

127

answers:

3

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

+1  A: 
Bragboy
I did it but It doesn't work. the exception still exist. the jar is inside my project and i did what you've said.
Elad
Can you please let me know what file you're using for the jar ?
Bragboy
A: 

In my Java projects, I create a /lib directory at the same level as /src and /bin. I throw any library jars in there and then right-click on the .jar file and do "Build Path | Add to Build Path."

Carl Smotricz
I did this step and I get the same exception
Elad
You didn't mention (until an hour later) that it's a Web application. I guess we should have asked. But I'm glad to see you got it resolved meanwhile.
Carl Smotricz
A: 

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.

Elad