Anylogic: Local Database Connection

3.1k views Asked by At

I'm really struggeling here. Anylogic gives me the Database Connection Problem for some days now and the support was not able to help me until now

Screenshot1

What I got here is a windows mashine running the latest Win10 with Anylogic 7.3 Professional

My Anylogic Model is completely local and runs perfect until I try to add an Database Table. As mentioned above Anylogic asks me reconnect the database each time I try to insert a table. Pressing the Connect button does nothing, but showing the same window again. Pressing cancel shows me the following error message:

Screenshot2

Together with the Anylogic Support I already tried to disable the Antivirus, send them logs,etc. Nothing helped so far. I already tried to reinstall the whole program including a thourough clean (all .Anylogic Folders, files,...).

I don't know anymore what else to do at this point. I hope any of you guys can help out a little.

!ENTRY org.eclipse.ui 4 0 2016-12-21 13:48:02.168
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.RuntimeException: java.sql.SQLException: Connection timed out
    at com.anylogic.objectmodel.commands.database.AbstractDatabaseCommand.execute(Unknown Source)
    at com.anylogic.objectmodel.commands.CompoundCommand.execute(Unknown Source)
    at com.anylogic.objectmodel.commands.BasicCommandStack.execute(Unknown Source)
    at com.anylogic.objectmodel.commands.CommandStack.execute(Unknown Source)
    at com.anylogic.properties.widget.WidgetBuilder$86.n(Unknown Source)
    at com.anylogic.properties.widget.WidgetBuilder$86.onAdd(Unknown Source)
    at com.anylogic.properties.widget.base.list.ListWidget.j(Unknown Source)
    at com.anylogic.components.button.ButtonDecorator.a(Unknown Source)
    at com.anylogic.components.button.ButtonDecorator.a(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at com.anylogic.application.AnyLogicApplication.start(Unknown Source)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
Caused by: java.sql.SQLException: Connection timed out
    at com.anylogic.database.DatabaseManager.getConnection(Unknown Source)
    at com.anylogic.database.DatabaseManager.getConnection(Unknown Source)
    at com.anylogic.database.DatabaseManager.a(Unknown Source)
    at com.anylogic.database.DatabaseManager.createColumn(Unknown Source)
    at com.anylogic.database.DatabaseManager.createColumn(Unknown Source)
    at com.anylogic.objectmodel.commands.database.CreateColumnCommand.doExecute(Unknown Source)
    ... 35 more
6

There are 6 answers

0
Patrick Kehrli On

I faced the same problem. I don't know exactly why it occurred, but something with storing the Model went wrong. But I managed to reconnect with the following procedure:

  1. Copy the whole folder of the Project and store it somewhere
  2. In the new folder delete the .original.alp-File
  3. Rename the .alp-File
  4. then open the Renamed .alp-File in an text-editor

In that file you'll find something like that:

*************************************************
          AnyLogic Project File 
*************************************************          
-->
<AnyLogicWorkspace WorkspaceVersion="1.9" AnyLogicVersion="8.5.1.201910011746" AlpVersion="8.4.9">
<Model>
 <Id>1570541727194</Id>
 <Name><![CDATA[20191030-02-SBB-DAT]]></Name>
 <EngineVersion>6</EngineVersion>
 <JavaPackageName><![CDATA[_20191008_02_sbb_dat]]></JavaPackageName>
 <ModelTimeUnit><![CDATA[Minute]]></ModelTimeUnit>
 <ActiveObjectClasses>
  <!--   =========   Active Object Class   ========  -->

Now find all Strings in that file equals to the packageName, in my case:

_20191008_02_sbb_dat

and replace it with the name of your .alp file, in mycase:

sbb_dat.

It should look like this:

<AnyLogicWorkspace WorkspaceVersion="1.9" AnyLogicVersion="8.5.1.201910011746" AlpVersion="8.4.9">
<Model>
 <Id>1570541727194</Id>
 <Name><![CDATA[SBB-DAT]]></Name>
 <EngineVersion>6</EngineVersion>
 <JavaPackageName><![CDATA[sbb_dat]]></JavaPackageName>
 <ModelTimeUnit><![CDATA[Minute]]></ModelTimeUnit>
 <ActiveObjectClasses>
  <!--   =========   Active Object Class   ========  -->

After that store and close the file and open it with AnyLogic. In my case this helped.

1
wizzwizz2 On

Try deleting all Anylogic relevant rules. This should solve the problem.

1
Tatiana Gomzina On

According to the result of listening localhost 9001, something blocked the connection between AnyLogic and Server DB. Deleting all rules defined for Anylogic (though all of them were „permit“) helped.

0
cogijl On

I have also run into this problem. If you go into the database folder of the model and delete the lock file and the previous database folder it will open without throwing that error.

0
juanpablorv On

I just got the same error and solved as follow: (Inspired on @cogijl answer)

  1. Close the model and Anylogic.
  2. Go to the model folder and delete the folder "database".
  3. Open the model. This will generate the error again but with something different: you can now add or delete databases (tables) in the database section.
  4. Delete the database with the option "Delete database" in the Database section.
  5. Add the tables again with the option "Create or Import table..."
  6. Make sure you import the tables using the same names as before, otherwise everything will crash.
  7. Done, the model runs again.

the only thing you will lose, is the Export setting, but it's easy to set them again.

Hope this helps others.

0
postlogist On

When the db connection fails after adding the first table to the model, I’d suggest checking if some application isn’t using the hsqldb port (9001). You could use Sysinternals tcpview to check that. In my case, Nvidia broadcast application took the port and broke db connections in all of my models.

Also, Anylogic db breaks when something is locking the db files. I’d suggest storing the models outside of cloud synced folders, and add antivirus exceptions to exclude the 'Models' folder from background scanning.