The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
"problem in using readDatabase, writeDatabase and updateDatabase operator in Java"
arunpushkar
Member Posts: 8 Contributor II
As suggested by Marco Boeck(administrator) i have used rapid miner GUI for creating process in which i used readDatabase operator read table from mysql data base and used it as a input to LOF operator and there after output of LOF operator was given to writeDatabase operator. process so created was called from java application, but when compiled it gives error on database connection variable 'netcon' which i have defined using GUI and was working well there. Then why is it not finding it when being called from java application. my java code is as follows.
package pkg;And my XML process code is as follows
import java.io.IOException;
import com.rapidminer.RapidMiner;
import com.rapidminer.RapidMiner.ExecutionMode;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.IOObject;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.repository.IOObjectEntry;
import com.rapidminer.repository.MalformedRepositoryLocationException;
import com.rapidminer.repository.ProcessEntry;
import com.rapidminer.repository.RepositoryException;
import com.rapidminer.repository.RepositoryLocation;
import com.rapidminer.tools.XMLException;
import com.rapidminer.Process;
public class trydatabase {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
// this initializes RapidMiner with your repositories available
// you have to call this for all your programs, otherwise your RapidMiner integration will not work correctly
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
RapidMiner.init();
// loads the process from the repository
RepositoryLocation pLoc = null;
try
{
pLoc = new RepositoryLocation("//NewLocalRepository/createOutlier");
}
catch (MalformedRepositoryLocationException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
ProcessEntry pEntry = null;
try
{
pEntry = (ProcessEntry) pLoc.locateEntry();
}
catch (RepositoryException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
String processXML = null;
try
{
processXML = pEntry.retrieveXML();
}
catch (RepositoryException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
Process myProcess = null;
try
{
myProcess = new Process(processXML);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch (XMLException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
try
{
myProcess.run();
}
catch (OperatorException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>Error which i am getting is
<process version="5.2.008">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
<process expanded="true" height="235" width="681">
<operator activated="true" class="read_database" compatibility="5.2.008" expanded="true" height="60" name="Read Database" width="90" x="47" y="177">
<parameter key="connection" value="netcon"/>
<parameter key="query" value="SELECT * FROM `nettable`"/>
<enumeration key="parameters"/>
</operator>
<operator activated="true" class="anomalydetection:Local Outlier Factor (LOF)" compatibility="1.2.000" expanded="true" height="76" name="Local Outlier Factor (LOF)" width="90" x="226" y="164">
<parameter key="k_max (MinPtsUB)" value="18"/>
</operator>
<operator activated="true" class="write_database" compatibility="5.2.008" expanded="true" height="60" name="Write Database" width="90" x="471" y="182">
<parameter key="connection" value="netcon"/>
<parameter key="table_name" value="resulttable"/>
</operator>
<connect from_op="Read Database" from_port="output" to_op="Local Outlier Factor (LOF)" to_port="example set"/>
<connect from_op="Local Outlier Factor (LOF)" from_port="example set" to_op="Write Database" to_port="input"/>
<connect from_op="Write Database" from_port="through" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
Dec 22, 2012 1:40:07 PM com.rapidminer.tools.ParameterService initCan you please suggest some solution please
INFO: Reading configuration resource com/rapidminer/resources/rapidminerrc.
Dec 22, 2012 1:40:07 PM com.rapidminer.tools.I18N <clinit>
INFO: Set locale to en.
Dec 22, 2012 1:40:07 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Property rapidminer.home is not set. Guessing.
Dec 22, 2012 1:40:07 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying parent directory of '/home/iitm/workspace/rapidminer/rapidminer.jar'...gotcha!
Dec 22, 2012 1:40:07 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying parent directory of '/opt/rapidminer/lib/rapidminer.jar'...gotcha!
Dec 22, 2012 1:40:07 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying parent directory of '/opt/rapidminer/lib/launcher.jar'...gotcha!
Dec 22, 2012 1:40:08 PM com.rapidminer.parameter.ParameterTypePassword decryptPassword
WARNING: Password in XML file looks like unencrypted plain text.
Dec 22, 2012 1:40:09 PM com.rapidminer.tools.jdbc.JDBCProperties <init>
WARNING: Missing database driver class name for ODBC Bridge (e.g. Access)
Dec 22, 2012 1:40:09 PM com.rapidminer.tools.jdbc.JDBCProperties registerDrivers
INFO: JDBC driver ca.ingres.jdbc.IngresDriver not found. Probably the driver is not installed.
Dec 22, 2012 1:40:09 PM com.rapidminer.tools.jdbc.JDBCProperties registerDrivers
INFO: JDBC driver oracle.jdbc.driver.OracleDriver not found. Probably the driver is not installed.
Dec 22, 2012 1:40:09 PM com.rapidminer.tools.WrapperLoggingHandler log
INFO: No filename given for result file, using stdout for logging results!
Dec 22, 2012 1:40:09 PM com.rapidminer.Process run
INFO: Process starts
com.rapidminer.operator.UserError: Database connection failed: connection netcon is unknown. Please define the connection properly.
at com.rapidminer.tools.jdbc.DatabaseHandler.getConnectedDatabaseHandler(DatabaseHandler.java:1038)
at com.rapidminer.operator.io.DatabaseDataReader.getResultSet(DatabaseDataReader.java:111)
at com.rapidminer.operator.io.DatabaseDataReader.createExampleSet(DatabaseDataReader.java:124)
at com.rapidminer.operator.io.AbstractExampleSource.read(AbstractExampleSource.java:52)
at com.rapidminer.operator.io.DatabaseDataReader.read(DatabaseDataReader.java:96)
at com.rapidminer.operator.io.DatabaseDataReader.read(DatabaseDataReader.java:82)
at com.rapidminer.operator.io.AbstractReader.doWork(AbstractReader.java:123)
at com.rapidminer.operator.Operator.execute(Operator.java:834)
at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:711)
at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:379)
at com.rapidminer.operator.Operator.execute(Operator.java:834)
at com.rapidminer.Process.run(Process.java:925)
at com.rapidminer.Process.run(Process.java:848)
at com.rapidminer.Process.run(Process.java:807)
at com.rapidminer.Process.run(Process.java:802)
at com.rapidminer.Process.run(Process.java:792)
at pkg.trydatabase.main(trydatabase.java:87)
0
Answers
i have set the PATH to this directory. but still same error "Database connection failed: connection netcon is unknown. Please define the connection properly." How ever this connection "netcon" has been defined properly using rapidminer GUI while making the process.
Still No solution