List of usage examples for java.sql PreparedStatement setBoolean
void setBoolean(int parameterIndex, boolean x) throws SQLException;
boolean
value. From source file:org.apache.sqoop.repository.common.CommonRepositoryHandler.java
/** * {@inheritDoc}//from ww w. java2 s . co m */ public void createJob(MJob job, Connection conn) { PreparedStatement stmt = null; int result; try { stmt = conn.prepareStatement(crudQueries.getStmtInsertJob(), Statement.RETURN_GENERATED_KEYS); stmt.setString(1, job.getName()); stmt.setLong(2, job.getFromLinkId()); stmt.setLong(3, job.getToLinkId()); stmt.setBoolean(4, job.getEnabled()); stmt.setString(5, job.getCreationUser()); stmt.setTimestamp(6, new Timestamp(job.getCreationDate().getTime())); stmt.setString(7, job.getLastUpdateUser()); stmt.setTimestamp(8, new Timestamp(job.getLastUpdateDate().getTime())); result = stmt.executeUpdate(); if (result != 1) { throw new SqoopException(CommonRepositoryError.COMMON_0009, Integer.toString(result)); } ResultSet rsetJobId = stmt.getGeneratedKeys(); if (!rsetJobId.next()) { throw new SqoopException(CommonRepositoryError.COMMON_0010); } long jobId = rsetJobId.getLong(1); // from config for the job createInputValues(crudQueries.getStmtInsertJobInput(), jobId, job.getFromJobConfig().getConfigs(), conn); // to config for the job createInputValues(crudQueries.getStmtInsertJobInput(), jobId, job.getToJobConfig().getConfigs(), conn); // driver config per job createInputValues(crudQueries.getStmtInsertJobInput(), jobId, job.getDriverConfig().getConfigs(), conn); job.setPersistenceId(jobId); } catch (SQLException ex) { logException(ex, job); throw new SqoopException(CommonRepositoryError.COMMON_0023, ex); } finally { closeStatements(stmt); } }
From source file:com.alfaariss.oa.engine.session.jdbc.JDBCSessionFactory.java
/** * Persist the session in the JDBC storage. * //w ww .ja v a 2 s . c om * The sessionstate is saved with its name. * @param session The session to persist. * @throws PersistenceException If persistance fails. * @see IEntityManager#persist(IEntity) */ public void persist(JDBCSession session) throws PersistenceException { if (session == null) throw new IllegalArgumentException("Suplied session is empty or invalid"); Connection oConnection = null; PreparedStatement psInsert = null; PreparedStatement psDelete = null; PreparedStatement psUpdate = null; String id = session.getId(); try { oConnection = _oDataSource.getConnection(); if (id == null) // New Session { try { byte[] baId = new byte[ISession.ID_BYTE_LENGTH]; do { _random.nextBytes(baId); try { id = ModifiedBase64.encode(baId); } catch (UnsupportedEncodingException e) { _logger.error("Could not create id for byte[]: " + baId, e); throw new PersistenceException(SystemErrors.ERROR_INTERNAL); } } while (exists(id)); //Key allready exists // Update expiration time and id long expiration = System.currentTimeMillis() + _lExpiration; session.setTgtExpTime(expiration); session.setId(id); //Create statement psInsert = oConnection.prepareStatement(_sInsertQuery); psInsert.setString(1, id); psInsert.setString(2, session.getTGTId()); psInsert.setInt(3, session.getState().ordinal()); psInsert.setString(4, session.getRequestorId()); psInsert.setString(5, session.getProfileURL()); psInsert.setBytes(6, Serialize.encode(session.getUser())); psInsert.setTimestamp(7, new Timestamp(expiration)); psInsert.setBoolean(8, session.isForcedAuthentication()); psInsert.setBoolean(9, session.isPassive()); psInsert.setBytes(10, Serialize.encode(session.getAttributes())); psInsert.setString(11, session.getForcedUserID()); psInsert.setBytes(12, Serialize.encode(session.getLocale())); psInsert.setBytes(13, Serialize.encode(session.getSelectedAuthNProfile())); psInsert.setBytes(14, Serialize.encode(session.getAuthNProfiles())); int i = psInsert.executeUpdate(); _logger.info(i + " new session(s) added: " + id + " for requestor '" + session.getRequestorId() + "'"); } catch (SQLException e) { _logger.error("Could not execute insert query: " + _sInsertQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_INSERT); } } else if (session.isExpired()) // Expired { try { _logger.info("Session Expired: " + id); _eventLogger.info(new UserEventLogItem(session, null, UserEvent.SESSION_EXPIRED, this, null)); psDelete = oConnection.prepareStatement(_sRemoveQuery); psDelete.setString(1, id); int i = psDelete.executeUpdate(); _logger.debug(i + " session(s) removed: " + id); } catch (SQLException e) { _logger.error("Could not execute delete query: " + _sRemoveQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_REMOVE); } } else // Update { try { // Update expiration time long expiration = System.currentTimeMillis() + _lExpiration; session.setExpTime(expiration); psUpdate = oConnection.prepareStatement(_sUpdateQuery); psUpdate.setString(1, session.getTGTId()); psUpdate.setInt(2, session.getState().ordinal()); psUpdate.setString(3, session.getRequestorId()); psUpdate.setString(4, session.getProfileURL()); psUpdate.setBytes(5, Serialize.encode(session.getUser())); psUpdate.setTimestamp(6, new Timestamp(expiration)); psUpdate.setBoolean(7, session.isForcedAuthentication()); psUpdate.setBoolean(8, session.isPassive()); psUpdate.setBytes(9, Serialize.encode(session.getAttributes())); psUpdate.setString(10, session.getForcedUserID()); psUpdate.setBytes(11, Serialize.encode(session.getLocale())); psUpdate.setBytes(12, Serialize.encode(session.getSelectedAuthNProfile())); psUpdate.setBytes(13, Serialize.encode(session.getAuthNProfiles())); psUpdate.setString(14, id); int i = psUpdate.executeUpdate(); _logger.info( i + " session(s) updated: " + id + " for requestor '" + session.getRequestorId() + "'"); } catch (SQLException e) { _logger.error("Could not execute update query: " + _sUpdateQuery, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_UPDATE); } } } catch (PersistenceException e) { throw e; } catch (Exception e) { _logger.error("Internal error during persist of session with id: " + id, e); throw new PersistenceException(SystemErrors.ERROR_RESOURCE_UPDATE); } finally { try { if (psInsert != null) psInsert.close(); } catch (SQLException e) { _logger.debug("Could not close insert statement", e); } try { if (psDelete != null) psDelete.close(); } catch (SQLException e) { _logger.debug("Could not close delete statement", e); } try { if (psUpdate != null) psUpdate.close(); } catch (SQLException e) { _logger.debug("Could not close update statement", e); } try { if (oConnection != null) oConnection.close(); } catch (SQLException e) { _logger.debug("Could not close connection", e); } } }
From source file:org.methodize.nntprss.feed.db.JdbcChannelDAO.java
public void saveItem(Item item) { Connection conn = null;//from ww w . ja v a2 s .c o m PreparedStatement ps = null; try { conn = DriverManager.getConnection(JdbcChannelDAO.POOL_CONNECT_STRING); ps = conn.prepareStatement("INSERT INTO " + TABLE_ITEMS + "(articleNumber, channel, title, link, description, comments, dtStamp, signature, creator, guid, guidIsPermaLink) " + "VALUES(?,?,?,?,?,?,?,?,?,?,?)"); int paramCount = 1; ps.setInt(paramCount++, item.getArticleNumber()); ps.setInt(paramCount++, item.getChannel().getId()); ps.setString(paramCount++, trim(item.getTitle(), FIELD_ITEM_TITLE_LENGTH)); ps.setString(paramCount++, item.getLink()); ps.setString(paramCount++, item.getDescription()); ps.setString(paramCount++, item.getComments()); ps.setTimestamp(paramCount++, new Timestamp(item.getDate().getTime())); ps.setString(paramCount++, item.getSignature()); ps.setString(paramCount++, trim(item.getCreator(), FIELD_ITEM_CREATOR_LENGTH)); ps.setString(paramCount++, item.getGuid()); ps.setBoolean(paramCount++, item.isGuidIsPermaLink()); ps.executeUpdate(); // Update associated category... if (item.getChannel().getCategory() != null) { ps.close(); ps = conn.prepareStatement("INSERT INTO " + TABLE_CATEGORYITEM + "(category, articleNumber, channel, channelArticleNumber) values(?,?,?,?)"); paramCount = 1; ps.setInt(paramCount++, item.getChannel().getCategory().getId()); ps.setInt(paramCount++, item.getChannel().getCategory().nextArticleNumber()); ps.setInt(paramCount++, item.getChannel().getId()); ps.setInt(paramCount++, item.getArticleNumber()); ps.executeUpdate(); } } catch (SQLException se) { throw new RuntimeException(se); } finally { try { if (ps != null) ps.close(); } catch (SQLException se) { } try { if (conn != null) conn.close(); } catch (SQLException se) { } } }
From source file:com.flexive.ejb.beans.ScriptingEngineBean.java
/** * {@inheritDoc}//ww w . j av a 2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxScriptMappingEntry updateAssignmentScriptMappingForEvent(long scriptId, long assignmentId, FxScriptEvent event, boolean active, boolean derivedUsage) throws FxApplicationException { FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement); FxScriptMappingEntry sm; Connection con = null; PreparedStatement ps = null; String sql; boolean success = false; //check script existance CacheAdmin.getEnvironment().getScript(scriptId); checkAssignmentScriptConsistency(scriptId, assignmentId, event, active, derivedUsage); try { long[] derived; if (!derivedUsage) derived = new long[0]; else { List<FxAssignment> ass = CacheAdmin.getEnvironment().getDerivedAssignments(assignmentId); derived = new long[ass.size()]; for (int i = 0; i < ass.size(); i++) derived[i] = ass.get(i).getId(); } sm = new FxScriptMappingEntry(event, scriptId, active, derivedUsage, assignmentId, derived); // Obtain a database connection con = Database.getDbConnection(); // 1 2 3 4 sql = "UPDATE " + TBL_SCRIPT_MAPPING_ASSIGN + " SET DERIVED_USAGE=?,ACTIVE=? WHERE ASSIGNMENT=? AND SCRIPT=? AND STYPE=?"; ps = con.prepareStatement(sql); ps.setBoolean(1, sm.isDerivedUsage()); ps.setBoolean(2, sm.isActive()); ps.setLong(3, sm.getId()); ps.setLong(4, sm.getScriptId()); ps.setLong(5, sm.getScriptEvent().getId()); ps.executeUpdate(); success = true; } catch (SQLException exc) { if (StorageManager.isUniqueConstraintViolation(exc)) throw new FxEntryExistsException("ex.scripting.mapping.assign.notUnique", scriptId, assignmentId); throw new FxUpdateException(LOG, exc, "ex.scripting.mapping.assign.update.failed", scriptId, assignmentId, exc.getMessage()); } finally { Database.closeObjects(ScriptingEngineBean.class, con, ps); if (!success) EJBUtils.rollback(ctx); else StructureLoader.reloadScripting(FxContext.get().getDivisionId()); } return sm; }
From source file:com.flexive.ejb.beans.ScriptingEngineBean.java
/** * {@inheritDoc}//from ww w. j av a 2 s. c om */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxScriptMappingEntry updateTypeScriptMappingForEvent(long scriptId, long typeId, FxScriptEvent event, boolean active, boolean derivedUsage) throws FxApplicationException { FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement); FxScriptMappingEntry sm; Connection con = null; PreparedStatement ps = null; String sql; boolean success = false; //check existance CacheAdmin.getEnvironment().getScript(scriptId); //check consistency checkTypeScriptConsistency(scriptId, typeId, event, active, derivedUsage); try { long[] derived; if (!derivedUsage) derived = new long[0]; else { List<FxType> types = CacheAdmin.getEnvironment().getType(typeId).getDerivedTypes(); derived = new long[types.size()]; for (int i = 0; i < types.size(); i++) derived[i] = types.get(i).getId(); } sm = new FxScriptMappingEntry(event, scriptId, active, derivedUsage, typeId, derived); // Obtain a database connection con = Database.getDbConnection(); // 1 2 3 4 5 sql = "UPDATE " + TBL_SCRIPT_MAPPING_TYPES + " SET DERIVED_USAGE=?,ACTIVE=? WHERE TYPEDEF=? AND SCRIPT=? AND STYPE=?"; ps = con.prepareStatement(sql); ps.setBoolean(1, sm.isDerivedUsage()); ps.setBoolean(2, sm.isActive()); ps.setLong(3, sm.getId()); ps.setLong(4, sm.getScriptId()); ps.setLong(5, sm.getScriptEvent().getId()); ps.executeUpdate(); success = true; } catch (SQLException exc) { if (StorageManager.isUniqueConstraintViolation(exc)) throw new FxEntryExistsException("ex.scripting.mapping.type.notUnique", scriptId, typeId); throw new FxUpdateException(LOG, exc, "ex.scripting.mapping.type.update.failed", scriptId, typeId, exc.getMessage()); } finally { Database.closeObjects(ScriptingEngineBean.class, con, ps); if (!success) EJBUtils.rollback(ctx); else StructureLoader.reloadScripting(FxContext.get().getDivisionId()); } return sm; }
From source file:org.apache.sqoop.repository.common.CommonRepositoryHandler.java
/** * Save given inputs to the database.//w w w . j a v a 2s . co m * * Use given prepare statement to save all inputs into repository. * * @param config * corresponding config * @param inputs * List of inputs that needs to be saved * @param baseInputStmt * Statement that we can utilize * @throws java.sql.SQLException * In case of any failure on Derby side */ private void registerConfigInputs(MConfig config, List<MInput<?>> inputs, PreparedStatement baseInputStmt) throws SQLException { short inputIndex = 0; for (MInput<?> input : inputs) { baseInputStmt.setString(1, input.getName()); baseInputStmt.setLong(2, config.getPersistenceId()); baseInputStmt.setShort(3, inputIndex++); baseInputStmt.setString(4, input.getType().name()); baseInputStmt.setBoolean(5, input.isSensitive()); // String specific column(s) if (input.getType().equals(MInputType.STRING)) { MStringInput strInput = (MStringInput) input; baseInputStmt.setShort(6, strInput.getMaxLength()); } else { baseInputStmt.setNull(6, Types.INTEGER); } baseInputStmt.setString(7, input.getEditable().name()); // Enum specific column(s) if (input.getType() == MInputType.ENUM) { baseInputStmt.setString(8, StringUtils.join(((MEnumInput) input).getValues(), ",")); } else { baseInputStmt.setNull(8, Types.VARCHAR); } int baseInputCount = baseInputStmt.executeUpdate(); if (baseInputCount != 1) { throw new SqoopException(CommonRepositoryError.COMMON_0014, Integer.toString(baseInputCount)); } ResultSet rsetInputId = baseInputStmt.getGeneratedKeys(); if (!rsetInputId.next()) { throw new SqoopException(CommonRepositoryError.COMMON_0015); } long inputId = rsetInputId.getLong(1); input.setPersistenceId(inputId); } }
From source file:org.ims.ssp.samplerte.server.SSP_Servlet.java
/** * This method stores the bucket information within a database for tracking. * @param iDescription//from ww w . j ava2 s .co m * * @return boolean - true if successful */ private boolean track(BucketAllocation iDescription) { if (_Debug) { System.out.println("Entering SSP_Servlet::track"); } boolean result = true; try { if (_Debug) { System.out.println("Getting connection to database"); } new SSP_DBHandler(); Connection conn = SSP_DBHandler.getConnection(); PreparedStatement stmtInsertBucket; if (iDescription.getReallocateFailure() == false) { String sqlInsertBucket = "INSERT INTO SSP_BucketAllocateTbl (CourseID, LearnerID, " + "BucketID, BucketType, Persistence, Min, Requested, " + "Reducible, Status, AttemptID, ManagedBucketIndex, SCOID) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmtInsertBucket = conn.prepareStatement(sqlInsertBucket); synchronized (stmtInsertBucket) { stmtInsertBucket.setString(1, iDescription.getCourseID()); stmtInsertBucket.setString(2, iDescription.getStudentID()); stmtInsertBucket.setString(3, iDescription.getBucketID()); stmtInsertBucket.setString(4, iDescription.getBucketType()); stmtInsertBucket.setInt(5, iDescription.getPersistence()); stmtInsertBucket.setInt(6, iDescription.getMinimumSizeInt()); stmtInsertBucket.setInt(7, iDescription.getRequestedSizeInt()); stmtInsertBucket.setBoolean(8, iDescription.getReducibleBoolean()); stmtInsertBucket.setInt(9, iDescription.getAllocationStatus()); stmtInsertBucket.setString(10, iDescription.getAttemptID()); stmtInsertBucket.setInt(11, iDescription.getManagedBucketIndex()); stmtInsertBucket.setString(12, iDescription.getSCOID()); stmtInsertBucket.executeUpdate(); } } else { String sqlInsertBucket = "INSERT INTO SSP_BucketAllocateTbl (CourseID, LearnerID, " + "BucketID, BucketType, Persistence, Min, Requested, " + "Reducible, Status, AttemptID, ManagedBucketIndex," + "SCOID, ReallocateFailure) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmtInsertBucket = conn.prepareStatement(sqlInsertBucket); synchronized (stmtInsertBucket) { stmtInsertBucket.setString(1, iDescription.getCourseID()); stmtInsertBucket.setString(2, iDescription.getStudentID()); stmtInsertBucket.setString(3, iDescription.getBucketID()); stmtInsertBucket.setString(4, iDescription.getBucketType()); stmtInsertBucket.setInt(5, iDescription.getPersistence()); stmtInsertBucket.setInt(6, iDescription.getMinimumSizeInt()); stmtInsertBucket.setInt(7, iDescription.getRequestedSizeInt()); stmtInsertBucket.setBoolean(8, iDescription.getReducibleBoolean()); stmtInsertBucket.setInt(9, iDescription.getAllocationStatus()); stmtInsertBucket.setString(10, iDescription.getAttemptID()); stmtInsertBucket.setInt(11, iDescription.getManagedBucketIndex()); stmtInsertBucket.setString(12, iDescription.getSCOID()); stmtInsertBucket.setBoolean(13, true); stmtInsertBucket.executeUpdate(); } } // Close the statements stmtInsertBucket.close(); conn.close(); } catch (Exception e) { result = false; e.printStackTrace(); } if (_Debug) { System.out.println("Exiting SSP_Servlet::track -- result = " + result); } return result; }
From source file:com.flexive.ejb.beans.ScriptingEngineBean.java
/** * {@inheritDoc}/* w ww .jav a 2s. c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxScriptMappingEntry createAssignmentScriptMapping(FxScriptEvent scriptEvent, long scriptId, long assignmentId, boolean active, boolean derivedUsage) throws FxApplicationException { FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement); FxScriptMappingEntry sm; Connection con = null; PreparedStatement ps = null; String sql; boolean success = false; //check existance CacheAdmin.getEnvironment().getScript(scriptId); checkAssignmentScriptConsistency(scriptId, assignmentId, scriptEvent, active, derivedUsage); try { long[] derived; if (!derivedUsage) derived = new long[0]; else { List<FxAssignment> ass = CacheAdmin.getEnvironment().getDerivedAssignments(assignmentId); derived = new long[ass.size()]; for (int i = 0; i < ass.size(); i++) derived[i] = ass.get(i).getId(); } sm = new FxScriptMappingEntry(scriptEvent, scriptId, active, derivedUsage, assignmentId, derived); // Obtain a database connection con = Database.getDbConnection(); sql = "INSERT INTO " + TBL_SCRIPT_MAPPING_ASSIGN + " (ASSIGNMENT,SCRIPT,DERIVED_USAGE,ACTIVE,STYPE) VALUES " + //1,2,3,4,5 "(?,?,?,?,?)"; ps = con.prepareStatement(sql); ps.setLong(1, sm.getId()); ps.setLong(2, sm.getScriptId()); ps.setBoolean(3, sm.isDerivedUsage()); ps.setBoolean(4, sm.isActive()); ps.setLong(5, sm.getScriptEvent().getId()); ps.executeUpdate(); success = true; } catch (SQLException exc) { if (StorageManager.isUniqueConstraintViolation(exc)) throw new FxEntryExistsException("ex.scripting.mapping.assign.notUnique", scriptId, assignmentId); throw new FxCreateException(LOG, exc, "ex.scripting.mapping.assign.create.failed", scriptId, assignmentId, exc.getMessage()); } finally { Database.closeObjects(ScriptingEngineBean.class, con, ps); if (!success) EJBUtils.rollback(ctx); else StructureLoader.reloadScripting(FxContext.get().getDivisionId()); } return sm; }
From source file:com.flexive.ejb.beans.ScriptingEngineBean.java
/** * {@inheritDoc}// w w w .ja va 2 s . c om */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxScriptMappingEntry createTypeScriptMapping(FxScriptEvent scriptEvent, long scriptId, long typeId, boolean active, boolean derivedUsage) throws FxApplicationException { FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement); FxScriptMappingEntry sm; Connection con = null; PreparedStatement ps = null; String sql; boolean success = false; //check existance CacheAdmin.getEnvironment().getScript(scriptId); //check consistency checkTypeScriptConsistency(scriptId, typeId, scriptEvent, active, derivedUsage); try { long[] derived; if (!derivedUsage) derived = new long[0]; else { List<FxType> types = CacheAdmin.getEnvironment().getType(typeId).getDerivedTypes(); derived = new long[types.size()]; for (int i = 0; i < types.size(); i++) derived[i] = types.get(i).getId(); } sm = new FxScriptMappingEntry(scriptEvent, scriptId, active, derivedUsage, typeId, derived); // Obtain a database connection con = Database.getDbConnection(); sql = "INSERT INTO " + TBL_SCRIPT_MAPPING_TYPES + " (TYPEDEF,SCRIPT,DERIVED_USAGE,ACTIVE,STYPE) VALUES " + //1,2,3,4,5 "(?,?,?,?,?)"; ps = con.prepareStatement(sql); ps.setLong(1, sm.getId()); ps.setLong(2, sm.getScriptId()); ps.setBoolean(3, sm.isDerivedUsage()); ps.setBoolean(4, sm.isActive()); ps.setLong(5, sm.getScriptEvent().getId()); ps.executeUpdate(); success = true; } catch (SQLException exc) { if (StorageManager.isUniqueConstraintViolation(exc)) throw new FxEntryExistsException("ex.scripting.mapping.type.notUnique", scriptId, typeId); throw new FxCreateException(LOG, exc, "ex.scripting.mapping.type.create.failed", scriptId, typeId, exc.getMessage()); } finally { Database.closeObjects(ScriptingEngineBean.class, con, ps); if (!success) EJBUtils.rollback(ctx); else StructureLoader.reloadScripting(FxContext.get().getDivisionId()); } return sm; }
From source file:com.uas.document.DocumentDAO.java
@Override public DocumentDTO createDocument(DocumentDTO dDto) { PreparedStatement preparedStmt = null; Connection c = null;/*from w w w . jav a2 s . c o m*/ ResultSet rs = null; // try { c = DataSourceSingleton.getInstance().getConnection(); String SQL = "INSERT INTO \"public\".\"document\" (\"id\",\"fileName\",\"fileDate\",\"idArea\",\"isFolder\") VALUES (?,?,?,?,?)"; preparedStmt = c.prepareStatement(SQL); preparedStmt.setInt(1, dDto.getId()); //System.out.println(""); preparedStmt.setString(2, dDto.getFilename()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); ////System.out.println("Dto.getFileDate().substring(0,10): " + dDto.getFileDate().substring(0,10)); java.util.Date parsedDate = dateFormat.parse(dDto.getFileDate().substring(0, 10)); Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime()); preparedStmt.setTimestamp(3, timestamp); preparedStmt.setInt(4, dDto.getIdArea()); preparedStmt.setBoolean(5, dDto.getIsFolder()); preparedStmt.executeUpdate(); TransactionRecordFacade tFac = new TransactionRecordFacade(); TransactionRecordDTO tDto = new TransactionRecordDTO(); tDto.getObjectDTO().setId(dDto.getId()); tDto.getTransactionTypeDTO().setId(3); tDto.getUsuarioDTO().setId(dDto.getCreatedBy()); tFac.createTransactionRecord(tDto); } catch (Exception e) { e.printStackTrace(); } finally { try { if (c != null) { c.close(); } if (rs != null) { rs.close(); } if (preparedStmt != null) { preparedStmt.close(); } } catch (Exception e) { e.printStackTrace(); } } return dDto; }