1 /*
2 * SymmetricDS is an open source database synchronization solution.
3 *
4 * Copyright (C) Eric Long <erilong@users.sourceforge.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
21 package org.jumpmind.symmetric.util;
22
23 import java.sql.Connection;
24 import java.sql.PreparedStatement;
25 import java.sql.SQLException;
26
27 import org.springframework.jdbc.core.PreparedStatementCreator;
28
29 public class MaxRowsStatementCreator implements PreparedStatementCreator {
30
31 private String sql;
32
33 private int maxRows;
34
35 public MaxRowsStatementCreator(String sql, int maxRows) {
36 this.sql = sql;
37 this.maxRows = maxRows;
38 }
39
40 public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {
41 PreparedStatement st = conn.prepareStatement(sql);
42 st.setMaxRows(maxRows);
43 return st;
44 }
45
46 }