I wrote a job with following code with following code:
====================================
ResultSet rs;
DictTable dictTable = new DictTable(tableNum(custTable));
Connection connection = new Connection();
Statement statement = connection.createStatement();
str sql= “select * from CustTable”;
rs = statement.executeQuery(sql);
while (rs.next() )
{
info(rs.getString(2));
}
==========
Statement : rs=statement.executeQuery(sql)-gives me an error:
Request for the permission of type ‘SqlStatementExecutePermission’ failed.
(S) \Classes\SqlStatementExecutePermission\demand
(S) \Classes\Statement\executeQuery
(C) \Jobs\CSA_AutoPadTest - line 20
=========================
I can not find class: SqlStatementExecutePermission.
I am connected as admin. How can i grant permission for this type of actions?
Perhaps you might want to check the authentication method on the database. Please make sure that you are using the right user credentials from the code.
The class that you mentioned is available under system documentation → classes in AOT.
If you haven’t managed to fix the problem yet, please do a search for SQLStatementExecutePermission in the Ax 4.0 developer’s guide. There are some code snippets there which you might want to give a try.
there are two conditions you have to make sure of them so the code will work.
by the way all what the guys repied is correct code, but.
you have to:
1- create new class and but that code in the main method"
*static void main(Args args)*
*{*
}
2- make sure that the property of the class “RunOn” is set to "server: this step is too IMPORTANT since the connection can only happen on the SERVER and it will fail if you run it in client.