问题描述
public boolean getInsert(NewCustomer customer) {Connection conn = null;PreparedStatement stmt = null;boolean a = false;int result = -1;conn = OracleDAOFactory.getConnection(); try{stmt = conn.prepareStatement(INSERT_CUSTOMER_CLIENT);stmt.setString(1, customer.getCertificate());stmt.setString(2, customer.getCertificateNumber());stmt.setString(3, customer.getUname());stmt.setString(4,customer.getBirthday());//这里是获取的日期格式(生日),怎么用to_date来插入到Oracle 数据库存里面.stmt.setString(5,customer.getSex());stmt.setString(6,customer.getAddess());result = stmt.executeUpdate();if(result>0){a = true;}}catch(SQLException e){e.printStackTrace();a = false;}finally {OracleDAOFactory.closeStatement(stmt);OracleDAOFactory.closeConnection(conn);}return a;}
解决方案
可以使用SimpleDateFormat类进行转换