-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathQuery.java
More file actions
69 lines (45 loc) · 1.5 KB
/
Copy pathQuery.java
File metadata and controls
69 lines (45 loc) · 1.5 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
package advancedsql.query;
import advancedsql.ISQL;
import advancedsql.table.ITable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class Query<T extends IQuery> implements IQuery {
protected ISQL sql = null;
protected String table = null;
protected List<Object> execute = new ArrayList<>();
protected PreparedStatement prepare = null;
protected String where = null;
protected int limit = 0;
private T instance;
public Query(ITable table) {
this.sql = table.getSQL();
this.table = table.getName();
}
public Boolean executeStatement() throws SQLException {
prepare = this.sql.prepare(this);
ISQL.setStatementParameters(this.prepare, this.execute);
return prepare.execute();
}
public ResultSet executeQuery() throws SQLException {
prepare = this.sql.prepare(this);
ISQL.setStatementParameters(this.prepare, this.execute);
return prepare.executeQuery();
}
public int executeUpdate() throws SQLException {
prepare = this.sql.prepare(this);
ISQL.setStatementParameters(this.prepare, this.execute);
return prepare.executeUpdate();
}
public abstract String toQuery();
public PreparedStatement getPrepare() {
return prepare;
}
@Override
public String toString() {
return this.toQuery();
}
}