Dukascopy
 
 
Wiki JStore Search Login

problem with JDBC connect string
 Post subject: problem with JDBC connect string Post rating: 0   New post Posted: Mon 25 Mar, 2013, 18:29 
User avatar

User rating: 0
Joined: Mon 19 Dec, 2011, 21:54
Posts: 8
Location: Czech Republic, Prague
Dear Support,

I encountered a problem while compiling the example "Write ticks in MySQL"
https://www.dukascopy.com/wiki/#Write_ticks_in_MySQL
from your Wiki pages.

Although in Eclipse the JDBC connect string works fine, on JForex platform it produces an error
String literal is not properly closed by a double-quote

properties.put("url", "jdbc:mysql://localhost/myDB");


Could you please advise correct or alternative specification? The problem seems to be // or /.
My JF platform version is 2.24.7 / API 2.7.9.3.

Many thanks in advance.


 
 Post subject: Re: problem with JDBC connect string Post rating: 0   New post Posted: Tue 02 Apr, 2013, 08:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The issue has been registered


 
 Post subject: Re: problem with JDBC connect string Post rating: 0   New post Posted: Wed 03 Apr, 2013, 09:36 
User avatar

User rating: 0
Joined: Mon 19 Dec, 2011, 21:54
Posts: 8
Location: Czech Republic, Prague
Hereby is a set of alternative statements how to connect & write info to MySQL database:

import com.mysql.jdbc.jdbc2.optional.*;
@RequiresFullAccess
@Library("C:\\MySQL\\Connector J 5.1.23\\mysql-connector-java-5.1.23-bin.jar")


OnStart block - opens connection..

        try {
          MysqlDataSource ds = new MysqlDataSource();
          ds.setServerName("localhost");
          ds.setPortNumber(3306);
          ds.setDatabaseName("myticks");
          ds.setUser("root");
          ds.setPassword("*****");
          con = ds.getConnection();
          } catch (Exception e) { console.getErr().println(e); }


OnTick / OnBar methods writes info to database..

      try {
          PreparedStatement ps = con.prepareStatement("INSERT INTO dom (Instrument, Dttm, BidQuote, AskQuote) VALUES (?,?,?,?)");
            try {
               ps.setString(1, myInst.toString());
               ps.setTimestamp(2, new Timestamp(timeStamp), gmtCalendar);
               ps.setDouble(3, myTick.getBid());
               ps.setDouble(4, myTick.getAsk());
               ps.executeUpdate();
            } finally { ps.close(); }
      } catch (Exception e) { console.getErr().println(e); }
     


Hope it helps! :)
Tipota


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com