Skrypt do sczytywania danych giełdowych

0

Witam serdecznie. Nie jestem programistą więc zwracam się do was o pomoc.Mam skrypt sczytywania zleceń giełdowych przy użyciu klawiatury lecz nie mogę go skompilować.Napisany jest on raczej dobrze bo znalazłem go na stronie brokera giełdowego. Przy kompilacji wyskakują mi takie błędy:

0728 The type Properties is ambiguous
0728 ^^^^^^^^^^
0728 Properties properties = new Properties();
0728 2. ERROR in C:\DOCUME1\MISTRZ1\USTAWI1\Temp\jfxide\tmp\TestMySQLAccess.java (at line 28)
0728 ----------
0728 The type Properties is ambiguous
0728 ^^^^^^^^^^
0728 Properties properties = new Properties();
0728 1. ERROR in C:\DOCUME
1\MISTRZ1\USTAWI1\Temp\jfxide\tmp\TestMySQLAccess.java (at line 28)

Wcześniej wyskakiwały mi inne błędy typu:
0736 File c:\fullpathtolib\commons-pool-1.4.jar not found.
0722 File c:\fullpathtolib\commons-dbcp-1.2.2.jar not found.
0740 File c:\fullpathtolib\mysql-connector-java-5.1.7-bin.jar not found.

Ale rozwiązalem je jak typowy amator programowania. Czyli założyłem ten folder na dysku C i pościągałem dane pliki z google ;-P i chyba tutaj jest pies pogrzebany.

Poniżej zamieszczam cały skrypt:
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//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 {
    }
    }

Dzięki za pomoc

Pozdrawiam.

0

Spróbuj zmienić wiersz

 Properties properties = new Properties();

na

 java.util.Properties properties = new java.util.Properties();
0

bo dzięki skomilowało się tylko teraz jak odpaliłem ten skrypt cały czas w raportach wywala mi kolejny błąd:

0853 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
0853 org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

o co tutaj chodzi??

1 użytkowników online, w tym zalogowanych: 0, gości: 1