Monday, 26 August 2013

How to insert NULL in mysql especially INT dataType ASAP

How to insert NULL in mysql especially INT dataType ASAP

I have 80000 recodes that are need to insert into database especially in
table: temp(ts, temp) temp is INT.
The problem is almost 20000 recodes are null, so I am wondering how to
insert NULL into DB when dataType is INT.
I tried this:
String val = null;
//insert(ts, val) into temp
String sql = "INSERT INTO temp" + "(val)" + " VALUES" + "('" + val + "')";
Statement st = (Statement) conn.createStatement();
count = st.executeUpdate(sql);
unfortunately "insert is failure Incorrect integer value: 'null' for
column 'val' at row 1"
Wish someone can help me with it. Thank you.

No comments:

Post a Comment