与内存中运行的数据库的本地H2服务器-客户端连接 [英] Local H2 Server-Client connection with DB running in memory

查看:113
本文介绍了与内存中运行的数据库的本地H2服务器-客户端连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个独立的Java应用程序,我想通过内存中的H2-DB相互通信.从理论上讲非常简单,但我无法正常工作.

I have two independent Java apps which I would like to communicate with each other through an in-memory H2-DB. In theory very straight forward, but I cannot get the connection to work.

我正在尝试做的事情:我创建一个执行 jdbc:h2:mem:test 的内存数据库.对于客户端,我尝试连接到该客户端.我尝试了 jdbc:h2:tcp://localhost/〜/test 和类似的连接字符串,但是都没有成功.

What I am trying to do: I create an in-memory DB executing jdbc:h2:mem:test. With the client(s), I try connecting to it. I tried jdbc:h2:tcp://localhost/~/test and similar connection strings, but all without success.

是否可以连接到内存数据库?连接字符串应如何工作?谢谢你.

Is it possible to connect to an in-memory DB? What should the connection strings look like to make this work? Thanks a bunch.

推荐答案

经过大量阅读和反复试验后,发现H2选项(http://h2database.com/html/advanced.html ),我发现可以使用TCP/IP或SSL/从同一台计算机上的多个进程(或远程)访问内存数据库TLS.内存数据库 test 的连接字符串为 jdbc:h2:tcp://localhost/mem:test .

After a ton of reading and trial-and-error with H2 options (http://h2database.com/html/features.html and http://h2database.com/html/advanced.html), I found that it is possible to access an in-memory database from multiple processes on the same machine (or remotely) using TCP/IP or SSL/TLS. The connection string for an in-memory database test is jdbc:h2:tcp://localhost/mem:test.

这篇关于与内存中运行的数据库的本地H2服务器-客户端连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