getConnection
Connection sqlDataManager.getConnection ( ) (professional and enterprise editions only)
Description
Retrieve the connection object of the data manager. This can be helpful if you want to do something that the data manager cannot do easily, such as query the database.
Be sure to close the connection once it is no longer needed. Failure to do so could exhaust the connection pool used by the datamanger, which will cause the scraping session to hang.
Parameters
This method does not receive and parameters.
Return Values
Returns a connection object matching the one used in the data manager.
Change Log
Version | Description |
---|---|
5.0 | Available for professional and enterprise editions. |
Examples
Retrieve Database Connection
// Import SQL object
import java.sql.*;
// Get datamanager
dm = session.getv( "DATAMANAGER" );
// Retrieve connection
connection = dm.getConnection();
try {
PreparedStatement ps = connection.prepareStatement( "UPDATE table SET status=?" );
ps.setString( 1, session.getv("STATUS") );
ps.executeUpdate();
} finally {
connection.close();
}
import java.sql.*;
// Get datamanager
dm = session.getv( "DATAMANAGER" );
// Retrieve connection
connection = dm.getConnection();
try {
PreparedStatement ps = connection.prepareStatement( "UPDATE table SET status=?" );
ps.setString( 1, session.getv("STATUS") );
ps.executeUpdate();
} finally {
connection.close();
}
scraper on 07/16/2010 at 5:23 pm
- Printer-friendly version
- Login or register to post comments