• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Streaming data records

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Streaming data records

    Please advise right code to put in Java Listener class to send all incoming steaming quotes to MySQL database.
    When I put :
    conn.insert(sql);
    sql = "INSERT INTO MarketData (`No`, `Symbol`, `BidPx`, `OfferPx`, `TimeStamp`) VALUES ('"+ incomingQuote.getQuoteID() + "','" + incomingQuote.getInstrument().getSymbol() + "','" + incomingQuote.getAskOpen() + "','" + incomingQuote.getBidOpen() + "','" + incomingQuote.getOpenTimestamp() + "')";
    Java send to DB only one record for each pair and after stops sending. Means I can see quotes on terminal display but they are not collecting in database.
    When I stop JM and restart I have another one set of quotes.

    #2
    Originally posted by Pumbaa View Post
    Please advise right code to put in Java Listener class to send all incoming steaming quotes to MySQL database.
    When I put :
    conn.insert(sql);
    sql = "INSERT INTO MarketData (`No`, `Symbol`, `BidPx`, `OfferPx`, `TimeStamp`) VALUES ('"+ incomingQuote.getQuoteID() + "','" + incomingQuote.getInstrument().getSymbol() + "','" + incomingQuote.getAskOpen() + "','" + incomingQuote.getBidOpen() + "','" + incomingQuote.getOpenTimestamp() + "')";
    Java send to DB only one record for each pair and after stops sending. Means I can see quotes on terminal display but they are not collecting in database.
    When I stop JM and restart I have another one set of quotes.
    In order for anybody to help you, you will need to provide a lot more information than you have done.

    I don't think you realise how much that snippet of code reveals about the code quality in the system that you are working on. If that is the type of code that you are putting into a production system, I suggest you give up programming now.

    Comment


      #3
      Streaming data

      I'm not in a hurry, so I have time to study, just if you know, give me idea from where to start to search, because in available sources about Java and MySQL I can't find any information about recording of streaming data. I believe that everything very simple and logical, but very important to find proper point of start.

      Comment


        #4
        sounds like you just need an infinite loop with break clauses
        Coffee's for closers

        Comment


          #5
          OK then,

          What methods and events have you got on your IncomingQuotes class?

          Comment


            #6
            PHP Code:
            public class ClientTester {

                private static List 
            accounts = new ArrayList();
                private static 
            String accountMassID;
                private static 
            String openOrderMassID;
                private static 
            String openPositionMassID;
                private static 
            String closedPositionMassID;
                private static 
            String tradingSessionStatusID;
                private static 
            TradingSessionStatus tradingSessionStatus;
                private static 
            boolean printMarketData false;

                public static 
            void main(final String[] args) {
                    
            System.out.println("startctc");
                    
            // step 1: get an instance of IGateway from the GatewayFactory
                    
            final IGateway fxcmGateway GatewayFactory.createGateway();

                    
            /*
                    step 2: register a generic message listener with the gateway, this
                    listener in particular gets all messages that are related to the trading
                    platform MarketDataSnapshot,OrderSingle,ExecutionReport, etc...
                     */
                    
            fxcmGateway.registerGenericMessageListener(new IGenericMessageListener() {

                        public 
            void messageArrived(ITransportable message) {
                            if (
            message instanceof MarketDataSnapshot) {
                                
            MarketDataSnapshot incomingQuote = (MarketDataSnapshotmessage;
                                if (
            printMarketData || incomingQuote.getMDReqID() != null) {
                                    try {

                                        
            ConnectDB conn = new ConnectDB();
                                        
            String sql null;
                                        
            conn.insert(sql);
                                        
            sql "INSERT INTO Sample5 (`QuoteID`, `Symbol`, `BidPx`, `OfferPx`, `TimeStamp`) VALUES ('" incomingQuote.getQuoteID() + "','" incomingQuote.getInstrument().getSymbol() + "','" incomingQuote.getAskOpen() + "','" incomingQuote.getBidOpen() + "','" incomingQuote.getOpenTimestamp() + "')"
            this is standard connection procedure for FXCM streaming server with supplied code and all quotes comes perfect, means we have source of data. I'm only add from ConnectDB conn = new ConnectDB;
            But for me it's crazy that in all books (even in Horstmann & Cornell Core Java Advanced Features) and Internet described only how to work with database, but nowhere how to feed it with streaming data. And only the command which I found to put new data is INSERT. All other only for work with existing data. Sorry for expression, but I'm trying to find solution from Monday.

            Comment


              #7
              Have you worked with SQL databases before?

              Perhaps you should take a look at hibernate or JPA?
              While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'

              Comment


                #8
                No, this is my first experience. But I've already studied most basic commands of MySQL and logic how to use them. Unfortunately all courses oriented for extracting and comparing data, but no one for feeding. But to start any analytical research I have to collect data.

                Comment


                  #9
                  Originally posted by Pumbaa View Post
                  But for me it's crazy that in all books (even in Horstmann & Cornell Core Java Advanced Features) and Internet described only how to work with database, but nowhere how to feed it with streaming data. And only the command which I found to put new data is INSERT. All other only for work with existing data. Sorry for expression, but I'm trying to find solution from Monday.
                  So essentially, you want to insert a row in to a table whenever a message is received and you need a book or the internet for that?

                  There's a painfully obvious error in the code you've pasted in here, I guess you may be losing exceptions because it's probably running in a different thread.

                  Comment


                    #10
                    Originally posted by Jaws View Post
                    So essentially, you want to insert a row in to a table whenever a message is received and you need a book or the internet for that?

                    There's a painfully obvious error in the code you've pasted in here, I guess you may be losing exceptions because it's probably running in a different thread.
                    I think even I have spotted it

                    I know very little about Java.
                    +50 Xeno Geek Points
                    Come back Toolpusher, scotspine, Voodooflux. Pogle
                    As for the rest of you - DILLIGAF

                    Purveyor of fine quality smut since 2005

                    CUK Olympic University Challenge Champions 2010/2012

                    Comment

                    Working...
                    X