Database problem
hello guys i am writing a program in java that stores some details into a postgresql database. The problem that i have is: one column of my table is set as serial (incremented with each entry, done by Postgresql automatically), in the specific code the serial column is traceid. My code to insert the values into the database looks like that:// Prepare a statement to insert into table TraceFile
String sql4 ="INSERT INTO tracefile(" +"traceid," +"filelocation,"
+"starttime," +"endtime," +"seqno," +"size," +"notes,"
+"keepflag," +"keepuntil," +"format) "
+"VALUES(?,?,?,?,?,?,?,?,?,?)";
try{
pstmt = conn.prepareStatement(sql4);
}catch (SQLException e2){
System.out.println(e2.getMessage());
}
// Set the values
try{
pstmt.setString(2, filename);
pstmt.setTimestamp(3, timestamp);
pstmt.setTimestamp(4, timestamp2);
pstmt.setInt(5, 10);
pstmt.setLong(6, length);
pstmt.setString(7,"Testing row");
pstmt.setString(8,"Keep for ever");
pstmt.setString(9,"14 July");
pstmt.setString(10,"pcap");
}catch (SQLException e2){
System.out.println(e2.getMessage());
}
// Insert the row
try{
pstmt.executeUpdate();
}catch (SQLException e2){
System.out.println(e2.getMessage());
// e2.printStackTrace();
}
// Close the Prepared Statement
try{
pstmt.close();
}catch (SQLException e2){
System.out.println(e2.getMessage());
}
And i get this error:
No value specified for parameter 1.
Do you know how i can avoid this error without setting any value to first column?

