java - Query working on SQL*Plus but not in jdbc program -


i executed query on sqlplus (oracle 11g)

select bookdetails.title,bookdetails.price bookdetails inner join orderdetails on bookdetails.bookid=orderdetails.bookid orderdetails.username ='divya.grg'; 

i got output:

title                                                             price ------------------------------------------------------------ ---------- mastering c++                                                     876.2 construction material reference book 2nd edition                    332 let c++                                                          793 

but when did same query on jdbc program:

preparedstatement ps=conn.preparestatement("select bookdetails.title,bookdetails.price"   +"from bookdetails"   +"inner join orderdetails"   +"on bookdetails.bookid=orderdetails.bookid"   +"where orderdetails.username ='"+username+"'"); resultset rs=ps.executequery(); 

i getting exception:

>java.sql.sqlsyntaxerrorexception: ora-00923: keyword not found expected 

now why happen? if sqlplus executing without problem why exception thrown in program?

place spaces @ beginnings of lines you're concatenating create query in java, or else lines you're concatenating run query as:

select bookdetails.title,bookdetails.pricefrom bookdetailsinner join orderdetails... 

when want

select bookdetails.title,bookdetails.price bookdetails inner join orderdetails... 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -