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:edu.umd.cs.psl.database.rdbms.RDBMSDataStoreMetadata.java
public void createMetadataTable() { if (checkIfMetadataTableExists()) return;/*from w w w.j a v a 2 s . c o m*/ try { PreparedStatement stmt = conn.prepareStatement("CREATE TABLE " + mdTableName + " (namespace VARCHAR(20), keytype VARCHAR(20), key VARCHAR(255), value VARCHAR(255), PRIMARY KEY(namespace,keytype,key))"); stmt.execute(); } catch (Exception e) { log.error("Error while creating metadata table - " + e.getMessage()); } }
From source file:bdManager.DBConnectionManager.java
public ResultSet execute(PreparedStatement statement, boolean isQuery) throws SQLException { if (isQuery) { ResultSet rs = null;//from ww w .ja v a 2 s.com rs = statement.executeQuery(); return rs; } else { statement.execute(); } return null; }
From source file:com.l2jfree.gameserver.model.entity.GrandBossState.java
public void save() { Connection con = null;//from w w w . j a va 2 s .com try { con = L2DatabaseFactory.getInstance().getConnection(con); PreparedStatement statement = con.prepareStatement( "INSERT INTO grandboss_intervallist (bossId,respawnDate,state) VALUES(?,?,?)"); statement.setInt(1, _bossId); statement.setLong(2, _respawnDate); statement.setInt(3, _state.ordinal()); statement.execute(); statement.close(); } catch (Exception e) { _log.error(e.getMessage(), e); } finally { L2DatabaseFactory.close(con); } }
From source file:pl.edu.agh.iosr.lsf.dao.DatabaseHelper.java
public void deleteKeyword(String key) throws SQLException { try (Connection c = source.getConnection()) { PreparedStatement ps = c.prepareStatement(getStatement("D_KEYWORD")); ps.setString(1, key);//from www.j a v a 2s. com ps.execute(); } }
From source file:com.l2jfree.gameserver.model.entity.GrandBossState.java
public void update() { Connection con = null;/*w w w . ja v a 2 s.c o m*/ try { con = L2DatabaseFactory.getInstance().getConnection(con); PreparedStatement statement = con.prepareStatement( "UPDATE grandboss_intervallist SET respawnDate = ?,state = ? WHERE bossId = ?"); statement.setLong(1, _respawnDate); statement.setInt(2, _state.ordinal()); statement.setInt(3, _bossId); statement.execute(); statement.close(); _log.info("update GrandBossState : ID-" + _bossId + ",RespawnDate-" + _respawnDate + ",State-" + _state.toString()); } catch (Exception e) { _log.warn("Exeption on update GrandBossState : ID-" + _bossId + ",RespawnDate-" + _respawnDate + ",State-" + _state.toString(), e); } finally { L2DatabaseFactory.close(con); } }
From source file:edu.umd.cs.psl.database.rdbms.RDBMSDataStoreMetadata.java
public Map<String, String> getAllValuesByType(String mdTableName, String space, String type) { Map<String, String> vals = null; try {//from ww w. j a va 2 s . c o m PreparedStatement stmt = conn.prepareStatement( "SELECT (key,value) from " + mdTableName + " WHERE namespace = ? AND keytype = ?"); stmt.setString(1, space); stmt.setString(2, type); stmt.execute(); ResultSet rs = stmt.getResultSet(); vals = new HashMap<String, String>(); while (rs.next()) { vals.put(rs.getString(1), rs.getString(2)); } } catch (Exception e) { log.error("Error getting all values for type " + type + e.getMessage()); } return vals; }
From source file:pl.edu.agh.iosr.lsf.dao.DatabaseHelper.java
public void monitorTag(String tag) throws SQLException { try (Connection c = source.getConnection()) { PreparedStatement ps = c.prepareStatement(statementStore.get("U_TAGS")); ps.setString(1, tag);/* w w w.ja v a2 s . c o m*/ ps.execute(); } }
From source file:pl.edu.agh.iosr.lsf.dao.DatabaseHelper.java
public void monitorUser(String user) throws SQLException { try (Connection c = source.getConnection()) { PreparedStatement ps = c.prepareStatement(statementStore.get("U_USERS")); ps.setString(1, user);/*from w w w . j av a 2s . c o m*/ ps.execute(); } }
From source file:com.l2jfree.gameserver.instancemanager.InstanceManager.java
public void deleteInstanceTime(int playerObjId, int id) { Connection con = null;//from w w w.ja v a2s. co m try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = null; statement = con.prepareStatement(DELETE_INSTANCE_TIME); statement.setInt(1, playerObjId); statement.setInt(2, id); statement.execute(); statement.close(); _playerInstanceTimes.get(playerObjId).remove(id); } catch (Exception e) { _log.warn("Could not delete character instance time data: ", e); } finally { L2DatabaseFactory.close(con); } }
From source file:test.Test_User.java
public void ttx() throws SQLException { BigDecimal db = new BigDecimal("15.465482652446425"); PreparedStatement ps = cpds.getConnection() .prepareStatement("insert into fc_transaction(id_account_, amount)" + "values(5, ?)"); ps.setBigDecimal(1, db);// www.java 2 s . c o m ps.execute(); // ResultSet rs = }