By the way, if you have a double quote around the table name the name
becomes case sensitive,i.e, if table name with in quotes is specified in
lower case, oracle will try to find the table name with lower case. And if
you had created a table in DB without using double quotes, even if you had
specified table name in lower case, it will be created with name in upper
case.

> -----Original Message-----
> From: Fengrui Gu [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, January 06, 2000 9:01 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: PreparedStatement trouble
>
> 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

___________________________________________________________________________
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

Reply via email to