zoukankan      html  css  js  c++  java
  • 【树莓派】h2数据库操作相关

    之前在树莓派上面操作时候,遇到一些业务方面的bug,和团队中的同事经过多次尝试,但就是难以重现用户现场的问题。

    但是问题却实实在在地发生,虽然并不是必然可重现的bug,但是也比较闹心;

    发生了问题,也只能通过数据库,直接操作,作为临时解决方案。

    这里记录一下,操作h2数据库的相关的信息。

    ---------------------------------------------

    操作分两种,一种通过linux shell下的命令行方式操作,另外一种是在Web Console的操作,类似与MySQL上面采用PHPAdmin操作一样。见下面:

    1、Shell Console

    首先下载h2 (h2下载地址:http://pan.baidu.com/s/1slOzQpv) ,上传到盒子上(如:/home/lifeccp/jdbc/)。然后执行如下命令:

    java -cp h2*.jar org.h2.tools.Shell

    更加提示,依次输入database URL, JDBC driver, user name, and password,即可进入Shell Console:

    sql> list

    Result list mode is now on

    sql> select * from test;

      

    2、WEB Console

    修改盒子上的Nginx配置,增加如下信息:

    location /h2-console {
    
            proxy_set_header X-Real-IP $remote_addr;
    
            proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
    
            proxy_set_header Host $http_host;
    
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:8090/h2-console;
    
     
    
            proxy_set_header Host $host;
    
            proxy_set_header X-Real-IP $remote_addr;
    
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
            proxy_set_header Upgrade $http_upgrade;
    
            proxy_set_header Connection "upgrade";
    
         } 

    重启Nginx,成功后,盒子内网环境下,直接访问http://盒子IP/h2-console/即可打开H2 WEB Console。


    ----------------------------------------------------------------------------------------------------

    java -cp h2-1.4.192.jar org.h2.tools.Shell
    URL:
    jdbc:h2:~/.h2/osprey;AUTO_SERVER=true;
    Driver:
    org.h2.Driver


    lifeccp@raspberrypi:~/h2-driver $ java -cp h2-1.4.192.jar org.h2.tools.Shell

    Welcome to H2 Shell 1.4.192 (2016-05-26)
    Exit with Ctrl+C
    [Enter] jdbc:h2:~/test
    URL jdbc:h2:~/.h2/osprey;AUTO_SERVER=true; 
    [Enter] org.h2.Driver
    Driver org.h2.Driver
    [Enter]
    User sa
    [Enter] Hide
    Password
    Password

    Commands are case insensitive; SQL statements end with ';'
    help or ? Display this help
    list Toggle result list / stack trace mode
    maxwidth Set maximum column width (default is 100)
    autocommit Enable or disable autocommit
    history Show the last 20 statements
    quit or exit Close the connection and exit

    sql>

    ----------------------------------------------------------------------------------------------------
    select * from t_study where study_instance_uid='1.2.410.200048.9496.20170301090845';
    update t_study set status=1,cuid=113232 where study_instance_uid='1.2.410.200048.9496.20170301090845';

    select * from t_study where study_instance_uid='1.2.840.20150323083837.345413';
    select * from t_study where study_instance_uid='1.2.840.20150323085841.345435';

    当连接OK之后,你就可以按照自己需要,去进行h2数据操作了。

  • 相关阅读:
    分享一个文件的工具类
    关于itext生成pdf的新的demo(包含简单的提取txt文件的内容 和xml内容转化为pdf)
    全文检索的Demo
    dom4j操作xml的demo
    利用Java获取ip地址
    利用htmlparser读取html文档的内容
    关于pdfbox操作pdf的分享链接手长
    poi读取word的内容
    基于NPOI对Excel进行简单的操作
    “尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,将出现此问题。”
  • 原文地址:https://www.cnblogs.com/haochuang/p/6519766.html
Copyright © 2011-2022 走看看