-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientApp.java
More file actions
34 lines (28 loc) · 1.05 KB
/
Copy pathClientApp.java
File metadata and controls
34 lines (28 loc) · 1.05 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
package example.client;
import com.reforms.orm.OrmDao;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
public class ClientApp {
public void doWorkWithClients() throws SQLException {
try (Connection connection = resolveConnection()) {
IClientDao cliensDao = OrmDao.createDao(connection, IClientDao.class);
List<Client> clients = cliensDao.loadAllClients();
clients.forEach(System.out::println);
}
}
public void saveClient(long id, String name, ClientState state) throws SQLException {
Client newClient = new Client();
newClient.setId(id);
newClient.setName(name);
newClient.setState(state);
try (Connection connection = resolveConnection()) {
IClientDao cliensDao = OrmDao.createDao(connection, IClientDao.class);
cliensDao.saveClient(newClient);
}
}
private Connection resolveConnection() {
// code here to resolving your connection or connection holder
return null;
}
}