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