Reading data from MySQL table

Hi, I'm adding data to a MySQL database. There are 2 tables I want to add data to: one that creates an auto-incrementing id, and another that has a foreign key on the auto-incrementing id of the first table.

I can create records and add them to the first table. I'm using the SQLDataManager to do this:

for (i=0; i < dataset_name.getNumDataRecords(); i++){
        data_record = dataset_name.getDataRecord(i);
        dm.addData( "db_table_name", data_record);
        dm.commit("db_table_name");
        dm.flush();
}

I'm stuck with how to get the auto-incremented id associated with that record, so I can use it to add data to the second table.
1) Is there a way to get data from an existing MySQL table using the SQLDataManager?
2) Is there a way to write a SQL statement using SQLDataManager so I can pull the information I'm interested in?

The dataManager is pretty

The dataManager is pretty robust.

If you make the connection, and set the dataManager in a session variable named "_DM"

import java.sql.*;

dm = session.getv("_DM");
conn = dm.getConnection();
PreparedStatement ads = conn.prepareStatement("SELECT * FROM ads WHERE `present` = 1");
ResultSet resultSet = ads.executeQuery();
while (resultSet.next())
{
   // Loop results
}

You can get the last inserted ID with getLastAutoIncrementValue.