Results 1 to 9 of 9
  1. #1

    HelloWorld JDBC Data Adapter

    Hello,

    I have tested the Hello World Demo on my local server and that is working as expected.

    However, I am encountering problems when attempting to connect to MySQL using the modified HelloWorldDataAdapter posted in this thread :

    http://forums.lightstreamer.com/show...a-Adapter-Java


    The following errors were logged:

    Starting Lightstreamer Server...
    Please check logs for detailed information.
    21.Oct.16 22:51:36,167 < INFO> Lightstreamer Server 5.1.2 build 1623.14
    21.Oct.16 22:51:36,197 < WARN> Lightstreamer is running with a Demo license, which has a limit of 20 concurrent users and can be used for evaluation, development, and testing, but not for production. If you need to evaluate Lightstreamer without this user limit, or need any information on the other license types, please contact info@lightstreamer.com
    21.Oct.16 22:51:36,205 < INFO> Lightstreamer Server starting in Vivace edition.
    21.Oct.16 22:51:36,417 < INFO> Started RMI server for JMX on port 8888.
    21.Oct.16 22:51:36,467 < INFO> Bound RMI Connector for JMX on port 8888 (communication on port 8888).
    21.Oct.16 22:51:36,491 < INFO> Bound RMI Connector for Platform mbeans on port 8888 (communication on port 8888).
    21.Oct.16 22:51:36,494 < INFO> SERVER pool size set by default at 10.
    21.Oct.16 22:51:36,522 < INFO> data_provider element without name attribute; using DEFAULT as the default name.
    21.Oct.16 22:51:36,524 < INFO> Loading Metadata Adapter HELLOWORLD
    21.Oct.16 22:51:36,524 < INFO> Loading Data Adapter HELLOWORLD.DEFAULT
    21.Oct.16 22:51:36,527 < INFO> Finished loading Metadata Adapter HELLOWORLD
    21.Oct.16 22:51:36,528
    <ERROR> Data Adapter HELLOWORLD.DEFAULT init error: java.lang.ClassNotFoundException: HelloWorldDataAdapter
    21.Oct.16 22:51:36,528
    <ERROR>Error while loading the Adapters: java.lang.ClassNotFoundException: HelloWorldDataAdapter
    21.Oct.16 22:51:36,528
    <ERROR> Error while loading the Adapters: HelloWorldDataAdapter.
    21.Oct.16 22:51:36,528
    <FATAL> Adapters initialization failed.

    The following are the browser console errors:

    http://localhost:8080/lightstreamer/create_session.js?LS_phase=8503&LS_caus…client_ver sion=6.1&LS_adapter_set=HELLOWORLD&LS_force_head=t rue&LS_eng=s0& Failed to load resource: net::ERR_CONNECTION_REFUSED

    I have also tried without success the following:


    • Copied file and set CLASSPATH in the system environment variables to "C:\Program Files (x86)\Java\jdk1.7.0_79\jre\lib\ext\mysql-connector-java-5.1.40-bin.jar"
    • Copied files and set CLASSPATH to \adapters\HelloWorld\lib\mysql-connector-java-5.1.40-bin.jar; and \shared\lib folders\mysql-connector-java-5.1.40-bin.jar;


    The source file "HelloWorldDataAdapter.java" would not compile until I placed the "mysql-connector-java-5.1.40-bin.jar" file into the "C:\Program Files (x86)\Java\jdk1.7.0_79\jre\lib\ext" directory.

    The test database name, table name and associated fields have been configured to match the example Adapter code, so coding errors can be excluded.

    Any assistance would be much appreciated.

    Thank you

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi longtrain0,

    It seems that the HelloWorldDataAdapter class is not defined in the classpath of your adapter. Please could you check inside the <LS_HOME>/adapters/HelloWorld folder (if you have not changed the name) if properly it contains the jar or the individual classes produced by your build?

    Thank you,
    Giuseppe

  3. #3
    Hello Giuseppe,

    Thanks once again for your prompt response.

    The two newly generated class files "HelloWorldDataAdapter$GreetingsThread.class" and "HelloWorldDataAdapter.class" are in the <LS_home>/tmp_classes/HelloWorld folder.

    The new JDBC adapter source file, "HelloWorldDataAdapter.java",using the same name as the previous Demo file, is in the <LS_home>/src folder.
    After being compiled it was then used to overwrite the previous "HelloWorldDataAdapter.jar" Demo file in the <LS_home>/adapters/HelloWorld/lib folder.

    There are no *.class files in the <LS_home>/adapters/HelloWorld/lib folder, just the single "HelloWorldDataAdapter.jar" file.

    I did not change any file or folder names in the process so spelling errors can be ruled out.

    When I revert to the original Demo source file using the above method there are no issues with the class definition.

    Your help is appreciated.

    best regards.
    Last edited by longtrain0; October 31st, 2016 at 06:59 AM.

  4. #4
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi longtrain0,

    Please note that the modified HelloWorldDataAdapter source include the package declaration

    Code:
    	package HelloWorldDataAdapter;
    which is not expected in the standard deployment of HelloWorld example. Please check this line of adapters.xml:

    HTML Code:
    	<adapter_class>HelloWorldDataAdapter</adapter_class>
    with package declaration should be:

    HTML Code:
    	<adapter_class>HelloWorldDataAdapter.HelloWorldDataAdapter</adapter_class>
    I am sorry whether this mismatch could lead to confusion.

    Regards,
    Giuseppe

  5. #5
    Hello Giuseppe,

    Once again you have promptly come to the rescue!!!
    The modified adapter is now working exactly as expected.
    Thank you my friend, very much appreciated.

    best regards,
    longtrain0

  6. #6
    Hello Guiseppe,

    Just a further note on this topic, I have had this JDBC demo on test and after running successfully for a few hours, an OutOfMemory error shuts down the LS server.

    For this test I have only one record containing 70 fields in the MySQL database.

    Could you please provide advice on how to resolve this issue.

    Many thanks in advance.

    regards,

    longtrain0
    Last edited by longtrain0; October 31st, 2016 at 02:52 AM.

  7. #7
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi longtrain0,

    About the Adapter code proposed, it should be intended as very basic POC and in real scenario usage it should be heavily developed.
    That said, after a quick review of the code, maybe you could add the release of the RecordSet and PreparedStatement in each cycle.
    Then if the issue persist, you should use a profiler to understand where it is actually occupied the memory.

    Regards,
    Giuseppe

  8. #8
    Hello Giuseppe,

    Thank you again for the rapid response and helpful advice.

    As for the original code, it was exactly what I was looking for i.e. a solution that didn't require further development because I am still learning Java.

    Would your code suggestion look something like this?

    finally {
    try { if (rs != null) rs.close(); } catch (Exception e) {};
    try { if (stmt != null) stmt.close(); } catch (Exception e) {};
    try { if (conn != null) conn.close(); } catch (Exception e) {};
    }

    best regards,

    longtrain0

  9. #9
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi longtrain0,

    Yes exactly, I meant something like that.

    Regards,
    Giuseppe

 

 

Similar Threads

  1. JDBC Data Adapter [Java]
    By Alessandro in forum Adapter SDKs
    Replies: 12
    Last Post: May 22nd, 2023, 02:42 PM
  2. JDBC Integrated Security Authentication DLL
    By zschmidt in forum Adapter SDKs
    Replies: 2
    Last Post: April 30th, 2014, 05:14 PM
  3. Issue with HelloWorld
    By irazabal.alex@gmail.com in forum Client SDKs
    Replies: 1
    Last Post: March 31st, 2010, 11:06 AM
  4. HELLOWORLD.DEFAULT init error
    By amoroso@forex.co.ke in forum Adapter SDKs
    Replies: 3
    Last Post: February 1st, 2010, 12:01 PM
  5. error jdbc Orcale
    By khalil78 in forum Adapter SDKs
    Replies: 2
    Last Post: April 22nd, 2008, 12:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 07:29 PM.