@@ -12,20 +12,9 @@ public class EventSender {
1212 private String insertScript ;
1313 private EventHandler eventHandler ;
1414 private DBConnection conn ;
15- private boolean isConnected ;
1615
17- public EventSender (List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) {
16+ public EventSender (DBConnection conn , String tableName , List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) throws IOException {
1817 this .eventHandler = new EventHandler (eventSchemas , eventTimeKeys , commonKeys );
19- this .isConnected = false ;
20- }
21-
22- public void connect (DBConnection conn , String tableName ) throws IOException {
23- if (this .isConnected )
24- throw new RuntimeException ("The eventSender has already been called." );
25-
26- if (!conn .isConnected ())
27- throw new RuntimeException ("The connection to dolphindb has not been established." );
28-
2918 this .conn = conn ;
3019
3120 String sql = "select top 0 * from " + tableName ;
@@ -35,13 +24,9 @@ public void connect(DBConnection conn, String tableName) throws IOException {
3524 throw new RuntimeException (errMsg .toString ());
3625
3726 this .insertScript = "tableInsert{" + tableName + "}" ;
38- this .isConnected = true ;
3927 }
4028
4129 public void sendEvent (String eventType , List <Entity > attributes ) {
42- if (!isConnected )
43- throw new RuntimeException ("This eventSender has not connected to the dolphindb" );
44-
4530 List <Entity > args = new ArrayList <>();
4631 StringBuilder errMsg = new StringBuilder ();
4732
@@ -55,8 +40,4 @@ public void sendEvent(String eventType, List<Entity> attributes) {
5540 }
5641 }
5742
58- public static EventSender createEventSender (List <EventSchema > eventSchemas , List <String > eventTimeKeys , List <String > commonKeys ) {
59- return new EventSender (eventSchemas , eventTimeKeys , commonKeys );
60- }
61-
6243}
0 commit comments