5 Star 6 Fork 0

浙江智臾科技有限公司/api-java

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ThreadedClientDemo.java 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
笨笨 提交于 2023-12-12 15:32 +08:00 . fix bugs of examples code.
package examples;
import com.xxdb.DBConnection;
import com.xxdb.streaming.client.ThreadedClient;
import java.io.IOException;
public class ThreadedClientDemo {
private static DBConnection conn = new DBConnection();
public static String host = "localhost";
public static Integer port = 8848;
public static ThreadedClient client;
public static Integer subscribePort = 8892;
public static void main(String[] args) throws IOException, InterruptedException {
createStreamTable();
ThreadedClient client = new ThreadedClient(subscribePort);
client.subscribe(host, port, "Trades", new MyHandler(), 0);
Thread.sleep(5 * 1000);
//shutdown the client
client.close();
}
public static void createStreamTable() throws IOException {
conn.connect(host, port);
conn.login("admin", "123456", false);
try{
conn.run("dropStreamTable(\"Trades\")");
}catch (Exception e){
System.out.println(e.getMessage());
}
conn.run("share streamTable(30000:0,`id`time`sym`qty`price,[INT,TIMESTAMP,SYMBOL,INT,DOUBLE]) as Trades\n");
conn.run("data=table(1..1000 as id, now()+1..1000 as time, take(`aaa,1000) as sym," +
"rand(100..1000, 1000) as qty,rand(100.0, 1000) as price)");
conn.run("Trades.tableInsert(data)");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dolphindb/api-java.git
git@gitee.com:dolphindb/api-java.git
dolphindb
api-java
api-java
master

搜索帮助