This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQLException: ORA-00911: invalid character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException: ORA-00911: invalid character " Watch "SQLException: ORA-00911: invalid character " New topic
Author

SQLException: ORA-00911: invalid character

Simon Knight
Greenhorn

Joined: Mar 04, 2004
Posts: 25
Hi - I've got the following code in respect of an SQL query:



Which when run produces the following (for a specific instance of the query):

select PARSING_USER_ID from v$sql where SQL_TEXT like 'select LOW_OPTIMAL_SIZE, HIGH_OPTIMAL_SIZE, OPTIMAL_EXECUTIONS, ONEPASS_EXECUTIONS, MULTIPASSES_EXECUTIONS, TOTAL_EXECUTIONS from GV$SQL_WORKAREA_HISTOGRAM where INST_ID = USERENV('Instance')'

This also has the unfortunate result of causing a "java.sql.SQLException: ORA-00933: SQL command not properly ended" exception. I don't understand this as the query looks fine to me, and when cut and paste into SQLDeveloper works fine...

Can anyone tell me, why won't it work in JDBC and is there a work around?
Pavel Cherkashin
Ranch Hand

Joined: Mar 04, 2005
Posts: 47
The point is in preparation of statement. Avoid using string concatination, when You put params into query.
For instance:

if SQLtext contains some invalid characters, jdbc driver translates
them to correct SQL escape symbols. But in your case all characters will be pasted into query as is.


Pavel Cherkashin - <br />SCJP, SCWCD, SCDJWS, SCBCD, SCEA, ...<br />www.linkedin.com/in/pcherkas
 
jQuery in Action, 2nd edition
 
subject: SQLException: ORA-00911: invalid character
 
Similar Threads
ORA-01000: maximum open cursors exceeded
JDBC connection in Oracle db
Need help with a query thats driving me insane
execute() and prepared statements
operator IN and NUMBER