Robert;
Table names are not elligible for placeholders. The
idea of preparing a statement is really to create a
cursor that has an execution path to retrieve data
froma specific table or tables. It may or may not
have placeholders that add selectivity conditionals to
get different rows from the same table, but once the
table changes, the cursor is invalidated.
What you need to do is implement dynamic SQL where by
you set the table name using a string, not a place
holder.
ie.
String myTabName = "ORDERS";
PreparedStatement pstmt =
conn.prepareStatement("Select * from " + myTabName);
ResultSet rset = pstmt.executeQuery();
//Nicholas
--- Robert Pimentel <[EMAIL PROTECTED]> 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
>
=====
"And what causes me to run?
'Cause you're a...
Big Black Furry Creature From Mars"
--
Nicholas Whitehead
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
___________________________________________________________________________
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