This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: SQLException: ORA-00911: invalid character
 
Similar Threads
Need help with a query thats driving me insane
execute() and prepared statements
operator IN and NUMBER
JDBC connection in Oracle db
ORA-01000: maximum open cursors exceeded