class WL_ODBCConnectionSqlData{ LoginProperty login; OdbcConnection odbcConnection; ExecutePermission perm; Statement statement;}void CreateOdbcSatement(str dnsName = "", str dataName = ""){ SysSQLSystemInfo systemInfo = SysSQLSystemInfo::construct(); ; if (!dnsName) dnsName = systemInfo.getLoginServer(); if (!dataName) dataName = systemInfo.getloginDatabase(); perm = new ExecutePermission(); perm.assert(); login = new LoginProperty(); login.setOther(strfmt("Driver={sql server};server=%1;database=%2;uid=%3;pwd=%4", dnsName,dataName,"xxxxx","********")); odbcConnection = new odbcConnection(login); statement = odbcConnection.createStatement(); codeAccessPermission::revertAssert();}
public Statement parmStatement(Statement _statement = statement)
{ ; statement = _statement; return statement;}
Job
WL_ODBCConnectionSqlData odbcCon = new WL_ODBCConnectionSqlData(); Statement statement; ResultSet resultSet; str strsql; SqlStatementExecutePermission m_permission; ; odbcCon.CreateOdbcSatement(); statement = odbcCon.parmStatement(); strSql = "select top 10 itemId,itemName from InventTable";
m_permission = new SQLStatementExecutePermission(strSQL);
m_permission.assert(); resultSet = statement.executeQuery(strsql); CodeAccessPermission::revertAssert(); while (resultSet.next()) { info(resultSet.getString(1)); } resultSet.close();
}