*
The moose likes JDBC and the fly likes Informix Prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Informix Prepared Statement" Watch "Informix Prepared Statement" New topic
Author

Informix Prepared Statement

Hugo Sanchez
Greenhorn

Joined: Jan 05, 2007
Posts: 1
I'm having the following problem:

- I have a PreparedStatement that works fine with the following SQL (it retrieves a date and converts it to char):

sql = "SELECT TO_CHAR(TO_DATE(M.call_date || ' ' || M.seize_time), ?) part_actual_start,
M.CROSS_REF part_id
FROM DATES_TABLE M"

stmt = con.prepareStatement(sql);
stmt.setString(1, ifxTimeFormat);


- Whenever I attempt to append more text an exception is thrown (I append timezone code to the result)

sql = "SELECT TO_CHAR(TO_DATE(M.call_date || ' ' || M.seize_time), ?) || ' GMT' part_actual_start,
M.CROSS_REF part_id
FROM DATES_TABLE M"

stmt = con.prepareStatement(sql);
stmt.setString(1, ifxTimeFormat)

java.sql.SQLException: A syntax error has occurred.

- The origin of the exception points to the line when the SQL is parsed

stmtCAS = conCAS.prepareStatement(sqlStmtCAS);


The same query runs pretty fine on my console

Have any of you experienced something like this before? How did you manage to solve this?

Thanks in advance
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31069
    
232

Hugo,
Welcome to JavaRanch!

I haven't used Informix, but the query looks fine. As an alternative, you could add the "GMT" in Java after you've retrieved the result. This would simplify the query too.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Informix Prepared Statement