web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

connecting to a MS Dynamics NAV database via jdbc

(0) ShareShare
ReportReport
Posted on by

hi,

i am trying to connect to a database that MS Dynamics NAV uses via jdbc. i followed the advice Jonathan gave me yesterday but i am getting an error when i run my code. i will paste the error at the bottom of this question. if i ping the host computers, it replies exectly the way it is supposed to.

also i was thinking  first to bring the database to MySQL Workbench 5.2 CE so that i can see its structure. please assist me with steps and configurations that are necessary to complete this.

 

this is the error that i got when i run my code in netbeans.

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.ConnectException
MESSAGE: Connection refused: connect

STACKTRACE:

java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.<init>(Socket.java:425)
    at java.net.Socket.<init>(Socket.java:241)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at testConnection.main(testConnection.java:44)


** END NESTED EXCEPTION **



Last packet sent to the server was 3 ms ago.
BUILD SUCCESSFUL (total time: 5 seconds)

*This post is locked for comments

I have the same question (0)
  • Verified answer
    keoma Profile Picture
    32,729 on at

    hi,

    what credentials do you use? that user (in the connectionstring) needs at least the sql right datareader for the target database.

    for building the jdbc connectionstring follow:

    http://msdn.microsoft.com/en-us/library/ms378428(v=sql.105).aspx

    http://msdn.microsoft.com/en-us/library/ms378956(v=sql.105).aspx

    if you are looking for a free sql management tool for sql server follow:

    http://www.heidisql.com/

    http://www.sqlmanager.net/en/products/mssql/manager

    also have a look at:

    http://www.microsoft.com/en-US/download/details.aspx?id=7593

  • Community Member Profile Picture
    on at

    hi Jonathan,

    this is how i created my connection.

    Class.forName("com.mysql.jdbc.Driver");

           con=DriverManager.getConnection("jdbc:mysql://10.0.0.19:7048/ databasename", "username", "password");

           System.out.println("connection successfull.");

           con.close();

    when connection is successful, the program should print "connection successful".

  • Suggested answer
    keoma Profile Picture
    32,729 on at

    did you check the sql rights for username in the sql server database?

    you are using the jdbc driver for mysql. that will not work with the sql server.

    you should write following:

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

    con=DriverManager.getConnection("jdbc:sqlserver://10.0.0.19:1433;databaseName=Cronus;username=xxx;password=yyy");

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    Did you try to login to DB with the provided credentials? Try that and see, if you have the proper access to the DB and then try to view data.

    If you do not have the access then you need to give proper access rights.

  • Community Member Profile Picture
    on at

    i have access to the database through NAV classic. do i use the credentials that i use to post to the database through Navision to login to the database?

  • Verified answer
    keoma Profile Picture
    32,729 on at

    yes, you can use them.

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    Yes. Those are the same credentials that you should use to log to NAV database.

    In classic version you can have two type of credentials.

    1. Database logins

    2. Windows logins.

    And it is a must to have these logins created in the SQL and mapped with NAV database.

    Since you have access to the NAV db that means those logins are been created and mapped to NAV and you can use them as your credentials to access the DB.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans