728x90

출처 : android.os.NetworkOnMainThreadException 예외가 발생했을 경우
android.os.NetworkOnMainThreadException
http://aroundck.tistory.com/1240

사용예

        if(android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        
        String test;
		try {
			test = HttpCallUtils.call("aaa", "bbb");
			System.out.println("test = " + test);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

HttpCallUtils

package com.test;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;

public class HttpCallUtils {

	private static String url = "https://test.com/login_check.php";
	private static String key_user = "mb_id";
	private static String key_password = "mb_password";	
	
	/*
	public static void main(String[] args) throws Exception {
		String test = HttpCallUtils.call("aaa", "bbb");
		System.out.println("test = " + test);
	}
	*/
	
	public static String call(String parma1, String param2) throws Exception {
		
		HttpClient client = new DefaultHttpClient();
		HttpPost post = new HttpPost(url);

		HttpParams params = client.getParams();
		params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
		params.setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(15000));
		params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(15000));

		ArrayList<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
		nameValuePairs.add(new BasicNameValuePair(key_user, parma1));
		nameValuePairs.add(new BasicNameValuePair(key_password, param2));
		UrlEncodedFormEntity entityRequest = new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
		post.setEntity(entityRequest);
		
		//
		HttpResponse response = client.execute(post);
		
		StringBuffer sb = new StringBuffer();

		// Examine the response status
		System.out.println(response.getStatusLine());

		// Get hold of the response entity
		HttpEntity entity = response.getEntity();

		// If the response does not enclose an entity, there is no need
		// to worry about connection release
		if (entity != null) {
			InputStream instream = entity.getContent();
			try {
				BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
				// do something useful with the response
				String line;
				while ((line = reader.readLine()) != null)
					sb.append(line+"\n");
			} catch (Exception ex) {
				ex.printStackTrace();
			} finally {
				instream.close();
			}
		}	
		return sb.toString();
	}	
}

 

728x90
728x90

출처 : IE, FF 설치된 ActiveX 수동 삭제 방법

1. 모든 IE 브라이저 종료

2. 관리자 권한으로 [명령 프롬프트] 실행

3. Windows 폴더로 이동

cd c:\windows

4. 삭제하고 싶은 ActiveX 검색
- dir 명령의 서브디렉토리 검색(/s) 옵션으로 검색

dir/s ActiveX파일명

5. 해당 폴더로 이동

cd c:\Windows\Downloaded Program Files

6. ActiveX 등록 해제 하기
- regsvr32 명령dml 해제 옵션(/u) 으로 ActiveX 해제

regsvr32 /u VoiceRec.ocx

해제 성공 메시지 확인 가능

7. ActiveX 파일 삭제

del VoiceRec.ocx

728x90
728x90

출처 : Passing Arrays between Java and Oracle Procedures
how to call procedure with out parameter as table type from a java class
Oracle procedure 'out' 'table of varchar2' type parameter
Oracle stored procedure using array as parameter for table insert
Jdbc array binding: character set encoding
Oracle Database 11g Release 2 JDBC Drivers

주의사항

1. Spring을 사용하는 경우 OracleConnection을 가지고 오기 위해서 <property name="accessToUnderlyingConnectionAllowed" value="true"/>

2. 인코딩 문제로 varchar2의 경우 orai18n.jar를 추가 해야 됨

oracle 배열 타입 생성

CREATE OR REPLACE TYPE ARRAY_V AS TABLE OF VARCHAR2(512);

oracle procedure

CREATE OR REPLACE PACKAGE XXX.PKG_TEST AS

  PROCEDURE SP_TERMINAL_SELECT
  ( 
    IN_TERMINAL_MAC  IN  ARRAY_V,
    OUT_TERMINAL_IP  OUT ARRAY_V   
  );

END PKG_TEST;
/

