forked from LupusUmbrae/Lunar
/
EnterBaseData.java
52 lines (41 loc) · 1.15 KB
/
EnterBaseData.java
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
package database.threads;
import image.ImageProcess;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import database.DbConnection;
public class EnterBaseData implements Runnable {
private ImageProcess process;
public EnterBaseData(ImageProcess process) {
this.process = process;
}
@Override
public void run() {
try {
String statement = process.statementsPoll();
while (statement == null) {
statement = process.statementsPoll();
}
DbConnection dbConn = new DbConnection();
Connection conn = dbConn.getConnection();
while (true) {
Statement stmt = conn.createStatement();
statement = process.statementsPoll();
if (statement != null && statement.matches("end")) {
break;
} else if (statement != null) {
stmt.execute(statement);
} else {
Thread.sleep(1000);
}
}
System.out.println("Base Data Thread finished");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}