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 help in sql 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 "help in sql " Watch "help in sql " New topic
Author

help in sql

Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
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

Joined: Oct 29, 2001
Posts: 8834
    
    7


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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
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

Joined: Jan 10, 2002
Posts: 60739
    
  65

Did you read Joe's response?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
The problem was not bcoz of the space as Joe suggested.When i rewrote the sql it worked.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

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

Joined: Aug 25, 2003
Posts: 138
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help in sql
 
Similar Threads
How to use httpsession with dao factory
java.sql.SQLException-Need help to resolve.
Overload or not overload
Result Set problems
java.sql.Timestamp to Oracle date