Discussion:
JDBC Connector AddOnly Mode
(too old to reply)
Devran Uluçay
2020-03-31 12:32:34 UTC
Permalink
Hello,

Normally in my project, I was parsing the json data returned as a result of web service to the csv file, now they want me to add it to the database, not csv. For this, I use JDBC connector in addonly mode but I cannot add data.
The code I wrote is as follows.

hEntry = work.fromJSON(work.Response);
jsObj = fromJson(hEntry.toJSON());
entry = system.newEntry();

for (i = 0; i < jsObj.resources.length; i++) {
schema = jsObj.resources[i];

entry.removeAllAttributes();

entry.id = schema.id;

atts = schema["urn:ibm:params:scim:schemas:extension:bean:agc:2.0:Entitlement"];
entry.application_id = atts.application_id;
entry.application_name = atts.application_name;
entry.name = atts.name;

//CsvConnector.add(entry);
DBConnector.putEntry(entry);
}
How can I add this data to the database?

Thanks.
Eddie Hartman
2020-03-31 18:17:47 UTC
Permalink
Post by Devran Uluçay
Hello,
Normally in my project, I was parsing the json data returned as a result of web service to the csv file, now they want me to add it to the database, not csv. For this, I use JDBC connector in addonly mode but I cannot add data.
The code I wrote is as follows.
hEntry = work.fromJSON(work.Response);
jsObj = fromJson(hEntry.toJSON());
entry = system.newEntry();
for (i = 0; i < jsObj.resources.length; i++) {
schema = jsObj.resources[i];
entry.removeAllAttributes();
entry.id = schema.id;
atts = schema["urn:ibm:params:scim:schemas:extension:bean:agc:2.0:Entitlement"];
entry.application_id = atts.application_id;
entry.application_name = atts.application_name;
entry.name = atts.name;
//CsvConnector.add(entry);
DBConnector.putEntry(entry);
}
How can I add this data to the database?
Thanks.
What you have there looks good, Devran, as long as DBConnector points to an initialized Database or JDBC Connector, and the names of the attributes you are writing conform with the column names of the table you are writing to.

/Eddie
Devran Uluçay
2020-04-01 10:41:14 UTC
Permalink
Hi,

Thanks for your answer.

What is meant by control regarding column names? I want to send my data directly to the jdbc connector. Do I need to specify a column name?

Thanks.
Devran Uluçay
2020-04-01 12:18:39 UTC
Permalink
Hi,

Database column names and entry attributes names are same. New code below,
hEntry = work.fromJSON(work.Response);
jsObj = fromJson(hEntry.toJSON());
entry = system.newEntry();

for (i = 0; i < jsObj.resources.length; i++) {
schema = jsObj.resources[i];

entry.removeAllAttributes();

entry.id = schema.id;

atts = schema["urn:ibm:params:scim:schemas:extension:bean:agc:2.0:Entitlement"];
entry.application_id = atts.application_id;
entry.application_name = atts.application_name;
entry.name = atts.name;

//CsvConnector.add(entry);
DBConnector.putEntry(entry.name);
DBConnector.putEntry(entry.application_id);
DBConnector.putEntry(entry.application_name);
DBConnector.putEntry(entry.id);
}

But not working :(
Eddie Hartman
2020-04-01 17:19:48 UTC
Permalink
What error do you get? The connector uses the names of the attributes as the column names. Make sure they are the same.

/Eddie
Devran Uluçay
2020-04-02 13:31:04 UTC
Permalink
Hi,

I receive error:

Failed with error: Error calling method 'putEntry(com.ibm.di.entry.Entry)' on an object of type 'com.ibm.di.server.AssemblyLineComponent [Dynamic Java Wrapper, com.ibm.di.server.AssemblyLineComponent]'.
14:22:57,533 ERROR - CTGDIS281E Error caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=19, col=17: [TypeError] Error calling method 'putEntry(com.ibm.di.entry.Entry)' on an object of type 'com.ibm.di.server.AssemblyLineComponent [Dynamic Java Wrapper, com.ibm.di.server.AssemblyLineComponent]'.

They have same name.
Eddie Hartman
2020-04-02 18:06:53 UTC
Permalink
You are so close, Devran. You are referencing the AL Connector in your AssemblyLine. The add method for this object is add(entry). If you instead grab it's Connector Interface (CI) by spending '.connector' to it then you can call putEntry(entry)

/Eddie
Devran Uluçay
2020-04-03 07:39:28 UTC
Permalink
Hi,

Thanks for your answer.

I tried jdbcconnector.add(entry.attributename) but not working.

I receive error;

ERROR - CTGDIS077I Failed with error: Script interpreter error, line=18, col=19: Java method 'add(com.ibm.di.entry.Attribute)' on java class 'com.ibm.di.server.AssemblyLineComponent' not found.

My code;

hEntry = work.fromJSON(work.Response);
jsObj = fromJson(hEntry.toJSON());
entry = system.newEntry();

for (i = 0; i < jsObj.resources.length; i++) {
schema = jsObj.resources[i];

entry.removeAllAttributes();

entry.id = schema.id;

atts = schema["urn:ibm:params:scim:schemas:extension:bean:agc:2.0:Entitlement"];
entry.application_id = atts.application_id;
entry.application_name = atts.application_name;
entry.name = atts.name;

//CsvConnector.add(entry);
JDBCConnector.add(entry.id);
JDBCConnector.add(entry.name);
JDBCConnector.add(entry.application_id);
JDBCConnector.add(entry.application_name);

}

JDBCConnector work with passive mode.

Attribute names and Database Column names are same.
Eddie Hartman
2020-04-03 17:26:07 UTC
Permalink
JDBConnector is the name of the component in your assmeblyline that is in Passive state, right? If you look in Help - Javadocs and look for the classname, AssemblyLineComponent you will see that the .add() method accepts an Entry as its argument and not an attribute. You are calling it with the attribute, work.attributename. Try instead calling it with just (work)
Devran Uluçay
2020-04-03 07:42:17 UTC
Permalink
Also,

My Entry;

{
"application_name": "Active Directory BBS",
"name": "Administrators",
"application_id": 108,
"id": "387"
}
Loading...