Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

e45dbee8-c186-4ac0-a648-9a01bd6897caJul 10 2016 — edited Jul 10 2016

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.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2016
Added on Jul 10 2016
17 comments
4,314 views