You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by as...@contact.bg on 2007/07/17 17:40:04 UTC

Inserting Null Dates


Hello,
I am having the following problem:
I want to insert a NULL for a row in a PostgreSQL 8.2 DATE field.

I am trying the follwoing SQL JDBC Control function:
	@SQL(statement="insert into test(id,date) values ({id},{date})")
	public void insertIntoTest(int id, java.sql.Date date);
	
I cannot do that with date=null.

I also tried with {d{date}} and then tried to use a second parameter of String
with null, and "" values, both with {date} and {d {date}} substitutions - 
I get different error messages.

How can I insert a null date value with the usual substitutional syntax?

This will be necessary when I get a table with a default non null value for a
DATE column and I will need to purposefully set the value to null.

Kind regards:
al_shopov

Re: Inserting Null Dates

Posted by Chad Schoettger <ch...@gmail.com>.
Based on the stack traces you sent this may be an issue with the
PostgresSQL JDBC driver.

Try setting a null date value using the JDBC API directly (not with
the JDBCControl) and see if you get the same error.  If that's the
case then it is an issue with the PostgresSQL JDBC driver.

 - Chad

On 7/18/07, ash@contact.bg <as...@contact.bg> wrote:
> Hi Chad,
> The errors were different in the different cases.
>
> I am providing the requested information:
>
> Kind regards:
> al_shopov
>
> 1. I am using Beehive 1.0.2
> 2. PostgresSQL 8.2
> 3. Sun JDK 1.5
> 4. apache-tomcat-5.5.23
> 5. JDBC driver - postgresql-8.1-408.jdbc3.jar
>
> Relevant JDBC control source:
> -----------------------------
>         @SQL(statement="insert into test (id, date) values ({id}, {date})")
>         public void insertIntoTestString(int id, String date);
>
>         @SQL(statement="insert into test (id, date) values ({id}, {d {date}})")
>         public void insertIntoTestStringEscaped(int id, String date);
>
>         @SQL(statement="insert into test (id, date) values ({id}, {date})")
>         public void insertIntoTestDate(int id, Date date);
>
>         @SQL(statement="insert into test (id, date) values ({id}, {d {date}})")
>         public void insertIntoTestDateEscaped(int id, Date date);
>
> Relevent Controller source:
> ------------------------------
>         @Jpf.Action(forwards = { @Jpf.Forward(name = "success", path = "showDates.jsp")})
>         public Forward processDate(){
>                 int i = invoiceControl.getMaxIdTest();
>
>
>                 java.sql.Date nullDate = null;
>                 String emptyString = "";
>                 String nullString = null;
>
>                 i++;
>                 try {invoiceControl.insertIntoTestDate(i, nullDate);}
>                 catch (Exception e)     {log.error("insertIntoTestDate - nullDate", e);}
>
>                 i++;
>                 try {invoiceControl.insertIntoTestDateEscaped(i, nullDate);}
>                 catch (Exception e)     {log.error("insertIntoTestDateEscaped - nullDate", e);}
>
>                 i++;
>                 try {invoiceControl.insertIntoTestString(i, nullString);}
>                 catch (Exception e) {log.error("insertIntoTestString - nullString", e);}
>
>                 i++;
>                 try {invoiceControl.insertIntoTestStringEscaped(i, nullString);}
>                 catch (Exception e) {log.error("insertIntoTestStringEscaped - nullString", e);}
>
>                 i++;
>                 try {invoiceControl.insertIntoTestString(i, emptyString);}
>                 catch (Exception e) {log.error("insertIntoTestString - emptyString", e);}
>
>                 i++;
>                 try {invoiceControl.insertIntoTestStringEscaped(i, emptyString);}
>                 catch (Exception e) {log.error("insertIntoTestStringEscaped - emptyString", e);}
>
>
>                 Map[] m = invoiceControl.getAllDates();
>                 Forward f = new Forward("success");
>                 f.addActionOutput("list", m);
>                 return f;
>         }
>
> Relevant log messages, I've cut out some of the stactrace and have substituted
> with .... ....:
> --------------------------------
>
> 2007-07-18 13:57:50,314 ERROR esign.invoices.admin.Controller -
> insertIntoTestDate - nullDate
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDate(InvoiceControlBean.java:249)
>         at esign.invoices.admin.Controller.processDate(Controller.java:244)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
> date but expression is of type character varying
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDate(InvoiceControlBean.java:234)
>         ... 41 more
>
> 2007-07-18 13:57:50,317 ERROR esign.invoices.admin.Controller -
> insertIntoTestDateEscaped - nullDate
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDateEscaped(InvoiceControlBean.java:405)
>         at esign.invoices.admin.Controller.processDate(Controller.java:248)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDateEscaped(InvoiceControlBean.java:390)
>         ... 41 more
>
> 2007-07-18 13:57:50,320 ERROR esign.invoices.admin.Controller -
> insertIntoTestString - nullString
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:524)
>         at esign.invoices.admin.Controller.processDate(Controller.java:252)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
> date but expression is of type character varying
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:509)
>         ... 41 more
>
> 2007-07-18 13:57:50,323 ERROR esign.invoices.admin.Controller -
> insertIntoTestStringEscaped - nullString
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:368)
>         at esign.invoices.admin.Controller.processDate(Controller.java:256)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:353)
>         ... 41 more
>
> 2007-07-18 13:57:50,327 ERROR esign.invoices.admin.Controller -
> insertIntoTestString - emptyString
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:524)
>         at esign.invoices.admin.Controller.processDate(Controller.java:260)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
> date but expression is of type character varying
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:509)
>         ... 41 more
>
> 2007-07-18 13:57:50,343 ERROR esign.invoices.admin.Controller -
> insertIntoTestStringEscaped - emptyString
> java.lang.reflect.UndeclaredThrowableException
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:368)
>         at esign.invoices.admin.Controller.processDate(Controller.java:264)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> .... ....
> Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
>         at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
>         at
> org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
>         at
> eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:353)
>         ... 41 more
>
>
>

