1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.finalist.tools.statementExecutorUtils;
19
20 import java.sql.*;
21 import javax.sql.*;
22 import javax.naming.*;
23
24 import com.finalist.tools.database.StatementExecutor;
25 import com.finalist.tools.database.OracleRowMapper;
26
27 public class QueryHelper extends StatementExecutor {
28
29 /*** Creates a new instance of QueryHelper */
30 public QueryHelper() {
31 super(createConnection(), new OracleRowMapper());
32 }
33
34
35
36 private static Connection createConnection() {
37 Connection con = null;
38 try {
39 con = ConnectionManager.connect();
40 }
41 catch (SQLException q) {
42 System.out.println("SQLException ocurred looking up connection from datasource ");
43 }
44 return con;
45 }
46
47
48 public void close() {
49 try {
50 if (this.conn != null && !this.conn.isClosed()) {
51 conn.close();
52 }
53 }
54 catch (SQLException e) {
55 System.out.println("Error closing the connection");
56 System.out.println("Message :" + e.getMessage());
57 }
58 }
59
60 }