CREATE OR REPLACE PACKAGE BODY XXX.PKG_TEST IS

  PROCEDURE SP_TERMINAL_SELECT
  ( 
    IN_TERMINAL_MAC  IN  ARRAY_V,
    OUT_TERMINAL_IP  OUT ARRAY_V   
  ) IS
  BEGIN
    -- need to initialize the collection or it will fail if it is used
    OUT_TERMINAL_IP := ARRAY_V();
  
    FOR i IN 1 .. IN_TERMINAL_MAC.COUNT LOOP
    
        OUT_TERMINAL_IP.extend(1);
        
        SELECT TERMINAL_IP INTO OUT_TERMINAL_IP(i) 
          FROM TERMINAL
         WHERE TERMINAL_MAC = IN_TERMINAL_MAC(i); 
        
    END LOOP;
  
  END SP_TERMINAL_SELECT;

END PKG_TEST;
/

java 소스

package test;

import java.sql.Connection;
import java.sql.SQLException;

import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

import org.apache.commons.dbcp.DelegatingConnection;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import test.util.ConnectionManager;

public class SelectTerminal {
	
	public static ApplicationContext context;
	
	public static void main(String[] args) throws Exception {
		
		System.out.println("test");
        String[] configLocation = new String[] { "file:WebContent/WEB-INF/test-servlet.xml" };
        context = new ClassPathXmlApplicationContext(configLocation);
		
		Connection conn = null;
		try {
			conn = ConnectionManager.getConnection();

			//
			Connection oraConn = ((DelegatingConnection)conn).getDelegate();
			if ((oraConn instanceof DelegatingConnection) && !(oraConn instanceof oracle.jdbc.OracleConnection)) {
				oraConn = ((DelegatingConnection)oraConn).getDelegate();
			}
			
			// Create descriptors for each Oracle collection type required
			// CREATE OR REPLACE ARRAY_V AS TABLE OF VARCHAR2(512); 
			ArrayDescriptor oracleVarchar2Collection = ArrayDescriptor.createDescriptor("ARRAY_V", oraConn);

	        // JAVA arrays to hold the data.
	        String[] terminal_mac_array    = { "08:xx:xx:xx:xx:xx", "00:xx:xx:xx:xx:xx" };
	        ARRAY ora_terminal_mac    = new ARRAY(oracleVarchar2Collection, oraConn, terminal_mac_array);
	
	        show_array_info(ora_terminal_mac);
	        
	        // Bind the input arrays.
			OracleCallableStatement stmt = 
	        	(OracleCallableStatement) oraConn.prepareCall("{ call PKG_TEST.SP_TERMINAL_SELECT(?,?) }");	        

	        stmt.setArray(1, ora_terminal_mac);
	        stmt.registerOutParameter(2, OracleTypes.ARRAY, "ARRAY_V");
	        stmt.execute();

	        //
	        ARRAY ora_terminal_ip = stmt.getARRAY(2);
	        if (ora_terminal_ip!=null) {
	        	String[] terminal_ip_array = (String[])ora_terminal_ip.getArray();
	        	for (int i=0; i<terminal_ip_array.length; i++) {
	        		System.out.println(i + " / terminal_ip = " + terminal_ip_array[i]);
	        	}
	        }	        

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn!=null) try { conn.close(); } catch (SQLException e) { }
		}        
	}
	
	private static void show_array_info(oracle.sql.ARRAY p_in) throws SQLException {

		System.out.println("Array is of type      " + p_in.getSQLTypeName());
		System.out.println("Array is of type code " + p_in.getBaseType());
		System.out.println("Array is of length    " + p_in.length());

		String[] values = (String[]) p_in.getArray();

		for (int i = 0; i < p_in.length(); i++)
			System.out.println("p_in[" + i + "] = " + values[i]);
	}

}

결과

Array is of type      XXX.ARRAY_V
Array is of type code 12
Array is of length    2
p_in[0] = 08:xx:xx:xx:xx:xx
p_in[1] = 00:xx:xx:xx:xx:xx
0 / terminal_ip = 192.168.0.2
1 / terminal_ip = 192.168.0.3
728x90
728x90

출처 : 안드로이드 c/c++ 개발환경 구축

Mac 환경에서 make-standalone-toolchain.sh 로 toolchain 사용해서 openssl 컴파일 해보았습니다.

컴파일 버전

openssl-1.0.1e.tar.gz

환경

Makefile 수정

추가

CROSS  = $(TOOLCHAIN)/bin/arm-linux-androideabi-
INCDIR = $(TOOLCHAIN)/sysroot/usr/include
LIBDIR = $(TOOLCHAIN)/sysroot/usr/lib

수정

CC= $(CROSS)gcc
AR= $(CROSS)ar $(ARFLAGS) r
RANLIB= $(CROSS)ranlib
NM= $(CROSS)nm

결과

테스트

Makefile

Makefile

-----------------------

libjson 파일컴파일

추가

CROSS  = $(TOOLCHAIN)/bin/arm-linux-androideabi-
INCDIR = $(TOOLCHAIN)/sysroot/usr/include
LIBDIR = $(TOOLCHAIN)/sysroot/usr/lib

수정

# Variables
prefix          = $(TOOLCHAIN)/sysroot/usr
exec_prefix     = $(prefix)
libdir          = lib
includedir      = include
srcdir          = _internal/Source
CXX             = $(CROSS)c++
AR              = $(CROSS)ar
PIC             = PIC
BUILD_TYPE      = "default"

728x90
728x90
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

public class HttpGetCall {

	public static void main(String[] args) throws Exception {
		URL url = new URL("http://naver.com");
		InputStream is = url.openStream();

		BufferedReader inFile = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while( (line = inFile.readLine()) != null ) {
            System.out.println(line);
        }
		is.close();
	}
}
728x90
728x90

Delphi - Byte 관련 Tip

function BytesToHex(aSource: TBytes): string;
begin
  SetLength(Result, Length(aSource) * 2);
  if Length(aSource) > 0 then
    BinToHex(aSource[0], PChar(Result), Length(aSource));
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  SetupLdrExeHeaderOffset = $01d204;
  A: Array[0..3] of Byte = ($EF, $BE, $AD, $DE);
var
  HInstance: THandle;
  filename: String;
  FileStream: TFileStream;
  ArrayBytesHeader, ArrayBytesHeaderStr : TBytes;
  HeaderStr : String;
begin
  // AbZipper1.FileName := 'C:\AAPlus4PC_server\ALZip861.exe';
  filename := 'C:\AAPlus4PC_server\ALZip861.exe';

  FileStream := TFileStream.Create(filename, fmOpenRead);
  try

    FileStream.Seek( SetupLdrExeHeaderOffset , soBeginning);

    SetLength( ArrayBytesHeader, 16 );
    FileStream.ReadBuffer(ArrayBytesHeader, 16);

    if (CompareMem(ArrayBytesHeader, @A, 4)) then begin
      SetLength(ArrayBytesHeaderStr, 12);
      CopyMemory( ArrayBytesHeaderStr, @ArrayBytesHeader[4], 12  );

      HeaderStr := TEncoding.ASCII.GetString(ArrayBytesHeaderStr);
      //Memo1.Lines.Add( BytesToHex(ArrayBytesHeader) );
      //Memo1.Lines.Add( BytesToHex(ArrayBytesHeaderStr) + '/' + HeaderStr );

      if HeaderStr='NullsoftInst' then begin
        Memo1.Lines.Add( 'ooooo' );
      end else begin
        Memo1.Lines.Add( 'xxxxx - 2' );
      end;

    end else begin
      Memo1.Lines.Add( 'xxxxx - 1' );
    end;
  finally
    SetLength(ArrayBytesHeader, 0);
    SetLength(ArrayBytesHeaderStr, 0);
    FileStream.Free;
  end;
end;
728x90
728x90

출처 : NT Service로 기동할때 톰캣메모리설정

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tomcat7\Parameters

"JVM Option Number 4"="-Xms512m"
"JVM Option Number 5"="-Xmx1024m" 

728x90
728x90

D7 for Delphi 7
D9 for Delphi 2005
D10 for Delphi 2006
D11 for Delphi 2007
D12 for Delphi 2009
D14 for Delphi 2010
D15 for Delphi XE
D16 for Delphi XE2
D17 for Delphi XE3

728x90

+ Recent posts