Since you uses setString, the API will put quote ' or " around
name_of_table in the SQL query string. So your query will be sent to SQL
server like this
select * from "name_of_table" or
select * from 'name_of_table'
single or double quotes depends on JDBC driver.
If you put "?" in the field of values,
such as "insert into table_name values (?, ?)", it will work because string
values need quotes.
I can not see any reason to use ? for table name.
Hope it will resolve your problem.
--Fengrui
At 08:17 AM 1/6/00 -0800, you wrote:
>Hi :)
>
>I apologize, slightly off-topic. I'm hoping a few people here have worked
with JDBC.
>
>Having trouble with my preparedStatment. I'm trying to assign a value to
my placeholder.The SQLException is raised. Error ORA-00903 Invalid table
name. Here's some of the code.
>
>PreparedStatement pstmt = conn.prepareStatement("Select * from ?");
pstmt.setString(1, "name_of_table");
>ResultSet rset = pstmt.executeQuery();
>
>I've tried using different table names. No luck. I also tried assigning
the value to a String first (i.e String tab_name = "name_of_table";). No
luck. I've also tried PreparedStatement pstmt =
conn.prepareStatement("Select column1 from ?"); In case the '*' was causing
a problem. Still no luck. Is it even possible to dynamically assign the
name of a table with a PreparedStatement?? Am I forgetting something??
>
>Tia,
>
>-Robert-
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html