Inserting System Date into Table

Hi,

I am having a problem inserting a system date into a table. I am currently using Mysql. Please find code below.

ins1="INSERT INTO USERS VALUES("

+ "'" + g_user_name + "'" + ","

+ "'" + g_user_password + "'" + ","

+ "'" + g_user_email + "'" + ","

+ "'" + g_user_phone + "'" + ","

+ "'" + g_user_address + "'" + ","

+ "'" + g_user_type + "'" + ","

+ "\'NOW\')";

InsertSQL(ins1, res);

When i run the servlet, I get the following error:

EXCEPTION com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect date value: 'NOW()' for column 'sys_creation_date' at row 1

Please can someone assist.

I have tried different variations as to use the NOW() function. I have also tried to use CURRENT_DATE(). If i do a manual insert into the DB from command prompt, it works perfectly. But when using the servlet, i get the above error.

Thanks Guys ...

Naren

[975 byte] By [gokala] at [2007-11-27 8:10:23]
# 1

> Hi,

>

> I am having a problem inserting a system date into a

>ins1="INSERT INTO USERS VALUES("

>+ "'" + g_user_name + "'" + ","

>+ "'" + g_user_password + "'" + ","

>+ "'" + g_user_email + "'" + ","

>+ "'" + g_user_phone + "'" + ","

>+ "'" + g_user_address + "'" + ","

>+ "'" + g_user_type + "'" + ","

>+ "\'NOW\')";

> InsertSQL(ins1, res);

Try with

>+ " {fn now() } )";

which is the JDBC function escape sequence for the current time.

Bye.

RG.

RealHowToa at 2007-7-12 19:53:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks .. It worked perfectly
gokala at 2007-7-12 19:53:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...