Getting an error inserting a timestamp using JDBC and PostgreSQL -


i new postgresql. trying insert data table using jdbc.

one of column values inserted of following type.

2014-04-04t19:56:42.784z (please note t , z in string).

i first used timestamp datatype corresponding column. however, getting following error :

org.postgresql.util.psqlexception: error: syntax error @ or near "t19"

i changed character(40) thinking might format wrong. however, still getting same error.

later, when removed t , z string, error stopped. please note thought colon problem. however, not case through testing.

java code snippet

string line = 1,2014-04-04t19:56:42.784z,456,0 string[] tempstr = strline.split(","); string sql = "insert table (a , timeofsess , b  , c )"              + "values("+tempstr[0]+","+tempstr[1]+","+tempstr[2]+","+tempstr[3]+")";  stmt.executeupdate(sql); 

please note using timeofsess character(40). analysis not important store time time. character work. going easy way around here.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -