use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericKarmaDAO method addKarma.
/**
* @see net.jforum.dao.KarmaDAO#addKarma(net.jforum.entities.Karma)
*/
public void addKarma(Karma karma) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("KarmaModel.add"));
p.setInt(1, karma.getPostId());
p.setInt(2, karma.getPostUserId());
p.setInt(3, karma.getFromUserId());
p.setInt(4, karma.getPoints());
p.setInt(5, karma.getTopicId());
p.setTimestamp(6, new Timestamp((new Date()).getTime()));
p.executeUpdate();
this.updateUserKarma(karma.getPostUserId());
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericAttachmentDAO method addAttachment.
/**
* @see net.jforum.dao.AttachmentDAO#addAttachment(net.jforum.entities.Attachment)
*/
public void addAttachment(Attachment a) {
PreparedStatement p = null;
try {
p = this.getStatementForAutoKeys("AttachmentModel.addAttachment");
p.setInt(1, a.getPostId());
p.setInt(2, a.getPrivmsgsId());
p.setInt(3, a.getUserId());
this.setAutoGeneratedKeysQuery(SystemGlobals.getSql("AttachmentModel.lastGeneratedAttachmentId"));
int id = this.executeAutoKeysQuery(p);
p.close();
p = null;
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.addAttachmentInfo"));
p.setInt(1, id);
p.setString(2, a.getInfo().getPhysicalFilename());
p.setString(3, a.getInfo().getRealFilename());
p.setString(4, a.getInfo().getComment());
p.setString(5, a.getInfo().getMimetype());
p.setLong(6, a.getInfo().getFilesize());
p.setTimestamp(7, new Timestamp(a.getInfo().getUploadTimeInMillis()));
p.setInt(8, 0);
p.setInt(9, a.getInfo().getExtension().getId());
p.executeUpdate();
this.updatePost(a.getPostId(), 1);
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericUserDAO method update.
/**
* @see net.jforum.dao.UserDAO#update(net.jforum.entities.User)
*/
public void update(User user) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.update"));
p.setString(1, user.getAim());
p.setString(2, user.getAvatar());
p.setString(3, user.getGender());
p.setInt(4, user.getThemeId());
p.setInt(5, user.isPrivateMessagesEnabled() ? 1 : 0);
p.setInt(6, user.isAvatarEnabled() ? 1 : 0);
p.setInt(7, user.isBbCodeEnabled() ? 1 : 0);
p.setInt(8, user.isHtmlEnabled() ? 1 : 0);
p.setInt(9, user.isSmiliesEnabled() ? 1 : 0);
p.setString(10, user.getEmail());
p.setString(11, user.getFrom());
p.setString(12, user.getIcq());
p.setString(13, user.getInterests());
p.setString(14, user.getOccupation());
p.setString(15, user.getSignature());
p.setString(16, user.getWebSite());
p.setString(17, user.getYim());
p.setString(18, user.getMsnm());
p.setString(19, user.getPassword());
p.setInt(20, user.isViewEmailEnabled() ? 1 : 0);
p.setInt(21, user.isViewOnlineEnabled() ? 1 : 0);
p.setInt(22, user.isNotifyOnMessagesEnabled() ? 1 : 0);
p.setInt(23, user.getAttachSignatureEnabled() ? 1 : 0);
p.setString(24, user.getUsername());
p.setString(25, user.getLang());
p.setInt(26, user.isNotifyPrivateMessagesEnabled() ? 1 : 0);
p.setString(27, user.getBiography());
if (user.getLastVisit() == null) {
user.setLastVisit(new Date());
}
p.setTimestamp(28, new Timestamp(user.getLastVisit().getTime()));
p.setInt(29, user.notifyAlways() ? 1 : 0);
p.setInt(30, user.notifyText() ? 1 : 0);
p.setInt(31, user.getRankId());
p.setInt(32, user.getId());
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericUserSessionDAO method update.
/**
* @see net.jforum.dao.UserSessionDAO#update(net.jforum.entities.UserSession,
* java.sql.Connection)
*/
public void update(UserSession us, Connection conn) {
if (this.selectById(us, conn) == null) {
this.add(us, conn, true);
return;
}
PreparedStatement p = null;
try {
p = conn.prepareStatement(SystemGlobals.getSql("UserSessionModel.update"));
p.setTimestamp(1, new Timestamp(us.getStartTime().getTime()));
p.setLong(2, us.getSessionTime());
p.setString(3, us.getSessionId());
p.setInt(4, us.getUserId());
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericUserSessionDAO method add.
private void add(UserSession us, Connection conn, boolean checked) {
if (!checked && this.selectById(us, conn) != null) {
return;
}
PreparedStatement p = null;
try {
p = conn.prepareStatement(SystemGlobals.getSql("UserSessionModel.add"));
p.setString(1, us.getSessionId());
p.setInt(2, us.getUserId());
p.setTimestamp(3, new Timestamp(us.getStartTime().getTime()));
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations