imit_model / AnyLogic / UsersManual(AnyLogic)
.pdf
AnyLogic V User’s Manual
20.2.2Associating with an ODBC data source
The other way to connect a data source to a database is to associate it with an ODBC data source. This technique uses the so-called ODBC drivers and makes your model independent of the database type and location.
To associate an AnyLogic data source with an ODBC data source, you must have the latter defined in the system. You define ODBC data sources using the ODBC Data Source Administrator tool. You need ODBC installed on your computer; otherwise, this tool is not available.
Each ODBC data source has unique name – a DSN. Note that the name of an AnyLogic data source is not related to DSN.
►To create a new DSN
1.Start ODBC Data Source Administrator located, e.g., under the following windows menu path: Start|Settings|Control Panel|Administrative Tools|Data Sources (ODBC).
2.Activate the User DSN page if you want to create a user DSN. Activate the System DSN page if you want to create a system DSN. A system DSN is visible to all applications started by any user, whereas a user DSN may be accessed only by applications started by the user that created that DSN.
3.Click the Add button.
4.Choose the driver.
5.Click the Finish button.
This opens the dialog box that varies depending on the driver selected. However, some settings are common and they are described below. You can also define options specific for the driver.
6.Type data source name in Data Source Name edit box. Do not enter an existing DSN name; otherwise that data source will be overwritten.
7.Type Description, if necessary.
8.Specify path to the database if it is stored in a file, or choose the database name if it is stored on a server.
© 1992-2004 XJ Technologies http://www.xjtek.com |
407 |
AnyLogic V User’s Manual
Figure 176. Selecting database file
To specify database file, click the Select button and browse for your database file. After closing the dialog boxes you see the newly created DSN in the list:
© 1992-2004 XJ Technologies http://www.xjtek.com |
409 |
AnyLogic V User’s Manual
Figure 178. Associating an AnyLogic data source with an ODBC data source
20.2.3Viewing data source content
You can examine tables and views available in a data source by clicking List of tables or List of views button in the data source’s properties. Once you’ve pressed the button, you can see a dialog box with two list boxes. The upper one displays available tables/views. When you select a table/view in it, the lower list box shows table’s/view’s fields.
Using these dialog boxes, you check connection to the database. Tables, views, and their fields should match the ones defined in the database-authoring tool.
© 1992-2004 XJ Technologies http://www.xjtek.com |
411 |
|
|
AnyLogic V User’s Manual |
|
|
|
|
|
|
static ResultSet |
The method returns result set produced |
|
|
getTableResultSet(String sTableName, |
|
|
|
String sListOfFields, |
by querying data from specified fields |
|
|
String sKeyField, |
and rows of specified table. |
|
|
String sKeyFieldValueString sSqlQuery) |
|
|
|
|
|
|
|
static String |
The method executes specified SQL |
|
|
getValue(String sSqlQuery) |
query and returns the produced value. |
|
|
|
|
|
|
static boolean |
The method executes specified SQL |
|
|
modify(String sSqlQuery) |
query. |
|
|
|
|
|
|
static java.sql.Statement |
The method returns statement. |
|
|
getStatement() |
|
|
|
|
|
|
|
|
|
|
|
static java.util.HashTable |
The method executes specified SQL |
|
|
getRow(String sSqlQuery) |
query and returns the produced values. |
|
|
|
|
|
Table 20. Methods of data source class generated by AnyLogic
20.4 Custom queries
If you need a view different from views available in a database, and you do not want to add that view to the database, you can create a query directly in AnyLogic.
►To create a new query
1.Choose Insert|New Query… from the main menu. The New Query dialog box is displayed.
Specify the name of the new query, choose the data source and click OK.
2.Alternatively, in the Project window, right-click the data source and choose New Query … from the popup menu.
The New Query dialog box is displayed.
Specify the name of the new query and click OK.
© 1992-2004 XJ Technologies http://www.xjtek.com |
413 |
AnyLogic V User’s Manual
21. Customizing AnyLogic UI
AnyLogic allows you to customize the UI to make your work more convenient. Namely, you can customize AnyLogic menu, toolbars (create your own toolbars, control the layout of toolbars and toolbar buttons) and change the colors of AnyLogic structure diagrams elements.
21.1 Customizing toolbars and menus
AnyLogic toolbars and menus are customizable. You can create your own toolbars, delete toolbars, make them invisible, etc. The layout of buttons on toolbars can also be changed. You can customize the AnyLogic menu appearance also. To customize toolbars and menu appearance, you use the Customize dialog box.
►To open the Customize dialog box
1.Choose Tools|Customize from the main menu.
2.Click the Toolbars tab if you are going to create, delete, show, or hide toolbars. See section 21.1.1, “Toolbars page” for details.
3.Click the Commands tab if you are going to add or remove toolbar buttons. See section 21.1.2, “Commands page” for details.
4.Click the Keyboard tab if you are going to configure the shortcut keys for the commands. See section 21.1.3, “Keyboard page” for details.
5.Click the Menu tab if you are going to customize AnyLogic menu appearance. See section 21.1.4, “Menu page” for details.
6.Click the Options tab if you are going to customize the toolbar buttons appearance. See section 21.1.5, “Options page” for details.
© 1992-2004 XJ Technologies http://www.xjtek.com |
415 |
