File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help in sql

 
Mary Wallace
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a sql statement like this

pin and account number is not passing the values. system .out print is showing this select pin,emp_acct_no,attn_name,address_line1,address_line2,po_box_no,city,state,zip,country_code,emailFROM w_employer WHERE pin= 'pinum' and emp_acct_no=checkaccountNumber
DB Connection Error(validate accountnumer): java.sql.SQLException: ORA-00923: FROM keyword not found where expected
what Im doing wrong here?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

String qry = "select pin,emp_acct_no,attn_name,address_line1,address_line2,po_box_no,city,state,zip,country_code,email" +
"FROM w_employer WHERE pin='" + pinnum + " 'AND emp_acct_no="+checkaccountNumber;

There's no space between "country_code,email" and "FROM". They get concatenated and the SQL compiler can't find the FROM keyword.
 
Mary Wallace
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed like this and it worked

i want to change that as a prepared statement like this:

but it gave me an error "DB Connection Error(validate pin frm db): java.sql.SQLException: ORA-00923: FROM keyword not found where expected"
what i have to do here?
thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read Joe's response?
 
Mary Wallace
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was not bcoz of the space as Joe suggested.When i rewrote the sql it worked.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your String query has a space before FROM but the String literal in your prepared statement doesn't have the space. Attention to detail!
 
Mary Wallace
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic