B4J Question [SOLVED] Jrdc2 example error

Discussion in 'B4J Questions' started by makis_best, Jun 19, 2019.

  1. makis_best

    makis_best Active Member Licensed User


    I try to make a connection with one MSSql Server
    The Server run on a local network and I try to connect using my client computer.
    When I run the Jrdc example I get the error
    Waiting for debugger to connect...
    Program started.
    2019-06-19 11:30:46.802:INFO::main: Logging initialized @597ms to org.eclipse.jetty.util.log.StdErrLog
    192019 11:30:46 Ξ Ξœ com.mchange.v2.log.MLog
    INFO: MLog clients using java 
    1.4+ standard logging.
    192019 11:30:47 Ξ Ξœ com.mchange.v2.c3p0.C3P0Registry
    INFO: Initializing c3p0- [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
    2019-06-19 11:30:47.619:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_172-b11
    2019-06-19 11:30:47.673:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
    2019-06-19 11:30:47.673:INFO:oejs.session:main: No SessionScavenger set, using defaults
    2019-06-19 11:30:47.677:INFO:oejs.session:main: node0 Scavenging every 660000ms
    2019-06-19 11:30:47.684:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@e720b71{/,file:///C:/Users/malagrakism.LOGIOS/Desktop/jRDC2/jRDC/Objects/www,AVAILABLE}
    2019-06-19 11:30:47.690:INFO:oejs.AbstractNCSARequestLog:main: Opened C:\Users\malagrakism.LOGIOS\Desktop\jRDC2\jRDC\Objects\logs\b4j-2019_06_19.request.log
    2019-06-19 11:30:47.714:INFO:oejs.AbstractConnector:main: Started ServerConnector@2a70a3d8{HTTP/1.1,[http/1.1]}{}
    2019-06-19 11:30:47.714:INFO:oejs.Server:main: Started @1511ms
    Emulated network latency: 100ms
    jRDC is running (version = 2.22)
    My jrdc example is modified like this
    'Non-UI application (console / server application)
    #Region  Project Attributes
    #MergeLibraries: True
    #End Region

    'change based on the jdbc jar file
    '#AdditionalJar: mysql-connector-java-5.1.27-bin
    '#AdditionalJar: postgresql-9.4.1207
    #AdditionalJar: sqljdbc42.jar

    Sub Process_Globals
    Public srvr As Server
    Public rdcConnector1 As RDCConnector
    Public const VERSION As Float = 2.22
    Type DBCommand (Name As String, Parameters() As Object)
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
    End Sub

    Sub AppStart (Args() As String)
        srvr.Port = rdcConnector1.serverPort
    Log($"jRDC is running (version = $1.2{VERSION})"$)
    End Sub
    And my config.properties is like
    #Java server port
  2. jimmyF

    jimmyF Active Member Licensed User

    Unless I am totally blind, I don't see an error.
    It appears to be running.
    What is NOT happening?
  3. makis_best

    makis_best Active Member Licensed User

    Sorry I forget to post the error... The service run But I can't connect on the database
  4. jimmyF

    jimmyF Active Member Licensed User

    What is the ip address of "server" where your sqlserver is running?
  5. makis_best

    makis_best Active Member Licensed User
    I try inserting it but I get the same result
  6. jimmyF

    jimmyF Active Member Licensed User

    Does your sqlserver allow remote access?
  7. makis_best

    makis_best Active Member Licensed User

    Yes... sqlserver allow remote access... 100%
  8. OliverA

    OliverA Expert Licensed User

    The jRDC2 logging on the console should give you more information. The underlying JDBC connection pooling used (3CP0) should spit out an error message that can help in further diagnosing this issue (if necessary, run the jRDC2 server in debug mode).
    José J. Aguilar and Erel like this.
  9. makis_best

    makis_best Active Member Licensed User

    @OliverA I am confuse with your post....
    I need a bit more explanation
  10. OliverA

    OliverA Expert Licensed User

    Open up your jRDC2 source code via the B4J IDE and run the code in Debug Mode. Your initial log entries in the Logs tab will be as you show in your first post
    Then on the same machine that your are the B4J IDE and the jRDC2 server, use a browser and go to
    Switch back to the B4J IDE and you should see an entry similar to this
    After this entry above, if any errors occur, you'll receive various Exception erros.

    For incorrect IP/Hostname and/or port number you should get a CommunicationsException error. In my case (using mysql driver) it is
    If the password or the user is wrong, you should get a java.sql.SQLException: Access denied for user error message.

    If you database name is wrong, you should get an Unknown database error message from your JDBC driver. For the mysql driver it looks something like this:
    If your JDBC URL portion that pertains to the driver is wrong (in your case jdbc:jtds:sqlserver:) then you should be getting a java.sql.SQLException: No suitable driver error message

    Please note, out of the box, the only config.properties file that jRDC2 server will use is located in the Files directory under the Objects directory. When you make any changes to that file, you have to recompile the jRDC2 server to recognize any changes to that file.
    José J. Aguilar, Erel and jimmyF like this.
  11. makis_best

    makis_best Active Member Licensed User

    Thnx for the explanation...

    When I do as you say I get the error

  12. keirS

    keirS Well-Known Member Licensed User

    I wouldn't recommend using the JTDS driver as it was last updated in 2013. I would use the official Microsoft driver.Forget JRDC2 for the minute and just try a JSQL connection. For this to work I am assuming you have enabled TCP /IP in SQL Server Configuration Manager and that the SQL Server Authentication is set to SQL Server and Windows Authentication mode.

    #Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
    #AdditionalJar: mssql-jdbc-7.2.2.jre11.jar
    #End Region
    Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Public MSSQLConnection As SQL
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)

    End Sub
    For the connection string:
    MYSERVER is the fully qualified name of the server you want to connect to.
    MYSQLSERVER:56860 is the name and port of the SQL server where the database is located (you can run multiple instance of SQL Server on the same server)
    MYDB is the name of the database you want to connect to.
    OliverA likes this.
  13. OliverA

    OliverA Expert Licensed User

    This is not the correct .jar file for jTDS. That' is why you are getting
    messages. The latest version should be a jtds-1.3.1.jar file. The file you are including is the JDBC driver from Microsoft, albeit a really old one. You should ignore both and go with @keirS's recommendation and use the latest Microsoft drivers (he provides a link). Please note that you may have two version included in each download. For example, if you go with the latest 7.2 branch (recommended), you'll get a mssql-jdbc-7.2.2.jre8.jar, used with JDK8/JRE8and a mssql-jdbc-7.2.2.jre11.jar, used with JDK10/JRE10 and up (notice no JDK9/JRE9 support).
    jimmyF, keirS and José J. Aguilar like this.
  14. makis_best

    makis_best Active Member Licensed User

    @OliverA thank you... I make the changes and everything working just fine.
    I finally get at browser
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice