Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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-00903: invalid table name

Bitra HemanthNov 7 2018 — edited Dec 13 2018

I am using below jsp script to apply select query from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

JSP Program:

<%@ page import="java.sql.*" %>

<%

   String table=request.getParameter("TAB");

   try

   { Class.forName("oracle.jdbc.driver.OracleDriver");

     Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","SYSTEM","Hemanth22");

     Statement st=con.createStatement();

    

           if(st.execute("SELECT * from "+table))

              {  ResultSet rs=st.getResultSet();

                 ResultSetMetaData rsmd=rs.getMetaData();

                 int nc=rsmd.getColumnCount();

                    out.print("<body bgcolor=yellow text=blue>");

                         out.print("<table align=center>");

                   while(rs.next())

                      { out.print("<tr>");

                         for(int c=1;c<=nc;c++)

                           { out.print("<td>"+rs.getString(c)+"</td>");}

                         out.print("</tr>");

                       }

   

TNSNames Settings.

$cat tnsnames.ora

# tnsnames.ora Network Configuration File: /home/bhemanth/app/bhemanth/product/12.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

LISTENER_ORCL =

  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

LISTENER_PDBORCL =

  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

PDBORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = pdborcl)

    )

  )

JDK Version:

$java -version

java version "9.0.4"

Java(TM) SE Runtime Environment (build 9.0.4+11)

Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

$javac -version

javac 9.0.4

[bhemanth@localhost admin]$ tomcat version

Server version: Apache Tomcat/7.0.76

Server built:   Oct 16 2018 09:15:49 UTC

Server number:  7.0.76.0

OS Name:        Linux

OS Version:     3.10.0-862.3.2.el7.x86_64

Architecture:   amd64

JVM Version:    9.0.4+11

JVM Vendor:     Oracle Corporation

OS i am using in CentOS7.5

Can you please advice why it is showing invalid table name even i am having some data in tab i.e. it give list of tables

This post has been answered by Bitra Hemanth on Dec 13 2018
Jump to Answer

Comments

Post Details

Added on Nov 7 2018
1 comment
3,050 views