Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.jdbc / src / main / java / org / gvsig / fmap / dal / store / jdbc2 / spi / operations / ExecuteOperation.java @ 44058

History | View | Annotate | Download (1.08 KB)

1
package org.gvsig.fmap.dal.store.jdbc2.spi.operations;
2

    
3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.sql.Statement;
6
import org.gvsig.fmap.dal.exception.DataException;
7
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
8
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
9

    
10
public class ExecuteOperation extends AbstractConnectionOperation {
11

    
12
    private final String sql;
13
    
14
    public ExecuteOperation(
15
            JDBCHelper helper,
16
            String sql
17
        ) {
18
        super(helper);
19
        this.sql = sql;
20
    }
21

    
22
    @Override
23
    public final Object perform(Connection conn) throws DataException {
24
        this.execute(conn, sql);
25
        return null;
26
    }
27

    
28
    public void execute(
29
            Connection conn,
30
            String sql
31
    ) {
32
        Statement st = null;
33
        try {
34
            st = conn.createStatement();
35
            JDBCUtils.execute(st, sql);
36
        } catch (SQLException ex) {
37
            throw new RuntimeException("Can't execute query ["+sql+"].",ex);
38
            
39
        } finally {
40
            JDBCUtils.closeQuietly(st);
41
        }
42

    
43
    }
44
}