This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and Relational Databases 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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 9043
    
    9


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.


[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: 62106
    
  67

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: 9043
    
    9

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