List of usage examples for java.sql PreparedStatement execute
boolean execute() throws SQLException;
PreparedStatement
object, which may be any kind of SQL statement. From source file:at.becast.youploader.database.SQLite.java
public static Boolean deleteTemplate(int id) { PreparedStatement prest = null; String sql = "DELETE FROM `templates` WHERE `id`=?"; try {/* w ww . ja v a 2 s . co m*/ prest = c.prepareStatement(sql); prest.setInt(1, id); boolean res = prest.execute(); prest.close(); return res; } catch (SQLException e) { LOG.error("Error deleting Template ", e); return false; } }
From source file:at.becast.youploader.database.SQLite.java
public static void setPlaylistHidden(int id, String hidden) throws SQLException { PreparedStatement prest = null; String sql = "UPDATE `playlists` SET `shown`=? WHERE `id`=?"; prest = c.prepareStatement(sql);//from w w w . ja va2 s .c o m prest.setString(1, hidden); prest.setInt(2, id); prest.execute(); prest.close(); }
From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.DM.java
public static void saveData() { java.sql.Connection con = null; try {/* w ww .j av a2 s . c o m*/ con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement; statement = con.prepareStatement("Delete from dm"); statement.execute(); statement.close(); statement = con.prepareStatement( "INSERT INTO dm (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, rewardId, rewardAmount, color, playerX, playerY, playerZ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); statement.setString(1, _eventName); statement.setString(2, _eventDesc); statement.setString(3, _joiningLocationName); statement.setInt(4, _minlvl); statement.setInt(5, _maxlvl); statement.setInt(6, _npcId); statement.setInt(7, _npcX); statement.setInt(8, _npcY); statement.setInt(9, _npcZ); statement.setInt(10, _rewardId); statement.setInt(11, _rewardAmount); statement.setInt(12, _playerColors); statement.setInt(13, _playerX); statement.setInt(14, _playerY); statement.setInt(15, _playerZ); statement.execute(); statement.close(); } catch (Exception e) { _log.error("Exception: DM.saveData(): " + e.getMessage()); } finally { try { con.close(); } catch (Exception e) { } } }
From source file:at.becast.youploader.database.SQLite.java
public static Boolean deleteUpload(int upload_id) { PreparedStatement prest = null; String sql = "DELETE FROM `uploads` WHERE `id`=?"; try {/*www . j a v a 2 s . c o m*/ prest = c.prepareStatement(sql); prest.setInt(1, upload_id); boolean res = prest.execute(); prest.close(); return res; } catch (SQLException e) { LOG.error("Error deleting upload", e); return false; } }
From source file:com.tethrnet.manage.db.UserDB.java
/** * updates existing user/*from w w w. ja va2 s . c o m*/ * @param user user object */ public static void updateUserNoCredentials(User user) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con .prepareStatement("update users set email=?, username=?, user_type=? where id=?"); stmt.setString(1, user.getEmail()); stmt.setString(2, user.getUsername()); stmt.setString(3, user.getUserType()); stmt.setLong(4, user.getId()); stmt.execute(); DBUtils.closeStmt(stmt); if (User.ADMINISTRATOR.equals(user.getUserType())) { PublicKeyDB.deleteUnassignedKeysByUser(con, user.getId()); } } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * re-enables SSH key//from www .jav a 2 s .c om * * @param id key id */ public static void enableKey(Long id) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement("update public_keys set enabled=true where id=?"); stmt.setLong(1, id); stmt.execute(); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * disables SSH key//from w w w . j a v a 2 s.com * * @param id key id */ public static void disableKey(Long id) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement("update public_keys set enabled=false where id=?"); stmt.setLong(1, id); stmt.execute(); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * deletes all public keys for a profile * * @param profileId profile id/*from w w w . ja v a 2 s. c o m*/ */ public static void deleteProfilePublicKeys(Long profileId) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement("delete from public_keys where profile_id=?"); stmt.setLong(1, profileId); stmt.execute(); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:at.becast.youploader.database.SQLite.java
public static Boolean updateUploadProgress(int id, long progress) { PreparedStatement prest = null; String sql = "UPDATE `uploads` SET `uploaded`=? WHERE `id`=?"; try {/*from w w w .jav a 2 s. c o m*/ prest = c.prepareStatement(sql); prest.setLong(1, progress); prest.setInt(2, id); boolean res = prest.execute(); prest.close(); return res; } catch (SQLException e) { LOG.error("Error updating upload progress", e); return false; } }
From source file:com.l2jfree.gameserver.model.entity.events.DM.java
public static void saveData() { Connection con = null;/*from w ww. j a v a 2s. com*/ try { con = L2DatabaseFactory.getInstance().getConnection(con); PreparedStatement statement; statement = con.prepareStatement("Delete from dm"); statement.execute(); statement.close(); statement = con.prepareStatement( "INSERT INTO dm (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, rewardId, rewardAmount, color, playerX, playerY, playerZ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); statement.setString(1, _eventName); statement.setString(2, _eventDesc); statement.setString(3, _joiningLocationName); statement.setInt(4, _minlvl); statement.setInt(5, _maxlvl); statement.setInt(6, _npcId); statement.setInt(7, _npcX); statement.setInt(8, _npcY); statement.setInt(9, _npcZ); statement.setInt(10, _rewardId); statement.setInt(11, _rewardAmount); statement.setInt(12, _playerColors); statement.setInt(13, _playerX); statement.setInt(14, _playerY); statement.setInt(15, _playerZ); statement.execute(); statement.close(); } catch (Exception e) { _log.error("Exception: DM.saveData(): ", e); } finally { L2DatabaseFactory.close(con); } }