简体   繁体   中英

Connecting to a MySQL db with the anylogic objects

I'm trying to connect to a local MySQL database, with the anylogic object "database".

I'm using the type: "Other Database", and the connection URL: "Server=localhost;Database=anylogicdata;"

but I constantly get a RuntimeException saying: "not suitable driver found" The help file says that you have to install the driver, but i don't know which or if it is my connection URL that is the problem.

Does anyone have some pointers to help me along the way?

You need a JDBC driver to be able to connect to a MySQL server from Java (that AnyLogic is based on) and you can find one here . After you have installed the driver you should find it in the list of available JDBC drivers in AnyLogic. The name should be com.mysql.jdbc.Driver if you chose the suggested one.

First you have to download and add the mysql-connector-java-*.jar file to the anylogic-project. Then you have to type com.mysql.jdbc.Driver into the JDBC driver dropdown box. finally the connection string should look something like

jdbc:mysql:[host/db]?:[port]

another thing I found that might be helpfull to others, is that you can get the java connection from the anylogic db object: database.getConnection() this is very usefull if you want to create your own query. eg create a bulk insert instead of the single insert that Anylogic provides.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM