SQLDataSource external type

SQLDataSource represents a connection to a database. An instance of this type is used in the EGL statements that interact with a database.

EGL package name

eglx.persistence.sql

Example use
The following code connects to a database and provides a user ID and password:
// the myCustomer variable is based on a custom Record type (not shown)
myCustomer Customer;

// the data source includes a connection string, as well as
// security details that are stored in a dictionary.
connectURL string = "jdbc:derby:SomeDB;create=true;";
properties Dictionary{user = "MyID", password = "MyPassword"};
ds SQLDataSource? = new SQLDataSource(connectURL, properties);

// get the customer details
get myCustomer from ds using(1234) with #sql{
      SELECT * FROM CUSTOMER WHERE id = ?
   };
The more flexible way to connect to a database is to specify a Resource annotation that makes available a database binding in the EGL deployment descriptor:
ds SQLDataSource?{@Resource{bindingkey = "MyDatabaseBinding"}};  
Type detail
externalType SQLDataSource extends DataSource type NativeType

   private constructor();

   // security details are optional
   constructor(connectionUrl string in);
   constructor(connectionUrl string in, properties Dictionary in);

   // ISOLATION LEVELS specify the level of independence 
   // of one user's database transaction from another user's transaction.
   // For background details, see the JDBC documentation from Oracle.
   
   // This value represents the default isolation level of the JDBC driver.
   // Driver vendors typically use repeatableRead, 
   // but check the documentation for your vendor to be sure.
   static TRANSACTION_ISOLATION_NONE int;

   // This value represents the most lenient isolation level: read uncommitted.
   // Your logic runs faster but might not detect the state of the database. 
   static TRANSACTION_ISOLATION_READ_UNCOMMITTED int;

   // This value represents a less lenient isolation level: read committed.
   static TRANSACTION_ISOLATION_READ_COMMITTED int;

   // This value represents a stricter isolation level: repeatable read.
   static TRANSACTION_ISOLATION_REPEATABLE_READ int;

   // This value represents the strictest isolation level: serializable.
   // The program is slower but detects the changes 
   // made by other programs that run at the same time. 
   static TRANSACTION_ISOLATION_SERIALIZABLE int;

   // End ISOLATION LEVELS

   // returns a boolean that indicates 
   // whether database changes are being committed immediately.
   function getAutoCommit() returns(boolean);

   // returns the isolation level.
   // possible return values were shown earlier. 
   function getTransactionIsolation() returns(int);

   // retrieves an object from which you can access warning details.
   // each warning is structured as an exception record.
   function getWarnings() returns(SQLWarning?);

   // indicates whether the connection is closed
   function isClosed() returns(boolean);

   // indicates whether the connection allows only reads from the database.
   function isReadOnly() returns(boolean);

   // returns true if a test of the connection succeeds within the 
   // specified number of seconds. if you specify zero seconds, no 
   // timeout applies.
   function isValid(timeout int in) returns(boolean);

   // indicates whether updates are committed immediately.
   // a false value typically results in faster processing.
   function setAutoCommit(autoCommit boolean in);

   // specifies the schema name
   function setCurrentSchema(schemaName string in);

   // sets the isolation level.  options were shown earlier.
   function setTransactionIsolation(level int in);

   // returns a Boolean value to indicate whether a 
   // specified isolation level is supported. options were shown earlier.
   function supportsTransactionIsolationLevel(level int in) returns(boolean);
end
Comments
Compatibility
Table 1. Compatibility
Target Issue
Java No issues.
JavaScript Database access is not supported.