troubleshooting Question

oracle sysdate in preparedstatement

Avatar of rajcspalani
rajcspalani asked on
Oracle DatabaseJava
2 Comments1 Solution2868 ViewsLast Modified:
I am using preparedstatement to insert values into my table.Here is My table structure  AUDIT_TRIAL (number,number,timestamp,varchar2). 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

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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros