2017년 9월 27일 수요일

Java Excel Large File Download 엑셀 대용량 다운로드 구현

java excel 다운로드는 apache poi 로 구현 한다.

was 상에서 엑셀을 poi 로 만들때 용량이 크면 jvm 메모리가 플 나게 되어 있다.

최신버전의 poi 는 엑셀을 만들면서 파일로 저장 할 수 있게 지원 하고 있다.

* poi 기본 사용 법 및 파일 생성 예제 -- java 로만 구현
* 엑셀로 저장 할 수 있는 데이터 량 확인
* 대용량 테스트를 위한 데이터베이스 연동
* 테스트 데이터 생성
* 기본 다운로드 구현
* 대용량 다운로드 구현

위 순서로 조금씩 업데이트 해 나가고자 한다.

1. apache poi


* 엑셀 제약의 이해 Ms 공식 문서
  
Total number of rows and columns on a worksheet
1,048,576 rows by 16,384 columns

2017년 9월 12일 화요일

Jsp 서버 아이피 확인

한줄버전
<%
String svrIP = InetAddress.getLocalHost().getHostAddress();
%>



<%@ page language="java" import="java.net.InetAddress" %>
InetAddress inet = InetAddress.getLocalHost();
String svrIP = inet.getHostAddress();


Reference

2017년 9월 7일 목요일

Ssh java send command example jcsh

예제 : http://www.jcraft.com/jsch/examples/Logger.java.html

JSch jsch=new JSch();
Session session=jsch.getSession(remoteHostUserName, RemoteHostName, 22);
session.setPassword(remoteHostpassword);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();

ChannelExec channel=(ChannelExec) session.openChannel("exec");
BufferedReader in=new BufferedReader(new InputStreamReader(channel.getInputStream()));
channel.setCommand("pwd;");
channel.connect();

접속 하니 Algorithm negotiation fail 에러가 뜬다
에러 내용을 더 자세히 보기 위해
com.jcraft.jsch.Logger 를 임플리먼트 해서
Jcsh.setLogger 에 추가 해서 상세 내용을 본다

https://stackoverflow.com/questions/16468475/sending-commands-to-remote-server-through-ssh-by-java-with-jsch






결론은 jce.jar 강제 업데이트

By default, JCE policies -which come with your JDK or JRE- don't support such techniques for ciphering like (ase-256,.. etc).
For sure you MUST replace your current JCE jars (exist on $JAVA_HOME/jre/lib/security) with compatible Jave version you have from oracle website.
  • Download links:
스택 링크 https://stackoverflow.com/questions/17989883/the-cipher-aes256-cbc-is-required-but-it-is-not-available

ㅋㅋㅋ 아직 끝이 아님
UnknownHostKey 에러남https://stackoverflow.com/questions/2003419/com-jcraft-jsch-jschexception-unknownhostkey
java.util.Properties config = new java.util.Properties(); 
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
Aas

Jce 라이센스 내용 쿠바 이란 북한 이 아니어서 괜찮다

Background
From various Sun/Oracle license agreements:
The JCE architecture allows users to enforce restrictions regarding the cryptographic algorithms and maximum cryptographic strengths available to applets/applications in different jurisdiction contexts (locations).
Any such restrictions are specified in “jurisdiction policy files”.
Due to import control restrictions by the governments of a few countries, the jurisdiction policy files shipped specify that “strong” but limited cryptography may be used. An “unlimited strength” version of these files indicating no restrictions on cryptographic strengths is available for those living in eligible countries (which is most countries). But only the “strong” version can be imported into those countries whose governments mandate restrictions. The JCE framework will enforce the restrictions specified in the installed jurisdiction policy files.
Encryption software exports are also governed by the United States Department of Commerce’s Bureau of Industry and Security “Export Administration Regulations” (EARs). For example “15 CFR Supplement No. 1 to Part 740 – Country Groups” Country Group E:1currently lists Cuba, Iran, North Korea, Sudan and Syria as requiring special licenses for encryption software. More here.
The error messages you might get include this one:
ERROR [com.adobe.livecycle.encryption.client.EncryptionServiceException] ALC-ENC-100-019 ACRO_9 compatibility implies 256 bit AES encryption, which requires JCE unlimited strength jurisdiction policy files to be installed on the JVM
https://www.bis.doc.gov/index.php/documents/regulation-docs/452-supplement-no-1-to-part-740-country-groups/file
Korea South 는 A1 임 e1만 제한있음

E1 Country
Cuba Iran Korea, North Sudan  Syria


2017년 9월 6일 수요일

Jsp use out from method

<%!
private void myFunc(String Bits, javax.servlet.jsp.JspWriter myOut)
{  
  try{ myOut.println("<div>"+Bits+"</div>"); } 
  catch(Exception eek) { }
}
%>
...
<%
  myFunc("more difficult than it should be",out);
%>

https://stackoverflow.com/questions/138999/how-to-output-html-from-jsp-block

도스 파일 편집 dos cmd file edit

From a windows command prompt enter copy con followed by the target file name. (copy con c:\file.txt)
Then enter the text you want to put in the file.
End and save the file by pressing CTRL-Z then Enter or F6 then Enter.
If you want to change text in an existing file simply display the text by using the command type followed by the file name and then just copy and paste the text in to the copy con command.



Reference

eclipse rcp dialog resize

  Dialog 안에 메소드를 만든다. private void autoResize(){     getShell().layout( true, true);     final Point newSize = getShell().computeSize...