https://openhome.cc/Gossip/CodeData/JDK8/Map.html
computeIfAbsent和computeIfPresent使用範例
https://stackoverflow.com/questions/59493461/can-i-use-concurrenthashmap-with-integer-for-thread-safe-counters
Java 6
https://github.com/imrexhuang/HikariCPClientExample/tree/master/ForJava6
Java 8+
https://github.com/imrexhuang/HikariCPClientExample/tree/master/ForJava8%2B
HikariCP
https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby
HikariCP Maven:
https://search.maven.org/search?q=com.zaxxer.hikaricp
作者:Brett Wooldridge
https://github.com/brettwooldridge
作者為何要開發HikariCP的專訪
https://dzone.com/articles/jooq-tuesdays-what-it-takes-to-write-the-fastest-java-connection-pool
利用SQL Server的sp_who指令查看
沒有設定setMinimumIdle和setMaximumPoolSize時,的確預設是建立10個Connection
超過預設10個Connection會出現以下錯誤訊息,無法再用HikariDataSource去getConnection導致timeout:
java.sql.SQLTimeoutException: Timeout after 30004ms of waiting for a connection.
at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:233)
at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:183)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:93)
at HikariCPDataSource.getConnection(HikariCPDataSource.java:33)
at SQLServerPOC.main(SQLServerPOC.java:25)
要處理的XML字串如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans><bean id="AB01"><property name="output"><map><entry><key><value>ID</value></key><value>01</value></entry><entry><key><value>ACNO</value></key><value></value></entry><entry><key><value>AMT</value></key><value></value></entry></map></property></bean></beans>
因為無法使用以下這種javax.xml.xpath的方式處理
XPathExpression expression = xPath.compile("//beans//bean//property[@name='output']");
所以改用org.w3c.dom的方式處理
Element eElement = (Element) nNode;
eElement.getElementsByTagName("entry").item(0).getTextContent());
會抓出ID01,再自己substring處理
雖然可以達到目的,但感覺應該有更好的方式
經網友指點,亦可使用以下方式處理eElement.getElementsByTagName("entry").item(0).getChildNodes().item(0).getTextContent()
=>可以取得ID
eElement.getElementsByTagName("entry").item(0).getChildNodes().item(1).getTextContent()
=>可以取得01
應該也可以使用JAXB,但是沒用過JAXB,不熟
日後再研究
已經確認資料來源編碼沒問題,log也可以正常顯示中文字
但Servlet頁面一直顯示問號???
解決方式:
需在response.getWriter()的之前加入以下設定
response.setContentType("text/html;charset=UTF-8");
如果使用Big5加入
response.setContentType("text/html;charset=Big5");