Hi,
I'm a beginner in jdbc i have written a code for get the ename column from the table employee which i have created using Oracle Database 11g Express Edition and here is my code
import java.sql.*;
public class connectivity
{
public static void main(String[] args)
{
Connection con = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","password");
Statement stmnt=con.createStatement();
ResultSet rs=stmnt.executeQuery("SELECT ename FROM emp1");
if(rs.next())
{
while(rs.next())
{
String str1=rs.getString("ENAME");
System.out.println(str1);
}
}
else
System.out.println("Error");
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
try
{
con.close();
}
catch(Exception e){
System.out.println(e);
}
}
}
}
but this code throws an exception "java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist".
Please anyone help me to solve this problem.