본문 바로가기

프로그램312

[Java] MSSQL 과 Java 연동 1. SQL Server 2005 클래스 경로 : com.microsoft.jdbc.sqlserver.SQLServerDriver 데이터베이스 : jdbc.microsoft.sqlserver://localhost:1433:database=webhr…2. SQL Server 2000 클래스 경로 : com.microsoft.sqlserver.jdbc.SQLServerDriver 데이터베이스 : jdbc.sqlserver://localhost:1433:database=webhr 2013. 11. 15.
[Java] GET 방식으로 전달된 한글 깨짐현상 jsp 에서 get 방식으로 데이터를 전달할때, 한글이 깨지는 현상이 발생하곤 한다. 이때, 해결 방법은 전달전에 엔코딩을 해서 전달 한 후에 jsp 에서 디코딩을 해서 사용하는 것이다.… Javascript 에서 다음과 같이 엔코딩 해서 한글을 넘긴다. location.href = “test.jsp?name=” + encodeURI(“한글나라”, “UTF-8″);… JSP 에서 다음과 같이 디코딩해서 사용한다. String name = java.net.URLDecoder.decode(request.getParameter(“name”), “UTF-8″); 2013. 11. 15.
[Java] Base64로 encoding된 파일을 decoding 해서 저장하기 이전 Article “HTTP POST 로 타서버로 파일 전송” 에서 전달된 Base64 로 encoding 된 파일을 받아서 decoding 하는 예제이다.… import org.apache.commons.codec.binary.Base64OutputStream;… stream = formFile.getInputStream(); // Base64로 encoding 된 파일 OutputStream bos = new Base64OutputStream(new FileOutputStream(“저장경로를 갖는 파일명”), false); int bytesRead = 0; byte[] buffer = new byte[8192]; while ((bytesRead = stream.read(buffer, 0, 8192).. 2013. 11. 15.
[Java] Url -> XML Document 객체 구글날씨 정보(XML)를 읽어와서 Document객체를 만든다.…… InputStreamReader isr = null; try{ //구글 날씨 정보 URL url = new URL(“http://www.google.co.kr/ig/api?hl=ko&weather=seoul”); isr = new InputStreamReader(url.openStream(), “euc-kr”); //XML 읽어오기 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new InputSource(isr)); … }catch(Exc.. 2013. 11. 15.
[PhoneGap] Plugin 에서 핸드폰 번호 가져오기 사이트에 알려진 내용으로 했을 때, NullPointException 에러가 나서 해결을 못하다고 우연히 다음과 같은 코드를 발견해서 해결했다. … TelephonyManager tm = null; tm = (TelephonyManager)this.ctx.getSystemService(Context.TELEPHONY_SERVICE); result = tm.getLine1Number(); … 위 코드는 검색하면 흔히 볼 수 있는 코드 인데, 올리는 사람에 따라, 붉은색 코드가 다르다. 이유는 아직 모르겠지만 다른 방법은 안되지만, 위와 같이 하면 디바이스의 전화번호를 정확히 가져온다. … Plugin 을 만드는 과정은 생략. 사이트 찾아보면 너무 많으니까 ^^; 2013. 11. 14.
[Java] Host IP 및 이름 알아내기 로컬 호스트의 IP 및 호스트명을 가져온다. … InetAddress addr = InetAddress.getLocalHost(); String strIP = addr.getHostAddress(); String strHostName = addr.getHostName(); … System.out.println(“IP : ” + strIP); System.out.println(“HOST : ” + strHostName); 2013. 11. 14.
[Appspresso] Unable to resolve target ‘android-7′ 오류 BUILD FAILED D:\Appspresso1.1.1\plugins\com.appspresso.cli_1.0.0.201205071744\axhome\build-axp.xml:290: The following error occurred while executing this line: D:\Appspresso1.1.1\plugins\com.appspresso.cli_1.0.0.201205071744\axhome\platforms\android\build-axp.xml:82: The following error occurred while executing this line: d:\Appspresso1.1.1\android-sdk-windows\tools\ant\build.xml:470: Unable to .. 2013. 11. 14.