RODBC in execute R works in RM but not work in web service

jujujuju Member Posts: 39 Guru
edited November 2018 in Help

Hi I'm doing read/write database in execute R. I'm using RODBC library in R for it.





This works in RM studio,

but when I make it a web service, it has error 

de.rapidanalytics.ejb.service.ServiceDataSourceException: Error executing process 
/home/RM/test_db_connection_in_web_service for service test_db_connection_in_web_service: The execution of the R script failed.

Here's the code (if you want to test, you need to change the server name, the database name and the table name.)

Any help's appreciated. Thank you!

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.4.000">
<operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="read_database" compatibility="6.4.000" expanded="true" height="60" name="Read Database" width="90" x="313" y="30">
<parameter key="connection" value="AnalyticsEngine"/>
<parameter key="define_query" value="table name"/>
<parameter key="table_name" value="table1"/>
<enumeration key="parameters"/>
<operator activated="false" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="60" name="Execute R" width="90" x="313" y="120">
<parameter key="script" value="library(RODBC)&#10;&#10;rm_main = function(){&#10; &#10; ch = odbcDriverConnect(&quot;Driver={SQL Server};Server=sao-dev-db22;Database=AnalyticsEngine;Trusted_Connection=True&quot;)&#10; &#10; rule_dtype_matching = sqlFetch(ch, 'mini_meta_rule_dtype_matching')&#10; &#10; odbcClose(ch)&#10; &#10; rule_dtype_matching&#10;}&#10;"/>
<operator activated="true" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="76" name="Execute R (2)" width="90" x="313" y="210">
<parameter key="script" value="library(RODBC)&#10;&#10;rm_main = function(){&#10; &#10; ch = odbcDriverConnect(&quot;Driver={SQL Server};Server=db22;Database=AnalyticsEngine;Trusted_Connection=True&quot;)&#10; sql0 = sprintf(&quot;SELECT * FROM [dbo].[table1]&quot;)&#10; dat = sqlQuery(ch, sql0)&#10; dat&#10;}&#10;"/>
<connect from_op="Read Database" from_port="output" to_port="result 1"/>
<connect from_op="Execute R (2)" from_port="output 1" to_port="result 2"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
<portSpacing port="sink_result 3" spacing="0"/>








  • Options
    Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    You can not create a Web Service in RapidMiner Studio, you need to use RapidMiner Server.



Sign In or Register to comment.