데이터가 int 형일 경우 null이 면 쥬금
되도록이면 DB에서 constraint 를 사용해 not null을 해주는게 ibatis에는 좋을 듯 하다.

[링크 : http://silver-lining.tistory.com/39]

 

'프로그램 사용 > ibatis & mybatis' 카테고리의 다른 글

ibatis null  (0) 2014.05.29
ibatis 쿼리에 list 타입 인자로 넣기  (0) 2014.05.28
ibatis namespace  (2) 2014.05.22
ibatis2 map  (0) 2014.05.21
ibatis / log4j 를 이용한 sql문 덤프  (0) 2014.05.21
Posted by 구차니
xml을 통해 sql문들을 불러올 키인 'name' 이 중복될 경우 키가 중복된다고
Duplicate <sql>-include ... found 에러가 뜨게 된다.

com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/sql'.  Cause: com.ibatis.sqlmap.client.SqlMapException: Duplicate <sql>-include 'select-all' found.
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
account.joinAction.<init>(joinAction.java:45)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:123)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:154)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:113)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:275)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
 

이런 문제는 namespace를 통해 해결할 수 있으나
namespace를 쓰기 위해서는 ibatis 설정에서 사용이 가능하도록 설정 해주어야 한다.
useStatementNamespaces 는 기본값이 false이다.
Example: useStatementNamespaces=”false”
Default: false (disabled)
 
