-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryResult.java
More file actions
executable file
·94 lines (70 loc) · 1.82 KB
/
QueryResult.java
File metadata and controls
executable file
·94 lines (70 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.iteracja.database;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
public class QueryResult {
private boolean success=true;
private String errorMessage;
private ResultSet result;
private int cursor=-1;
private Statement statement;
private int errorCode;
private SQLException exception;
public boolean isSuccess() {
return success;
}
/**
* Ustawienie rezultatu zapytania
* @param result obiekt z danymi
*/
public void setResult(ResultSet result) {
this.result=result;
}
public ResultSet getResult() {
return result;
}
public void newRecord() {
cursor++;
}
public boolean next() throws SQLException {
return result.next();
}
public String getString(String column) throws SQLException {
return result.getString(column);
}
public Boolean getBoolean(String column) throws SQLException {
return result.getBoolean(column);
}
public int getInt(String column) throws SQLException {
return result.getInt(column);
}
public Long getLong(String column) throws SQLException {
return result.getLong(column);
}
/**
* @author Michał Tomczak
* @return
* @throws SQLException
*/
public HashMap<String, String> toHashMap() throws SQLException {
HashMap<String, String> resultHashMap=new HashMap<String, String>();
ResultSetMetaData columns = result.getMetaData();
for (int i = 1; i <= columns.getColumnCount(); i++) {
resultHashMap.put(columns.getColumnName(i), result.getString(i));
}
return resultHashMap;
}
void setStatement(Statement statement) {
this.statement=statement;
}
public void setException(SQLException e) {
this.exception=e;
this.success=false;
}
public SQLException getException() {
return exception;
}
}