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?
您需要下载jar ORACLE JDBC驱动程序并将其导入Eclipse中的项目中:项目->属性-> Java构建路径->库和“添加外部库”
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) { }
}
}
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.