[링크 : http://ibatis.apache.org/docs/dotnet/datamapper/ch04s03.html


/src/sqlMapConfig.xml

<sqlMapConfig>
<properties resource="/dbconnect.properties" />
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="1" maxSessions="1"
maxTransactions="1" useStatementNamespaces="true" />

<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
</dataSource>
</transactionManager>

<sqlMap resource="/sql/external.xml"/>
</sqlMapConfig> 

/src/sql/external.xml

<sqlMap namespace="user_namespace">
</sqlMap>

[링크 : http://www.okjsp.net/seq/89041]
Posted by 구차니
스트럿츠도 jsp니까.. 기본적으로 포함가능한 방법이 있지만..
<jsp:include
include는 소스가 아닌 결과를 삽입
일반적으로 flush=false로 작업함 

<%@ include
include directive는 소스를 불러옴(차이점 주의!) 

위의 두 가지 방법을 사용해도 action 페이지는 불러올 수 없다.
즉, jsp:include는 제어권을 넘겼다가 받아 오지만 실제 존재하는 경로상의 파일에 접근하는 것이기 때문인데..


아무튼.. s:action 태그를 이용하여 include 하 듯 불러올 수는 있다.

<s:action name="myAction"  ignoreContextParams="true" executeResult="true">
        <s:param name="foo" value="bar"/>
</s:action> 
[링크 : http://ssongka.egloos.com/2371453]
[링크 :
http://stackoverflow.com/questions/374099/struts2-parameters-between-actions

+
원래는 스트럿츠에서 타일스에 연동하는 경우
타일스 에서 스트럿츠 페이지를 다시 불러 끼워 넣으려고 한건데..
걍 타일스를 드러내는게 나을듯 해졌다 -_-a
느리기도 느리지만.. 제대로 안되는 것 봐서는 스트럿츠->타일스->스트럿츠 순으로 호출되는거라 정상적인 건 아닐듯.. 


---
2014.05.23 추가

<s:action name="myAction"  flush="true" ignoreContextParams="true" executeResult="true">
        <s:param name="foo" value="bar"/>
</s:action> 


flush를 안해줘서 안된듯 -_-
결론은 된다 
Posted by 구차니
스트럿츠에서 메소드를 통해 타일즈 레이아웃을 변경시킬수 있으나..
내가 의도했던 것과는 달라서 일단 봉인 -_-a

[링크 : http://syaku.tistory.com/174]
Posted by 구차니

'프로그램 사용 > struts2 tiles' 카테고리의 다른 글

struts2 페이지 포함하기  (0) 2014.05.22
스트럿츠 동적 레이아웃 구성하기  (0) 2014.05.22
struts2 result type input  (0) 2014.05.19
struts2 result type  (0) 2014.05.17
struts2 / tiles 연동시 에러  (0) 2014.05.16
Posted by 구차니
일반적인 상황에서는 ibatis2를 통해 인자를 하나만 넘겨줄수 있는데
2개 이상 필요할 경우에는 DAO를 통해 클래스로 넘기거나
Map 객체를 통해 여러개의 값을 넘겨줄 수 있다.

[링크 : http://okjsp.net/bbs?seq=206384]
[링크 : http://masachi.tistory.com/258]
Posted by 구차니
ibatis의 단점(?)아닌 단점으로는
실제로 값이 넘어가는지 알기가 어렵다는 점인데..
log4j를 이용하여 로그로 콘솔을 통해 디버깅이 용이하도록
SQL 문 자체를 출력할 수 있다.

DEBUG [http-8080-3] -Created connection 1249656.
DEBUG [http-8080-3] -{conn-100000} Connection
DEBUG [http-8080-3] -{conn-100000} Preparing Statement:       SELECT * FROM SBOARD2      WHERE boardId = ? ORDER BY ref DESC, re_step ASC  
DEBUG [http-8080-3] -{pstm-100001} Executing Statement:       SELECT * FROM SBOARD2      WHERE boardId = ? ORDER BY ref DESC, re_step ASC  
DEBUG [http-8080-3] -{pstm-100001} Parameters: [null]
DEBUG [http-8080-3] -{pstm-100001} Types: [null]
DEBUG [http-8080-3] -{rset-100002} ResultSet
DEBUG [http-8080-3] -Returned connection 1249656 to pool. 

 # Global logging configuration
log4j.rootLogger=ERROR, stdout

# SqlMap logging configuration
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.BasicDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG

log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG

# Console output
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] -%m%n

[링크 : http://northface.tistory.com/15]
[링크 : http://www.apache.org/dyn/closer.cgi/logging/log4j/1.2.17/log4j-1.2.17.zip]

'프로그램 사용 > ibatis & mybatis' 카테고리의 다른 글

ibatis 쿼리에 list 타입 인자로 넣기  (0) 2014.05.28
ibatis / mybatis 데이터가 비어있는 경우(null)  (0) 2014.05.23
ibatis namespace  (2) 2014.05.22
ibatis2 map  (0) 2014.05.21
ibatis - db framework  (0) 2014.05.14
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 23:32
오라클에는 varchar2 라는 타입을 주로 사용하지만
이녀석은 char[] 로 1바이트 문자열을 최대 4000 byte까지 저장할 수 있다.
물론 4000 바이트라는건 최대 선언 가능한 길이일뿐
varcahr2 타입으로 선언한다고 해서 가변으로 0~4000자를 입력할수 있는건 아니다.
(이렇게 자동으로 길이 해주면 얼마나 좋았을까 -_-)

아무튼 요즘은 바야흐로(?) 유니코드 시대이기에 문자열 역시 유니코드로 저장하게 되는데
DB에서도 varchar2와 같이 1byte 문자열이 아닌 2byte 문자열(UTF-8 / UTF-16)을 지원해야 하고
이녀석은 nvarchar2로 N이 하나 더 붙게 된다.


VARCHAR2 and VARCHAR Datatypes

The VARCHAR2 datatype stores variable-length character strings. When you create a table with a VARCHAR2 column, you specify a maximum string length (in bytes or characters) between 1 and 4000 bytes for the VARCHAR2 column. For each row, Oracle stores each value in the column as a variable-length field unless a value exceeds the column's maximum length, in which case Oracle returns an error. Using VARCHAR2 and VARCHAR saves on space used by the table.

For example, assume you declare a column VARCHAR2 with a maximum size of 50 characters. In a single-byte character set, if only 10 characters are given for the VARCHAR2 column value in a particular row, the column in the row's row piece stores only the 10 characters (10 bytes), not 50.

Oracle compares VARCHAR2 values using nonpadded comparison semantics.


NCHAR and NVARCHAR2 Datatypes

NCHAR and NVARCHAR2 are Unicode datatypes that store Unicode character data. The character set of NCHAR and NVARCHAR2 datatypes can only be either AL16UTF16 or UTF8 and is specified at database creation time as the national character set. AL16UTF16 and UTF8 are both Unicode encoding.

The NCHAR datatype stores fixed-length character strings that correspond to the national character set.

The NVARCHAR2 datatype stores variable length character strings.

When you create a table with an NCHAR or NVARCHAR2 column, the maximum size specified is always in character length semantics. Character length semantics is the default and only length semantics for NCHAR or NVARCHAR2.

For example, if national character set is UTF8, then the following statement defines the maximum byte length of 90 bytes:

CREATE TABLE tab1 (col1 NCHAR(30));

This statement creates a column with maximum character length of 30. The maximum byte length is the multiple of the maximum character length and the maximum number of bytes in each character. 
[링크 : http://docs.oracle.com/cd/B19306_01/server.102/b14220/datatype.htm

If you prefer to implement Unicode support incrementally, or if you need to support multilingual data only in certain columns, then you can store Unicode data in either the UTF-16 or UTF-8 encoding form in SQL NCHAR datatypes (NCHAR, NVARCHAR2, and NCLOB). The SQL NCHAR datatypes are called Unicode datatypes because they are used only for storing Unicode data.

[링크 : http://docs.oracle.com/cd/B28359_01/server.111/b28298/ch6unicode.htm]

'프로그램 사용 > oracle' 카테고리의 다른 글

sql distinct  (0) 2014.05.29
oracle 대소문자 구분없이 검색하기  (0) 2014.05.28
oracle view  (0) 2014.05.20
oracle alter  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 16:08
view는 일종의 select sql 문을 저장해 두는 기능을 한다.

CREATE VIEW locations_view AS
   SELECT d.department_id, d.department_name, l.location_id, l.city
   FROM departments d, locations l
   WHERE d.location_id = l.location_id;

SELECT column_name, updatable 
   FROM user_updatable_columns
   WHERE table_name = 'LOCATIONS_VIEW';
 
[링크 : http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_8004.htm

어떻게 보면.. 게시판 소스에서 많이 보게 되는 서브쿼리 혹은 중첩쿼리의 기능인데
subquery / inline view 라고도 부르며 이녀석 역시 일종의 view 인 것이었다!!

Inline 뷰
인라인 뷰는 FROM 절에서 서브쿼리를 사용하여 생성한 임시 뷰이다. 인라인 뷰는 SQL 문이 실행되는 동안만 임시적으로 정의된다.
 
[링크 : http://radiocom.kunsan.ac.kr/lecture/oracle/what_is/view.html

[링크 : http://zetswing.com/bbs/board.php?bo_table=ORACLE_TIP&wr_id=9&page=2


+
mysql에서 view는 5.0.x 부터 지원한다.
[링크 : http://dev.mysql.com/doc/refman/5.0/en/views.html]

'프로그램 사용 > oracle' 카테고리의 다른 글

oracle 대소문자 구분없이 검색하기  (0) 2014.05.28
oracle 타입 - nvarchar2 varchar2  (0) 2014.05.20
oracle alter  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
오라클 DDL 정리  (0) 2014.05.11
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 15:43
변경시에는 추가된 값이 있으면 안되는 경우도 있으니(date -> varchar2)
주의해서 사용해야 할 듯...

alter table tablename add (colname type ..) // 항목 추가하기
alter table tablename drop column // 항목 삭제하기
alter table tablename modify (colname newtype ..) // 변수형 바꾸기
alter table tablename rename column oldname to newname // 항목명 바꾸기(9iR2 이후) 

[링크 : http://majesty76.tistory.com/27]


'프로그램 사용 > oracle' 카테고리의 다른 글

oracle 타입 - nvarchar2 varchar2  (0) 2014.05.20
oracle view  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
오라클 DDL 정리  (0) 2014.05.11
오라클 10g용 시작/종료 스크립트  (0) 2014.04.11
Posted by 구차니