# Tick data to Kdb+ table

**URL:** <https://forum.kx.com/t/tick-data-to-kdb-table/11871>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [February 19, 2019, 4:23am UTC](https://forum.kx.com/t/tick-data-to-kdb-table/11871 "2019-02-19T04:23:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francisco1](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@Francisco1](https://forum.kx.com/u/Francisco1)\
**Post date:** [February 19, 2019, 4:23am UTC](https://forum.kx.com/t/tick-data-to-kdb-table/11871/1 "2019-02-19T04:23:00Z")

</div>

Hello,

I’m trying to get live tick data from jforex trading platform in a a Kdb+ table.

In&nbsp;https://www.dukascopy.com/wiki/en/development/strategy-api/practices/write-ticks-in-mysql there is an example using MySql:

```
package jforex;import com.dukascopy.api.*;import java.util.*;import java.sql.*;import javax.sql.*;import org.apache.commons.dbcp.*;/** * commons-pool can be downloaded here - http://commons.apache.org/pool/ * commons-dbcp can be downloaded here - http://commons.apache.org/dbcp/ * mysql java connection can be downloaded here - http://dev.mysql.com/downloads/connector/j/5.1.html */@RequiresFullAccess@Library("c:/fullpathtolib/commons-pool-1.4.jar;c:/fullpathtolib/commons-dbcp-1.2.2.jar;c:/fullpathtolib/mysql-connector-java-5.1.7-bin.jar")public class TestMySQLAccess implements IStrategy { private IContext context; private IConsole console; private DataSource dataSource; private Calendar gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); public void onStart(IContext context) throws JFException { this.context = context; console = context.getConsole(); try { Properties properties = new Properties(); properties.put("driverClassName", "com.mysql.jdbc.Driver"); properties.put("url", "jdbc:mysql://localhost/test"); properties.put("username", "test"); properties.put("password", "test"); properties.put("poolPreparedStatements", "true"); dataSource = BasicDataSourceFactory.createDataSource(properties); } catch (Exception e) { console.getErr().println(e); } } public void onAccount(IAccount account) throws JFException { } public void onMessage(IMessage message) throws JFException { } public void onStop() throws JFException { try { ((BasicDataSource) dataSource).close(); } catch (SQLException e) { console.getErr().println(e); } } public void onTick(Instrument instrument, ITick tick) throws JFException { try { Connection connection = dataSource.getConnection(); try { PreparedStatement statement = connection.prepareStatement("insert into ticks(instrument, tick_time, ask, bid, askVol, bidVol) values (?, ?, ?, ?, ?, ?)"); try { statement.setString(1, instrument.toString()); statement.setTimestamp(2, new Timestamp(tick.getTime()), gmtCalendar); statement.setDouble(3, tick.getAsk()); statement.setDouble(4, tick.getBid()); statement.setDouble(5, tick.getAskVolume()); statement.setDouble(6, tick.getBidVolume()); statement.execute(); } finally { statement.close(); } } finally { connection.close(); } } catch (SQLException e) { console.getErr().println(e); } } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { }}
  

<font style='""' size='"2"' face='"arial,' sans-serif>I think this code can be easily modified to use a Kdb+ table instead of MySql by a java programmer (that I'm not).</font>

<font style='""' size='"2"' face='"arial,' sans-serif>Please can you help me?</font>

  

<font face='"arial,' sans-serif size='"2"'>Cheers</font>

<font face='"arial,' sans-serif size='"2"'>Francisco</font>

```

---

<div class="post-metadata">

**Author:** ![Francisco1](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@Francisco1](https://forum.kx.com/u/Francisco1)\
**Post date:** [February 24, 2019, 6:05am UTC](https://forum.kx.com/t/tick-data-to-kdb-table/11871/2 "2019-02-24T06:05:00Z")

</div>

If somebody wants to send me a quotation for this task please reply privately. Thanks.

![]()

---

<div class="post-metadata">

**Author:** ![Flying1](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Flying1](https://forum.kx.com/u/Flying1)\
**Post date:** [February 27, 2019, 8:35am UTC](https://forum.kx.com/t/tick-data-to-kdb-table/11871/3 "2019-02-27T08:35:00Z")

</div>

You need to read this:&nbsp;[https://code.kx.com/q/interfaces/java-client-for-q/](https://code.kx.com/q/interfaces/java-client-for-q/)

---

<div class="post-metadata">

**Author:** ![Francisco1](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@Francisco1](https://forum.kx.com/u/Francisco1)\
**Post date:** [March 13, 2019, 3:56am UTC](https://forum.kx.com/t/tick-data-to-kdb-table/11871/4 "2019-03-13T03:56:00Z")

</div>

Thanks for your help!
