question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow access to the java.sql.Connection from DbExecute

See original GitHub issue

Environment Details

  • Helidon Version: 2.3.0-SNAPSHOT
  • Helidon SE
  • JDK version: 16
  • OS: debian

Problem Description

I’m trying to use the CopyManager from the PostgreSQL JDBC Driver to insert some CSV-Data into my database. That requires access to the underlying java.sql.Connection, which seems impossible to obtain from the io.helidon.dbclient.DbExecute / io.helidon.dbclient.DbTransaction passed to DbClient::execute / DbClient::inTransaction. The Connection obtained should be part of the current transaction, if possible. Thank you for the work on Helidon, it’s a joy to use. 😃

Edit: I’m imagining something like this:

dbClient.execute(exec -> {
    Optional<org.postgresql.core.BaseConnection> connection = exec.unwrap(org.postgresql.core.BaseConnection.class);
    // use connection ...
});

Ideally, the JdbcDbClient variant would handle further unwrapping of the connection (I actually need the org.postgresql.core.BaseConnection), but just getting the java.sql.Connection would be fine as well.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Tomas-Krauscommented, Apr 27, 2021

Yes, Project Loom will change a lot. With features like fibers, we can probably start simplifying some reactive APIs which won’t be required anymore. But until that, we can’t do much in this area. So you are right, when we are talking about long term plans, there will for sure be some changes to introduce simple blocking API.

0reactions
zimmicommented, Apr 27, 2021

Thanks a lot for the code, I’m sure it will come in handy. Listening to talks about Project Loom I got the impression that it will reduce the need for reactive streams by allowing blocking code to scale in a similar fashion. So I assumed that this is the long term goal of Helidon, especially because it’s an Oracle effort as well. But I’m happy to be told otherwise.

Edit: My needs are fairly minimal as of now. I just need an organized, well documented framework with modern defaults and decent code quality that doesn’t rely on reflection and lots of abstraction layers that make debugging painful. Helidon SE ticks all those boxes. The APIs are very nice and clean, the only thing that makes reading the code harder is the reactive part. I was hoping that this will go away in the future as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow access to the java.sql.Connection from DbExecute · Issue ...
I'm trying to use the CopyManager from the PostgreSQL JDBC Driver to insert some CSV-Data into my database. That requires access to the...
Read more >
Processing SQL Statements with JDBC
In general, to process any SQL statement with JDBC, you follow these steps: Establishing a connection. Create a statement. Execute the query. Process...
Read more >
FileNet P8 5.5.x - Setting DbExecute connections - IBM
A DbExecute connection enables a workflow to access and run a procedure that is stored in an external database through the DbExecute system...
Read more >
Error using DBExecute in CloverETL 3.4 - CloverCARE Support
Hi Pro, I use DBExecute to call a procedure against a MSSQL database which will create a recordset. It ran into the error:...
Read more >
Step 3: Proof of concept connecting to SQL using Java
Step 3 is a proof of concept, which shows how you can connect to SQL Server using Java and JDBC. The basic examples...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found