Reputation: 191
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?
Upvotes: 1
Views: 1194
Reputation: 11
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) { }
}
}
Upvotes: 0
Reputation: 5007
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
Upvotes: 2
Reputation: 4427
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"
Upvotes: 6