Re: Inserting Null Dates

Posted by as...@contact.bg.
Hi Chad,
The errors were different in the different cases.

I am providing the requested information:

Kind regards:
al_shopov

1. I am using Beehive 1.0.2
2. PostgresSQL 8.2
3. Sun JDK 1.5
4. apache-tomcat-5.5.23
5. JDBC driver - postgresql-8.1-408.jdbc3.jar

Relevant JDBC control source:
-----------------------------
	@SQL(statement="insert into test (id, date) values ({id}, {date})")
	public void insertIntoTestString(int id, String date);
	
	@SQL(statement="insert into test (id, date) values ({id}, {d {date}})")
	public void insertIntoTestStringEscaped(int id, String date);
	
	@SQL(statement="insert into test (id, date) values ({id}, {date})")
	public void insertIntoTestDate(int id, Date date);

	@SQL(statement="insert into test (id, date) values ({id}, {d {date}})")
	public void insertIntoTestDateEscaped(int id, Date date);
	
Relevent Controller source:
------------------------------
	@Jpf.Action(forwards = { @Jpf.Forward(name = "success", path = "showDates.jsp")})
	public Forward processDate(){
		int i = invoiceControl.getMaxIdTest();
		

		java.sql.Date nullDate = null;
		String emptyString = "";
		String nullString = null;
		
		i++;
		try {invoiceControl.insertIntoTestDate(i, nullDate);}
		catch (Exception e)	{log.error("insertIntoTestDate - nullDate", e);}
		
		i++;
		try {invoiceControl.insertIntoTestDateEscaped(i, nullDate);}
		catch (Exception e)	{log.error("insertIntoTestDateEscaped - nullDate", e);}
		
		i++;
		try {invoiceControl.insertIntoTestString(i, nullString);}
		catch (Exception e) {log.error("insertIntoTestString - nullString", e);}
		
		i++;
		try {invoiceControl.insertIntoTestStringEscaped(i, nullString);}
		catch (Exception e) {log.error("insertIntoTestStringEscaped - nullString", e);}
		
		i++;
		try {invoiceControl.insertIntoTestString(i, emptyString);} 
		catch (Exception e) {log.error("insertIntoTestString - emptyString", e);}
		
		i++;
		try {invoiceControl.insertIntoTestStringEscaped(i, emptyString);} 
		catch (Exception e) {log.error("insertIntoTestStringEscaped - emptyString", e);}
		

		Map[] m = invoiceControl.getAllDates();
		Forward f = new Forward("success");
		f.addActionOutput("list", m);
		return f;
	}

