Hello,
I try this script in my BDM and display it in my table.
*import com.company.model.Division;
String divisionNames = [“IT”, “Finance”, “Marketing”];
List newDivisions = new ArrayList();
for (String divisionName : divisionNames)
{
Division newDivision = new Division();
newDivision.setName(divisionName);
newDivision.setDescription("Sample description for "+ divisionName);
newDivisions.add(newDivision);
}
return newDivisions;*
It work! Now I want divisionNames (array) select from database and display it in text field & table. How am I suppose to do?
Thanks and Best Regards,
Anna
This is a big ask,
- you need to know your SQL database,
- you need to connect to the database with a connector,
- you need to write some SQL in the connector to read the database,
- and once you have that you can populate your list in a connector using code similar to that you’ve already got
Your SQL statement will need to be something like:
Select divisionName from divisionsTable;
Teaching SQL though is outside the scope of this forum, have a look at
http://www.w3schools.com/sql/
regards
Sean
Hello Sean,
Thanks for your fast respond. I try again in my way like this
- I go to my pool and go to the execution tab
- I create a new connection in Connector In
- I fill all the database information and in Enter Query Form I write my SQL “select divisionName from divisionTable”
- Now, how to populate my list in my script?
Can you show me the way?
Thanks and Best Regards,
Anna
[What’s Next?]
[What’s Next?]: http://imgur.com/UrwrXF6
I found this article http://community.bonitasoft.com/questions-and-answers/how-read-data-using-db-connector-business-variable. I follow his step and it work.
import com.company.model.Division;
List newDivisions = new ArrayList();
while(resultset.next()){
Division newDivision = new Division();
newDivision.setName(resultset.getString(“name”));
newDivision.setName(resultset.getString(“description”));
newDivisions.add(newDivision);
}
return newDivisions;
Thanks and Best Regards,
Anna
Hello Sean,
I have 2 question for you:
- How to fill my Input widget from my BDM? I can show it in my Table widget but I can’t show it in my Input widget. I call my BDM in my Table widget with this API “…/API/bdm/businessData/com.company.model.DivisionTable?p=0&c=20&q=find”.
- How to clean data in my BDM before I fill with my sql query.
Thanks and Best Regards,
Anna