Is it possible to access a database asynchronously through Java NIO non-blocking sockets?

前端 未结 2 1190
逝去的感伤
逝去的感伤 2021-01-01 19:18

I would like to access a database in a non-blocking way, in other words, I will send the SQL request through a socket and read the query response through the same socket

相关标签:
2条回答
  • 2021-01-01 20:01

    If you write your own driver, it would certainly be possible to do this for most databases.

    I am not aware of any drivers that do this "out of the box," however.

    0 讨论(0)
  • 2021-01-01 20:10

    It's possible, but not with JDBC. Unless you want to use the raw SocketChannel interface and parse the results yourself, the only async database drivers on the JVM I'm aware of are https://github.com/mauricio/postgresql-async (which despite the name also supports MySQL). They're written in Scala but it should be possible to call them from Java (since it's a JVM language), though I can't say how Java-friendly the API will be.

    0 讨论(0)
提交回复
热议问题