1
2
3
4
5
6
7
8
9
10
11 package it.imolinfo.jbi4cics.connection.jdbc.util;
12
13 import java.sql.SQLException;
14 import java.sql.Statement;
15
16
17
18
19
20 class PreparedStatementInvocationHandler extends StatementInvocationHandler {
21
22 protected String sql;
23 protected int autoGeneratedKeys=-1;
24 protected int[] columnIndexes;
25 protected String[] columnNames;
26
27
28
29
30 public PreparedStatementInvocationHandler(String sql) {
31 super();
32 this.sql=sql;
33 }
34
35
36
37
38
39 public PreparedStatementInvocationHandler(String sql, int autoGeneratedKeys) {
40 super();
41 this.sql=sql;
42 this.autoGeneratedKeys=autoGeneratedKeys;
43 }
44
45
46
47
48
49 public PreparedStatementInvocationHandler(String sql, int[] columnIndexes) {
50 super();
51 this.sql=sql;
52 this.columnIndexes=columnIndexes;
53 }
54
55
56
57
58
59
60 public PreparedStatementInvocationHandler(String sql, int resultSetType, int resultSetConcurrency) {
61 super(resultSetType, resultSetConcurrency);
62 this.sql=sql;
63 }
64
65
66
67
68
69
70
71 public PreparedStatementInvocationHandler(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) {
72 super(resultSetType, resultSetConcurrency, resultSetHoldability);
73 this.sql=sql;
74 }
75
76
77
78
79
80 public PreparedStatementInvocationHandler(String sql, String[] columnNames) {
81 super();
82 this.sql=sql;
83 this.columnNames=columnNames;
84 }
85
86
87
88
89
90
91 protected Statement createStatement() throws SQLException {
92 if (columnNames!=null){
93 return getConnection().prepareStatement(sql,columnNames);
94 }
95 if (columnIndexes!=null){
96 return getConnection().prepareStatement(sql,columnIndexes);
97 }
98 if (autoGeneratedKeys!=-1){
99 return getConnection().prepareStatement(sql,autoGeneratedKeys);
100 }
101 return getConnection().prepareStatement(sql,resultSetType,resultSetConcurrency,resultSetHoldability);
102 }
103
104 }