Skip to Content
0
Jun 04, 2010 at 02:51 PM

OpenSQLException - object of type java.sql.Date is not normalized

54 Views

Hi,

I am attempting to code an SQL query in an EJB and get the following exception:

com.sap.sql.log.OpenSQLException: The object of type java.sql.Date with the value '2010-06-04 13:21:09.424' assigned to host variable 1 is not normalized. It must not contain time components in the time zone running the virtual machine. at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85) at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124) at com.sap.sql.jdbc.common.CommonPreparedStatement.setDate(CommonPreparedStatement.java:650) at......

Below is the code snippet I am using:

private static String selWQ = "Select * from ZZZZ_TABLE " +

"where DATEFROM >= ? " +

"and DATETO <= ? ";

public UsageRecord[] getRecords(Date fromDate,Date toDate)

{

UsageRecord[] ura = null;

String q = null;

ArrayList al = new ArrayList();

try

{

q = selWQ;

conn.open();

PreparedStatement p = conn.prepareStatement(q);

p.setDate(1, fromDate);

p.setDate(2,toDate);

ResultSet rs = p.executeQuery();

.......

I have a PreparedStatement and am using setDate to set the values. The fromDate and toDate parameters are of type java.sql.Date

Can someone please tell me what I am doing wrong and how to fix it?

thanks

Brian