forked from dremella/TickDataStreaming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PremiumDiscount.java
71 lines (58 loc) · 2.47 KB
/
PremiumDiscount.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package acme;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileReader;
import java.net.UnknownHostException;
import org.voltdb.client.ClientConfig;
import org.voltdb.client.ClientResponse;
import org.voltdb.client.ProcedureCallback;
public class PremiumDiscount {
public static void main(String[] args) throws UnknownHostException, IOException {
File file = new File("/opt/poc/main_execute/premiums.csv");
int ch;
StringBuffer strContent = new StringBuffer("");
FileReader fileInSt = null;
String readLine;
ClientConfig clientConfig = new ClientConfig();
org.voltdb.client.Client client = org.voltdb.client.ClientFactory.createClient(clientConfig);
// Client instance connected to the database running on
// the specified IP address, in this case 127.0.0.1. The
// database always runs on TCP/IP port 21212.
client.createConnection("localhost");
try{
FileInputStream fStream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fStream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
fileInSt = new FileReader(file);
int curLineNr = 1;
int skipLines = 1;
while ((readLine = br.readLine()) != null) {
if (curLineNr++ <= skipLines) {
continue;
}
System.out.println("ReadLine "+readLine.length() );
System.out.println("ReadLine "+readLine.toString() );
String[] values = readLine.toString().split(",");
client.callProcedure(new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse clientResponse) throws Exception {
if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
System.err.println(clientResponse.getStatusString());
}
}
},"InsertPremiumDiscount",
values[0].toString(),
values[1].toString()
);
System.out.println(values[0]);
System.out.println(values[1]);
}
}catch(Exception e){
e.printStackTrace();
}
}
}