rajcspalani
asked on
oracle sysdate in preparedstatement
I am using preparedstatement to insert values into my table.Here is My table structure AUDIT_TRIAL (number,number,timestamp,v archar2). I want to insert current date & time on 3rd column, so, i am using sysdate(stmt.setString(3," sysdate")) , but it is giving error that "ORA-01858: a non-numeric character was found where a numeric was expected". Please resolve this issue.
Advance thanks
Advance thanks
public static void addAuditTrial(int adminId, String desc){
Connection con = null;
PreparedStatement stmt = null;
String insertStatement = "insert into "+ADMIN_AUDIT_TRIAL+" values(?,?,?,?)";
try {
con = DBConnection.getDBConnection();
int nextId = DBConnection.getNextID(ADMIN_AUDIT_TRIAL, "AT_ID", con);
stmt = con.prepareStatement(insertStatement);
stmt.setInt(1, nextId);
stmt.setInt(2, adminId);
stmt.setString(3, "sysdate");
stmt.setString(4, desc);
stmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
finally {
try {
stmt.close();
DBConnection.closeConnection(con);
} catch (Exception e) {
e.printStackTrace();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER