Hi,
I created an editable grid and successfully saved data into table.
But I am not able to populate form with this data.
I have three data fields on form : name, email, partner
At pool level java.util.List type variable javalistfromdb
At connector level in output operation definition :
“javalistfromdb” takes value of
import groovy.sql.Sql;
import java.sql.Driver;
def String str;
def host = “localhost:3306”;
def user = “root”;
def pass = “root”;
def schema = “test”;
def result = [:];
def sql = BonitaSql.newInstance(“jdbc:mysql://$host/$schema”,“$user”,“$pass”, new com.mysql.jdbc.Driver());
def query=“”;
query=“select name
,email
, partner_name
from data”;
sql.eachRow (query, { row-> result.put(row.name, row.email, row.partner_name) })
sql.close()
I have no idea how to bind each fild with the data from sql
Regards
Manoj
Hi.
Rather than creating your own connector, you can use the MySQL connector that already is inside Bonita BPM.
In the output of the connector your will obtain a List of List that contains the data you read in your database.
If you want to read each data in this List of List you can do this :
for (ArrayList row : javalistfromdb) {
row.get(0); // name
row.get(1); // email
row.get(2); // partner
}
If you have multiple row, you can’t populate a single field with all the value all at once. I don’t know what excactly you want to do so I can’t help more.
Hi,
I created new task (step 2) with form
On each field on form (i.e. name, email, partner) under Data tab->initial value->script I have written the code
when I run the form it opens the default input form which contains fields(email, name, partner and “submit” button) which is blank.
I changed the button label for my form from “submit1” to “submit form” but still the form is created as default for three fields.
I even moved the data fields created at pool level to step2 but same result.
any idea what can be the issue?
Thanks
Manoj
Thanks for reply,
Ok, I used MySql connector and in Query/Batch Script window I wrote sql:
select name, email, partner_name from data where name=‘myname’
then in output window (Graphical mode) I selected “javalistfromdb”(which was created at pool level of java.util.List type), is it ok?
Then I created a form at this step1 ( which contains above Mysql connector also)
now, I want fill the values in three fields in form.
How to set value we get from above sql to form fields? where to write code?
Please help
Thanks
Manoj
then in output window (Graphical mode) I selected “javalistfromdb”(which was created at pool level of java.util.List type), is it ok?
Yes, this is ok.
Then I created a form at this step1 ( which contains above Mysql connector also)
I recommand to create the form on a new task after the task that contains the connector.
I think that the result of your query is only one row.
To fill each field you need to add this code in the Data tab “Initial Value” :
if (javalistfromdb == null) return null;
else if (javalistfromdb.size() <1) return null;
else return javalistfromdb.get(0).get(X);
// Where X is 0 for name, 1 for email and 2 for partner
Hi.
There is a default form that is automatically created at the beginning of each process.
Your custom form is displayed after your submit the default form.
To desactivate the default form, you need to click on your Pool, then on the Application tab and check the “Skip” box.
I applied skip as you mentioned and run process,
In step 1 “get data from db” click->default form is opened to enter three field details->submit then it says “your information has been submitted”
It did not show my form with data
when I checked log it shows error:
CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=test | CONNECTOR_INSTANCE_ID=28 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.connector.exception.SConnectorException: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:332)
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnector(ConnectorServiceImpl.java:150)
at org.bonitasoft.engine.connector.ConnectorServiceDecorator.executeConnector(ConnectorServiceDecorator.java:111)
at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:125)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork.work(FailureHandlingBonitaWork.java:70)
at org.bonitasoft.engine.work.BonitaWork.run(BonitaWork.java:56)
at org.bonitasoft.engine.work.SequenceRunnableExecutor.innerRun(SequenceRunnableExecutor.java:47)
at org.bonitasoft.engine.work.BonitaRunnable.run(BonitaRunnable.java:35)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.connector.exception.SConnectorException: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:119)
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:324)
… 14 more
Caused by: java.util.concurrent.ExecutionException: org.bonitasoft.engine.connector.exception.SConnectorException: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.getValue(ConnectorExecutorImpl.java:143)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:113)
… 15 more
Caused by: org.bonitasoft.engine.connector.exception.SConnectorException: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:72)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:188)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:170)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
… 3 more
Caused by: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at org.bonitasoft.connectors.database.jdbc.JdbcConnector.executeBatch(JdbcConnector.java:266)
at org.bonitasoft.connectors.database.jdbc.JdbcConnector.execute(JdbcConnector.java:92)
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:70)
… 6 more
Caused by: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at org.bonitasoft.connectors.database.Database.executeBatch(Database.java:100)
at org.bonitasoft.connectors.database.jdbc.JdbcConnector.executeBatch(JdbcConnector.java:261)
… 8 more
Caused by: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:1198)
at org.bonitasoft.connectors.database.Database.executeBatch(Database.java:94)
… 9 more
Hi,
above error was due to I put “;” as command separtor.
Now I am able to populate form with data from mysql
many thanks
-Manoj