I am trying to write a java code which will insert multiple rows into a oracle table.
I saw the insert sql method in wM java API-
public Values insert(java.lang.String table,
Now I have a IData array in service input, could you pls let me know how to convert this input IData array to Values array for this insert method input.
Appreciate your help!
Why don’t you use batchInsert built-in adapter service? Is there a particular thing you want to accomplish using a java service for this task?
You can try this.
- Declare a Values object, valueObj
- For each IData, define a cursor.
- use cursor.getKey() and cursor.getValue() to get both name nad value;
//Here docs is an input doc list i declared
IDataCursor cur = pipeline.getCursor();
IData docs = IDataUtil.getIDataArray(cur,"List");
Values valueObj = new Values();
IDataCursor localCur = docs[i].getCursor();
String key = localCur.getKey();
String value = (String)localCur.getValue();
thnaks for your reply. I am trying to call different databases depending on sender id and cant change JDBC connection dynamically for 6.1 so need to write these java code.
I’d offer that you don’t “need” to write this in Java. Another approach would be to create the connections to the different databases and then create the JDBC services as needed for each. This probably will result in duplicate services, but IMO is a far better scenario than managing JDBC within Java. And it also sets you up for the future with 6.5 where dynamic control of the connection to use is possible.
we thought of that, problem is we have 3 target systems and each has 3/4 test enviroments and we need to switch very often. this is mainly require for testing, i am planning to keep adapter services in Prod.
BTW, if anybody knows about DB2 DB url pls let me know.
I am using these in adapter connection -
DataSource Class- com.ibm.as400.access.AS400JDBCDataSource
Other Properties - libraries=;transaction isolation=none;prompt=false
“we have 3 target systems and each has 3/4 test enviroments”
This might be better facilitated by using multiple JDBC connections as well. It would make switching which DB a particular connection is using (test1, test2, etc.) very quick and easy.
But clearly I don’t have all the details, so what I’m suggesting may not be effective.