101-Amol 101-Amol - 29 days ago 11
Java Question

Which SqlDriver should be used to log FIX sessions, messages in SQL server database?

I have an java application in which I need to store logging data such as sessions ,messages and event logs in SQL server database. I am refering SQLjdbc4.jar for database connectivity using com.microsoft.sqlserver.jdbc.SQLServerDriver. Along with this I also used all supporting jars (e.g. proxool.jar, com.springsource.org.logicalcobwebs.cglib.core-0.9.1.jar).
Still I am unable to connect and log data into database.
Is their any bugs in code or jars used?

Exception is as follows :



INFO: [FIX.4.4:FIXCLIENT->FIXSERVER] daily, 00:00:00-UTC - 00:00:00-UTC
INFO FXClient - Error in login : error during session initialization
quickfix.ConfigError: error during session initialization
at quickfix.mina.initiator.AbstractSocketInitiator.createSessions

(AbstractSocketInitiator.java:169)
at quickfix.mina.initiator.AbstractSocketInitiator.createSessionInitiators

(AbstractSocketInitiator.java:84)
at quickfix.SocketInitiator.initialize(SocketInitiator.java:86)
at quickfix.SocketInitiator.start(SocketInitiator.java:64)
at client.FXClient.login(FXClient.java:137)
at client.FXClient.startClient(FXClient.java:76)
at client.FXClient.main(FXClient.java:59)
Caused by: quickfix.RuntimeError: com.microsoft.sqlserver.jdbc.SQLServerException: The connection to

the host ABC, named instance XYZ_2008 has failed. Error: "java.net.SocketTimeoutException:

Receive timed out". Verify the server and instance names, check that no firewall is blocking UDP

traffic to port 1434, and for SQL Server 2005 or later verify that the SQL Server Browser Service is

running on the host.





Normal database connectivity is working fine with same SQl server.

Answer Source

This problem is of quickFixJ JDBC logging. I have solved this issue using SQl data source. I have set SQL data source object as JDBCStoreFactory and JDBCLogFactory datasource. QuickFIXJ provides all necessary utilities. Please find below code snippet for the same.

 JdbcStoreFactory objJSF = new JdbcStoreFactory(settings);
            JdbcLogFactory objJLF = new JdbcLogFactory(settings);
            SQLServerDataSource ds = new SQLServerDataSource();
            ds.setServerName(<SERVER_NAME);
            ds.setDatabaseName(<quickfix_database_name>);
            ds.setInstanceName(<INSTANCE_NAME>);               
          ds.setIntegratedSecurity(AUTHMODE.toUpperCase().contains("WINDOW") ? true : false);
            objJSF.setDataSource(ds);
            objJLF.setDataSource(ds);
            storeFactory = objJSF;
            logFactory = objJLF;
        MessageFactory messageFactory = new MessageFactory();
        initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);