Database "mem:h2" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-210] 90149/90149 解决

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
1.4.198 (2019-02-22) 版本开始,H2不再自动创建数据库,很难在网上找到有解决方案,故down了源码
 
Connection to jdbc:h2:tcp://0.0.0.0:6666/./aika failed. [90149][90149] Database "/home/Hex/IdeaProjects/h2database/h2/aika" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200]
 
翻阅源码在
 
tutorial.html中有这么一段话(官方是不推荐这么做的,但是我们有时候用h2内嵌如果不能自动建库会很不方便)
 
    If you really need to allow remote database creation, you can pass <code>-ifNotExists</code> parameter to
    TCP, PG, or Web servers (but not to the Console tool).
    Its combination with <code>-tcpAllowOthers</code>, <code>-pgAllowOthers</code>, or <code>-webAllowOthers</code>
    effectively creates a remote security hole in your system, if you use it, always guard your ports with a firewall
    or some other solution and use such combination of settings only in trusted networks.
 
  
 
在启动服务的时候添加  -ifNotExists 就可以了。
 
    package org.h2.start;
      
    import org.h2.tools.Server;
      
      
    public class StartServer {
      
        public static void main(String[] args) throws Exception{
            Server server = Server.createTcpServer("-tcp", "-tcpAllowOthers","-ifNotExists", "-tcpPort",
                    "6666");
      
            server.start();
            while (true){
                Thread.sleep(10000);
            }
        }
    }

 

posted @   锐洋智能  阅读(1250)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· Windows 提权-UAC 绕过
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示