Relevant log messages, I've cut out some of the stactrace and have substituted
with .... ....:
--------------------------------

2007-07-18 13:57:50,314 ERROR esign.invoices.admin.Controller -
insertIntoTestDate - nullDate
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDate(InvoiceControlBean.java:249)
        at esign.invoices.admin.Controller.processDate(Controller.java:244)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
date but expression is of type character varying
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDate(InvoiceControlBean.java:234)
        ... 41 more
        
2007-07-18 13:57:50,317 ERROR esign.invoices.admin.Controller -
insertIntoTestDateEscaped - nullDate
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDateEscaped(InvoiceControlBean.java:405)
        at esign.invoices.admin.Controller.processDate(Controller.java:248)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestDateEscaped(InvoiceControlBean.java:390)
        ... 41 more
        
2007-07-18 13:57:50,320 ERROR esign.invoices.admin.Controller -
insertIntoTestString - nullString
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:524)
        at esign.invoices.admin.Controller.processDate(Controller.java:252)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
date but expression is of type character varying
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:509)
        ... 41 more
        
2007-07-18 13:57:50,323 ERROR esign.invoices.admin.Controller -
insertIntoTestStringEscaped - nullString
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:368)
        at esign.invoices.admin.Controller.processDate(Controller.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:353)
        ... 41 more
        
2007-07-18 13:57:50,327 ERROR esign.invoices.admin.Controller -
insertIntoTestString - emptyString
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:524)
        at esign.invoices.admin.Controller.processDate(Controller.java:260)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: column "date" is of type
date but expression is of type character varying
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestString(InvoiceControlBean.java:509)
        ... 41 more
        
2007-07-18 13:57:50,343 ERROR esign.invoices.admin.Controller -
insertIntoTestStringEscaped - emptyString
java.lang.reflect.UndeclaredThrowableException
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:368)
        at esign.invoices.admin.Controller.processDate(Controller.java:264)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... ....
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:290)
        at
org.apache.beehive.controls.system.jdbc.JdbcControlImpl.invoke(JdbcControlImpl.java:224)
        at
eu.horizon_it.invoices.controls.InvoiceControlBean.insertIntoTestStringEscaped(InvoiceControlBean.java:353)
        ... 41 more

	

Re: Inserting Null Dates

Posted by Chad Schoettger <ch...@gmail.com>.
I wasn't able to recreate the issue (with Derby).  Were you getting
errors from the SQL Driver ?  Or were they from the JDBC control?

If you can include the error messages you were getting I'll take
another shot at reproducing this issue.


  - Chad


On 7/17/07, ash@contact.bg <as...@contact.bg> wrote:
>
>
> Hello,
> I am having the following problem:
> I want to insert a NULL for a row in a PostgreSQL 8.2 DATE field.
>
> I am trying the follwoing SQL JDBC Control function:
>         @SQL(statement="insert into test(id,date) values ({id},{date})")
>         public void insertIntoTest(int id, java.sql.Date date);
>
> I cannot do that with date=null.
>
> I also tried with {d{date}} and then tried to use a second parameter of String
> with null, and "" values, both with {date} and {d {date}} substitutions -
> I get different error messages.
>
> How can I insert a null date value with the usual substitutional syntax?
>
> This will be necessary when I get a table with a default non null value for a
> DATE column and I will need to purposefully set the value to null.
>
> Kind regards:
> al_shopov
>