QStudio
Query kdb+ Servers and Chart Results.
Examples of querying, subscribing and a java feedhandler are available to download and are detailed below:
The Interfacing kdb with Java page on the code KX website documents the API. Useful snippets include:
Signature | Notes |
---|---|
public c(String host, int port, String usernameAndPassword) throws KException, IOException | Throws a KException if access is denied by the kdb+ server. The username and password should be of the format "username:password" |
public c(String host, int port) throws KException, IOException | Uses the user.name property as the login name and password. It throws a KException if access is denied by the kdb server |
Comm Type | Method | Description |
---|---|---|
Asynchronous | public void ks(String s) throws IOException | Send string query. |
public void ks(Object x) throws IOException | Send K object. | |
Synchronous | public Object k(String s) throws KException, IOException | Send string query, wait and return response. |
public Object k(Object x) throws KException, IOException | Send K object, wait and return response | |
public Object k() throws KException, IOException | Retrieve waiting messages without sending a query. |
See the TableQueryExample.java in the java example code. This is an almost a direct copy from code.kx.com. The steps are:
See the SubscriberExample.java in the java example code. This demonstrates connecting a tickerplant and subscribing to the trade table. The steps are:
Demonstrate creating feedhandler, making it listen to incoming data and forwarding to the kdb server. Before running start a fresh kdb server on port 5000 and enter the below:
Create our feed handler that forwards data to a q process on localhost port 5000 and attach to a fake feed.
Query kdb+ Servers and Chart Results.