?
Solved

insert empty timestamp into db2 using jsp

Posted on 2005-03-17
5
Medium Priority
?
1,502 Views
Last Modified: 2008-01-09
I am using DB2. I want to insert a record using JSP.

The table is as follow :
COLUMN NAME: A (primary key) , B ,C
DATA TYPE: TIMESTAMP, DATE


I am using JSP to insert a record.

my sql statement is as follow :
INSERT INTO TBL_AAA VALUES ('P1','','')

however I get the follow error:
com.ibm.db2.jcc.c.SqlException: The syntax of the string representation of a datetime value is incorrect.

THE DATA SAMPLE IS AS FOLLOW:

P2, FEB 3,2005 2:40:03 PM 218000 , DEC 14, 2004

Would somebody please help me ?
0
Comment
Question by:mikekwok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 13563526

why not just do:

INSERT INTO TBL_AAA VALUES( 'P1' )

?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 13563532
Or, using a PreparedStatement,

String a = "P1" ;
String sql = "INSERT INTO TBL_AAA VALUES( ?, ?, ? )" ;
PreparedStatement stmt = conn.prepareStatement( sql ) ;
stmt.setString( 1, a ) ;
stmt.setNull( 2, Types.TIMESTAMP ) ;
stmt.setNull( 2, Types.DATE ) ;
int cnt = stmt.executeUpdate() ;

out.println( "<h1>" + cnt + " rows added!!" ) ;
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13563534
Obviously, you need to close the statement, catch the exceptions, etc...
0
 

Author Comment

by:mikekwok
ID: 13571167
Actually the table contains more than 3 column, therefore I cannot use INSERT INTO TBL_AAA VALUES( 'P1' )
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13572709
You can do:

   INSERT INTO TBL_AAA ( COLUMNNAME ) VALUES ( 'P1' )

to just insert into a single column :-)

Good luck!!

Tim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question