1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jdbc;
12
13 import java.sql.Connection;
14 import java.sql.PreparedStatement;
15 import java.sql.SQLException;
16
17 import javax.sql.DataSource;
18
19 import org.apache.commons.dbutils.QueryRunner;
20
21
22
23
24
25
26 public class ExtendedQueryRunner extends QueryRunner
27 {
28 private int queryTimeout;
29
30 public ExtendedQueryRunner(DataSource ds, int queryTimeout)
31 {
32 super (ds);
33 this.queryTimeout = queryTimeout;
34 }
35
36 @Override
37 protected PreparedStatement prepareStatement(Connection conn, String sql) throws SQLException
38 {
39 PreparedStatement statement = super.prepareStatement(conn, sql);
40 if (this.queryTimeout >= 0)
41 {
42 statement.setQueryTimeout(this.queryTimeout);
43 }
44 return statement;
45 }
46
47 public int getQueryTimeout()
48 {
49 return this.queryTimeout;
50 }
51 }