Project

General

Profile

« Previous | Next » 

Revision 48012

Added by Tsampikos Livisianos almost 7 years ago

prepared statements for the sql queries

View differences:

SqlStore.java
176 176
	 * @return
177 177
	 * @throws SQLException
178 178
	 */
179
	public ResultSet executeQuery(String command, ArrayList<String> values) throws SQLException, SQLStoreException {
179
	public ResultSet executeQuery(String command, ArrayList<Object> values) throws SQLException, SQLStoreException {
180 180
		log.debug("  Executing   Query ..." + command);
181 181

  
182 182
			PreparedStatement st = connection.prepareStatement(command);
183 183

  
184 184
			int pos = 1;
185 185

  
186
			for (String v : values) {
186
			for (Object v : values) {
187 187

  
188 188
				st.setObject(pos, v);
189 189

  
......
240 240
	 * @throws Exception
241 241
	 * @values as parameters
242 242
	 */
243
	public void executeUpdate(String command, ArrayList<String> values) throws SQLException {
243
	public boolean executeUpdate(String command, ArrayList<Object> values) throws SQLException {
244 244
		log.debug("  Executing   Query ..." + command);
245 245
			PreparedStatement st = connection.prepareStatement(command);
246 246

  
247 247
			int pos = 1;
248 248

  
249
			for (String v : values) {
249
			for (Object v : values) {
250 250

  
251 251
				st.setObject(pos, v);
252 252

  
......
255 255

  
256 256
			boolean executed = st.execute();
257 257

  
258
			if (!executed) {
258
			if (executed) {
259 259
				log.error("Fail to execute update command " + st.getWarnings());
260 260
				throw new SQLException("Fail to execute update command " + st.getWarnings());
261 261
			}
262
			return !executed;
262 263
	}
263 264

  
264 265

  

Also available in: Unified diff