joyoon00
(Jeongon Yoon)
December 19, 2024, 8:00am
1
I would like to perform provisioning in ISC using a JDBC connector and specify insert queries for two different tables.
Here is the code snippet I am considering:
// First statement
statement1 = connection.prepareStatement(sql1);
statement1.setString(1, req.getValue());
statement1.setString(2, user_id);
statement1.executeUpdate();
statement1.close();
// Second statement
statement2 = connection.prepareStatement(sql2);
statement2.setString(1, req.getValue());
statement2.setString(2, req.getValue());
statement2.setString(3, user_id);
statement2.executeUpdate();
statement2.close();
Is this a valid approach?
If not, could you suggest a better way to insert data into two different tables within the same transaction?
Thank you in advance!
gourab
(Gourab Sadhukhan)
December 19, 2024, 9:31am
2
Hi @joyoon00
I can give you some theoretical jdbc suggestions:
Check if data already exists in tables
The setAutoCommit(false)
call ensures that the changes made by both statements are not automatically committed to the database.
If both statements succeed, the commit()
method is called to apply the changes.
If either statement fails, the rollback()
method is called to undo changes from both statements, maintaining database integrity.
Finally, always ensure resources are closed properly in the finally
block
IAMpdu
(Prasad Uplenchwar)
December 19, 2024, 12:25pm
3
Hello @joyoon00 , you can do that and yes it is valid, if you want to build a complex logic you can build JAR file and refer that in JDBC PROV rule.
Disclaimer: Some information in this article may be outdated, please verify details by referring to latest resources or reach out to our technical teams. Introduction In an effort to better enable both partners and customers, we have outlined a...
1 Like
joyoon00
(Jeongon Yoon)
January 7, 2025, 5:08am
4
Hello, sorry for the delayed response.
I’m an amateur, so I’m having difficulty handling JDBC provisioning rule.
In my previous provisioning rule, I used the following commit:
result.setStatus(ProvisioningResult.STATUS_COMMITTED);
However, I lack sufficient knowledge about setAutoCommit(false)
, commit()
, and rollback()
methods as you explained above.
Would you be able to provide examples or share any reference documents?
mcheek
(Mark Cheek)
January 7, 2025, 1:58pm
5
You can find documentation around the setAutoCommit, commit, and rollback methods in the java.sql.connection documentation. It’s nothing specific to SailPoint, it’s just a Java class
https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/Connection.html
1 Like