Database Access

You can access any JDBC compliant databases to either read from the database or update database directly from MScript. This document describes how you can set up a data set that points to a database and read from the data set using MScript.

The first step is to declare a db - data source with the JDBC driver and connection string.

Then you can declare dataset to read from the db. Below is an example of basic MScript:

<db id="myDB" connectionstring="jdbc:mysql://myDbHost:3306/mySqlDBName" driverclass="com.mysql.jdbc.Driver" user="xxx" password="yyyy"/>
<dataset id="myDS" db="myDB" mode="replace">
  <sql>
    select * from orders where dept = ?
  </sql>
</dataset>

<action code="$loadFromDataSource('myDS','Sales')"/>
<log msg="myDS info: $dataSetInfo('myDS')"/>
<log msg="reading data: $getData('myDS','orderID')"/>
<action code="$nextDataSetRow('myDS')"/>
<log msg="reading next row: $getData('myDS','orderID')"/>

Check out External Resources for a list of JDBC drivers for your database and their connection strings.

Print/export
QR Code
QR Code how_do_i_set_up_dataset_to_read_from_database (generated for current page)