The Micronaut framework includes several options for connection pooling since it launched and today there is a new option available for your microservice applications: Oracle Universal Connection Pool (UCP). In this post, I'd like to show you how to use this new feature in your application.
To get started, you must first include the dependency in your
If you're using Maven:
Next, you'll need to create a datasource in your
application.yaml file. All of the properties from
PoolDataSource are valid here and will be passed to the pool instance at runtime. For example:
You're now ready to add a service to query your datasource. If you're using Micronaut Data, you're all ready to go. Otherwise, you can create a service and inject the DataSource:
Add a method to get a connection from the pool, create and execute the query:
And a private helper to convert the ResultSet into a List of HashMap objects:
The only thing left to do is inject the UserService into our controller and add an endpoint to retrieve the users and return them:
In this post, we looked at how to utilize the new support for Oracle UCP in Micronaut. For further information, please check the docs or leave a question below!.
I recently blogged about a brand-new service in the Oracle Cloud - Database Tools. It's a safe, secure way to store your database credentials in the...
There's a brand new tool in town, and it's ready to make your life a whole lot easier if you work with Oracle DB in the cloud. It's called "Database Tools...
I have been spending a lot of time playing around with Oracle Advanced Queuing (AQ) lately and one of the things that has bothered me is the lack of a ...