Dear Gents,
i am trying to connect to an external database on different server from x , my purpose is the following:
i am creating a new batch job class on D365 FO to insert data in a table from an external database, database located on different server, not the same one.
i tried the standard ODBC connection but ODBC doesn't allow you to enter UserID and password, only DSN and database.
then i tried the below via ODBC and it didn't work either:
server static ResultSet executeQuery(str sql, Connection connection = new Connection())
{
LoginProperty loginProperty;
OdbcConnection odbcConnection;
str con;
str dsn="server name";
str UID="UserID";
str pwd="Password";
SqlStatementExecutePermission sqlPerm;
Statement statement;
ResultSet resultSet;
;
con=strFmt("DSN=1%,UID=2%,pwd=3%",dsn,UID,pwd);
loginProperty = new LoginProperty();
loginProperty.setDatabase("tm");
loginProperty.setOther(con);
odbcConnection = new OdbcConnection(loginProperty);
sqlPerm = new SqlStatementExecutePermission(sql);
sqlPerm.assert();
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sql);
CodeAccessPermission::revertAssert();
return resultSet;
}
what im facing is when i run the query in batch job, the batch job is returning Error in status, it's not even executing.
kindly provide me with solutions and how to debug if the connection is working or no
Regards,