zoukankan      html  css  js  c++  java
  • 记录自己在 cmd 中执行 jar 文件遇到的一些错误

    记录自己在 cmd 中执行 jar 文件遇到的一些错误

    场景: 请求接口,解析接口返回的 JSON 字符串并插入到我们的数据库里面。

    情况: 项目在 eclipse 中正常运行,打成 jar 包后在 cmd 命令窗口报错。

    错误信息如下:

    Microsoft Windows [版本 10.0.17134.407]
    (c) 2018 Microsoft Corporation。保留所有权利。
    
    C:UsersAdministrator>cd Desktop
    
    C:UsersAdministratorDesktop>java -jar TimedTask.jar
    正在读取数据,请稍后...
    出现异常,准备回滚了...
    java.sql.BatchUpdateException: ORA-12899: 列 "TLCZGJDDW"."T_RISK_SAFECHECKLIST"."ZW" 的值太大 (实际值: 51, 最大值: 40)
    
            at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10070)
            at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:213)
            at com.critc.task.InsertOrl.AddData(InsertOrl.java:144)
            at com.critc.task.App.main(App.java:61)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at com.simontuffs.onejar.Boot.run(Boot.java:306)
            at com.simontuffs.onejar.Boot.main(Boot.java:159)
    正在读取数据,请稍后...
    org.json.JSONException: Expected a ',' or '}' at 319293 [character 319294 line 1]
            at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
            at org.json.JSONObject.<init>(JSONObject.java:227)
            at org.json.JSONTokener.nextValue(JSONTokener.java:363)
            at org.json.JSONArray.<init>(JSONArray.java:116)
            at org.json.JSONTokener.nextValue(JSONTokener.java:366)
            at org.json.JSONObject.<init>(JSONObject.java:212)
            at org.json.JSONTokener.nextValue(JSONTokener.java:363)
            at org.json.JSONObject.<init>(JSONObject.java:212)
            at org.json.JSONObject.<init>(JSONObject.java:314)
            at com.critc.task.HttpRequestUtil.ConvertStream2Json(HttpRequestUtil.java:65)
            at com.critc.task.HttpRequestUtil.getJsonContent(HttpRequestUtil.java:30)
            at com.critc.task.App.main(App.java:49)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at com.simontuffs.onejar.Boot.run(Boot.java:306)
            at com.simontuffs.onejar.Boot.main(Boot.java:159)
    Exception in thread "main" java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at com.simontuffs.onejar.Boot.run(Boot.java:306)
            at com.simontuffs.onejar.Boot.main(Boot.java:159)
    Caused by: java.lang.NullPointerException
            at com.critc.task.HttpRequestUtil.ConvertStream2Json(HttpRequestUtil.java:69)
            at com.critc.task.HttpRequestUtil.getJsonContent(HttpRequestUtil.java:30)
            at com.critc.task.App.main(App.java:49)
            ... 6 more
    
    C:UsersAdministratorDesktop>
    

    解决过程:
    出现这种情况后,在排除了一些可能性后,意识到可能是编码的问题了,不然为什么在 eclipse 中可以,而到 cmd 命令行中就出现错误了。

    最终解决方案:
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));换成指定编码的格式
    BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));

  • 相关阅读:
    《父亲写的散文诗》--许飞
    python 解数独
    github key already in use
    openwrt ddns绑定域名
    hexo 长期后台运行
    修复云服务器rpm无法使用的问题
    vim 取消筛选高亮
    力扣 2021.02.25 最长公共前缀
    [模板]-Manacher
    背包问题回顾
  • 原文地址:https://www.cnblogs.com/hgnulb/p/10059236.html
Copyright © 2011-2022 走看看