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数据操作了。

  • 相关阅读:
    回调函数: 一定要在函数名前加上 CALLBACK,否则有可能引起内存崩溃!
    win32-api: 让 static 控件中的水平横行,垂直居中。
    Win32-API: 终于能正常的捕获焦点事件: WM_COMMAND、BN_SETFOCUS、EN_SETFOCUS
    FindExecutable:查找与一个指定文件关联在一起的程序的文件名
    ImageMagick: win7 | win8 & uac (用户帐户控制) 注册表的一些事
    ImageMagick: 6.8.3 升级到 6.8.9 遇到的问题
    ImageMagick: DrawImage(Image*,DrawInfo*) 绘制填充图片时卡住的原因分析
    真的无语, 今天遇到一个奇葩的事情: http 会话劫持
    高DPI下界面错乱的解决方法和原理
    关于 HDC 的释放
  • 原文地址:https://www.cnblogs.com/haochuang/p/6519766.html
Copyright © 2011-2022 走看看