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

  • 相关阅读:
    Sql server Always On 读写分离配置方法
    MSSQL AlwaysOn中的“主角色中的连接”和“可读辅助副本”
    Windows Server 2019 Active Directory (AD域)时间不同步的解决方法
    windows server 2008 R2 域中用组策略隐藏指定磁盘驱动器(盘符)
    pg数据库优化
    Qlik
    如何查看数据库特别慢
    针对数量的null值最好要做变0处理
    pg如何实现月份的加减
    sql
  • 原文地址:https://www.cnblogs.com/haochuang/p/6519766.html
Copyright © 2011-2022 走看看