1

I'm attempting to create a java program that will allow me access to an oracle database to run sql queries. It shouldn't be too difficult of a program but I can't get an IDE to work correctly.

The sample program the teacher of the class gave us to use starts off with

import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
import java.util.*;

and my main issue is that the IDE I use (eclipse Helios) will not recognize the import oracle.jdbc statement. I've spent hours searching for a plugin or anything at all to fix this. I've even installed Netbeans thinking that I would have more luck there. Any suggestions?

3 Answers 3

6

You need to download the jar ORACLE JDBC Drivers and import it in your project on Eclipse: project -> Properties -> Java Build Path -> Libraries and "Add external libraries"

Sign up to request clarification or add additional context in comments.

Comments

2

You have the drivers here

what i would recommend is not to use import oracle.jdbc.*; use for start just java.sql

A good link to start using that is here

In rest put the driver in the classpath as @Andrea recommended

Comments

0

On notepad editor (not in eclipse..) this is type 4 connection which is faster than rest of all note: - set ur classpath for oracle search more to know about "tnsnames.ora" file which gonna help u on 4th line of this code.

import java.sql.*;

class A { 
    public static void main(String arr[]) {
        try { 
            Class.forName("oracle.jdbc.dirver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle.thin:@localhost:1521:XE","System","manager");
            Statement stmt=con.creatStatement();
            ResultSet rset=stmt.executeQuery("Select * from emp");
            while(rset.next()) {
                System.out.println(rset.getInt(1)+"\t"+rset.getInt(2));
            }
            con.close();
        } catch(Exception e) { }
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.