blob: 4618eff4de2fd54b0ec720fda31b511e4941f052 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* Copyright (c) 2009, 2011, 2012 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andre Dietisheim - initial API and implementation
* Eike Stepper - maintenance
*/
package org.eclipse.emf.cdo.common.internal.db;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.text.MessageFormat;
/**
* @author Andre Dietisheim
*/
public abstract class AbstractUpdateStatement extends AbstractDBAccessor
{
public AbstractUpdateStatement()
{
}
public void update(Connection connection) throws Exception
{
PreparedStatement preparedStatement = null;
try
{
preparedStatement = getPreparedStatement(connection);
preparedStatement.executeUpdate();
if (preparedStatement.getUpdateCount() == 0)
{
throw new DBException(MessageFormat.format("No row inserted by statement \"{0}\"", getSQL()));
}
connection.commit();
}
finally
{
DBUtil.close(preparedStatement);
}
}
@Override
protected void setParameters(PreparedStatement preparedStatement) throws Exception
{
}
}
|