I searched for answer to this question and only found vague answers. Here is the problem: I have a sample table in MySQL: mytable time Timestamp data BigInt(20) unsigned
Data field is chosen so that it can take in 2^64 max value: 18446744073709551616 (20 digits and hence BigInt(20)).
I have a csv file which contains unsigned 64-bit integers.
Now I am using Java and JDBC to insert this data and running into issues because Java does not have unsigned long. So I tried just passing string - but it fails.
st = conn.prepareStatement("INSERT INTO pawan_table (mytime, data) VALUES(?, ?)");
st.setTimestamp(1, new Timestamp(86400000+i*1000));
st.setString(2, "18446744073709551616");
st.execute();
I also tried BigInteger class in Java - but JDBC does not have a method which takes that type. I can only convert BigInteger to "long" which is signed and that is not what I want. For example:
BigInteger bi = new BigInteger(string_from_csv_file);
st.setLong(2, bi.longValue());
Interesting thing is that MySQL Workbench can insert this data - but it is written in c#! and I need to write my code in Java!
How do Java programmers insert unsigned 64-bit number in MySQL BigInt(20) column?
st.setLong(2, 18446744073709551616L);
? – Luiggi Mendoza