Database Connection from custom Node

I’m currently in the process of updating my custom nodes. I have an older node that connects to an oracle database.

It uses:

DatabaseDriverLoader.registerDriver("oracle.jdbc.OracleDriver");

And then

DriverManager.getConnection()

However the sdk tells me that registerDriver is deprecated and I wanted to also fix that. However it’s completely unclear how and the documentation is really no help at all:

use the DatabaseUtility.getConnectionFactory() method instead since this is only one source for database drivers

This leads to OracleUtility() but then you seem to need a DBDriverFactory which needs DatabaseConnectionSettings. it’s the typical Java enterprise rabbit hole.

A guide how to create a db connection would be appreciated. The old way was trivial and simple…

2 Likes

Hi @beginner
Your should be able to create a DatabaseConnectionSettings Object with: DatabaseConnectionSettings(final String dbIdentifier, final String driver, final String jdbcUrl, final String user, final String pass, final String credName, final String timezone) to use here. (credName can be null, timezone can be “none”)

On this you can call
.getUtility().getConnectionFactory().getConnection(final CredentialsProvider cp, final DatabaseConnectionSettings settings)
with your settings object to get a Connection. (CredentialsProvider can be null)

I hope this helps
best regards Mareike

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.