gnu.caf.db.impl
Class SqlUtilOracle

java.lang.Object
  extended by gnu.caf.db.impl.SqlUtilOracle
All Implemented Interfaces:
SqlUtil
Direct Known Subclasses:
DBManager2Oracle

public class SqlUtilOracle
extends java.lang.Object
implements SqlUtil

SqlUtil 의 Oracle 구현 클래스임.

Since:
1.0
Author:
이호성
See Also:
SqlUtil

Field Summary
protected  boolean bDEBUG
           
protected  java.sql.Connection connection
           
protected  javax.sql.DataSource dataSource
           
protected  boolean isAutoCommit
           
protected  java.lang.String jndiDataSourceName
           
protected  RowCallbackHandler rowCallbackHandler
           
protected  int transaction
           
 
Constructor Summary
SqlUtilOracle()
           
 
Method Summary
 void clearParams(java.util.ArrayList params)
           
 void close()
          close 처리를 함.
 void commit()
          commit 처리를 함.
 java.lang.String executeQueryForFixedSequenceString(java.lang.String sql, int fixedLength)
          고정길이의 seq을 가져옴.
 java.lang.String executeQueryForFixedSequenceString(java.lang.String sql, java.lang.Object[] params, int fixedLength)
          고정길이의 seq를 가져옴.
 int executeQueryForInt(java.lang.String sql)
          sql에 해당하는 int 를 반환함.
 int executeQueryForInt(java.lang.String sql, java.lang.Object[] params)
          sql에 해당하는 int 를 반환함.
 java.util.List executeQueryForList(java.lang.String sql)
          sql에 해당하는 List 를 반환함.
 java.util.List executeQueryForList(java.lang.String sql, java.lang.Object[] params)
          sql에 해당하는 List객체를 반환함.
 java.util.List executeQueryForList(java.lang.String sql, java.lang.Object[] params, int startRow, int maxRows)
          sql에 해당하는 List객체를 반환함.
 java.util.Map executeQueryForMap(java.lang.String sql)
          sql에 해당하는 Map객체를 반환함.
 java.util.Map executeQueryForMap(java.lang.String sql, java.lang.Object[] params)
          sql에 해당하는 Map객체를 반환함.
 PagingList executeQueryForPagingList(java.lang.String sql, int pageNo, int pageSize)
          sql에 해당하는 PagingList 객체를 반환함.
 PagingList executeQueryForPagingList(java.lang.String sql, java.lang.Object[] params, int pageNo, int pageSize)
          sql에 해당하는 PagingList 객체를 반환함.
 int executeUpdate(java.lang.String sql)
          sql를 실행함.
 int executeUpdate(java.lang.String query, java.lang.Object[] params)
          sql를 실행함.
 void executeUpdateClob(java.lang.String sql, java.lang.Object[] params, java.lang.String clobData)
          Clob 데이타를 갱싱을 위해서 사용함.
 void executeUpdateClob(java.lang.String sql, java.lang.String clobData)
          Clob 데이타를 갱신을 위해서 사용함.
 int executeUpdateNCHAR(java.lang.String sql, java.lang.Object[] params)
          다국어 처리를 위하여 사용함.
protected  void finalize()
           
 boolean getAutoCommit()
           
 java.sql.Connection getConnection()
           설정된 connection 을 가져옴.
 java.sql.Connection getConnection(java.lang.String jndiDataSourceName)
          JNDI 에 등록된 dataSource의 connection을 가져옴.
 java.sql.Connection getConnection(java.lang.String className, java.lang.String url, java.lang.String username, java.lang.String password)
          Connection을 직접 설정할 때 사용함.
 javax.sql.DataSource getDataSource()
          dataSource를 반환함.
 java.lang.String getJndiDataSourceName()
          JNDI DataSurceName 을 반환함.
 RowCallbackHandler getRowCallbackHandler()
          java.sql.ResultSet 객체를 처리시 사용할 handler객체를 반환함.
 boolean isDebug()
           
static java.util.Properties loadParams(java.lang.String file)
          This method reads the properties file:Connection.properties which is passed as the parameter to it and load it into a java Properties object and returns it.
static void main(java.lang.String[] args)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql)
           
 void rollback()
          rollback 처리를 함.
 void setAutoCommit(boolean autocommit)
          트랜잭션 처리를 위해 autoCommit 설정을 함.
 void setConnection(java.sql.Connection connection)
          sqlUtil 에서 사용할 connection을 설정함.
 void setDataSource(javax.sql.DataSource dataSource)
          dataSource를 설정함.
 void setDebug(boolean b)
           
 void setJndiDataSourceName(java.lang.String jndiDataSourceName)
          JNDI DataSourceName 을 설정함.
 void setRowCallbackHandler(RowCallbackHandler rowCallbackHandler)
          java.sql.ResultSet 객체를 처리시 사용할 handler객체를 설정함.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bDEBUG

protected boolean bDEBUG

isAutoCommit

protected boolean isAutoCommit

transaction

protected int transaction

connection

protected java.sql.Connection connection

dataSource

protected javax.sql.DataSource dataSource

jndiDataSourceName

protected java.lang.String jndiDataSourceName

rowCallbackHandler

protected RowCallbackHandler rowCallbackHandler
Constructor Detail

SqlUtilOracle

public SqlUtilOracle()
Method Detail

setDebug

public void setDebug(boolean b)

isDebug

public boolean isDebug()

getConnection

public java.sql.Connection getConnection(java.lang.String className,
                                         java.lang.String url,
                                         java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Connection을 직접 설정할 때 사용함.

Specified by:
getConnection in interface SqlUtil
Parameters:
className -
url -
username -
password -
Returns:
Connection
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

설정된 connection 을 가져옴.

Connection 객체를 반환하는 기준은 dataSource, connection 기준으로 connection을 가져온다. dataSource 가 설정되어있는 경우에는 dataSource에 해당하는 connection을 반환함.

Specified by:
getConnection in interface SqlUtil
Returns:
Connection
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String jndiDataSourceName)
                                  throws java.sql.SQLException
JNDI 에 등록된 dataSource의 connection을 가져옴.

Specified by:
getConnection in interface SqlUtil
Parameters:
jndiDataSourceName -
Returns:
Connection
Throws:
java.sql.SQLException

main

public static void main(java.lang.String[] args)

executeUpdateClob

public void executeUpdateClob(java.lang.String sql,
                              java.lang.String clobData)
                       throws java.sql.SQLException
Clob 데이타를 갱신을 위해서 사용함. 한개컬럼에 대하여만 사용함.

Specified by:
executeUpdateClob in interface SqlUtil
Parameters:
sql -
clobData -
Throws:
java.sql.SQLException
java.io.IOException

executeUpdateClob

public void executeUpdateClob(java.lang.String sql,
                              java.lang.Object[] params,
                              java.lang.String clobData)
                       throws java.sql.SQLException
Clob 데이타를 갱싱을 위해서 사용함.

Specified by:
executeUpdateClob in interface SqlUtil
Parameters:
sql -
params -
clobData -
Throws:
java.sql.SQLException
java.io.IOException

executeQueryForFixedSequenceString

public java.lang.String executeQueryForFixedSequenceString(java.lang.String sql,
                                                           int fixedLength)
                                                    throws java.sql.SQLException
고정길이의 seq을 가져옴.

Specified by:
executeQueryForFixedSequenceString in interface SqlUtil
Parameters:
sql -
fixedLength - 고정문자열길이
Returns:
String
Throws:
java.sql.SQLException

executeQueryForFixedSequenceString

public java.lang.String executeQueryForFixedSequenceString(java.lang.String sql,
                                                           java.lang.Object[] params,
                                                           int fixedLength)
                                                    throws java.sql.SQLException
고정길이의 seq를 가져옴.

Specified by:
executeQueryForFixedSequenceString in interface SqlUtil
Parameters:
sql -
params -
fixedLength -
Returns:
String
Throws:
java.sql.SQLException

executeQueryForInt

public int executeQueryForInt(java.lang.String sql)
                       throws java.sql.SQLException
sql에 해당하는 int 를 반환함. 카운트 계산을 위해서 사용함.

Specified by:
executeQueryForInt in interface SqlUtil
Parameters:
sql -
Returns:
int
Throws:
java.sql.SQLException

executeQueryForInt

public int executeQueryForInt(java.lang.String sql,
                              java.lang.Object[] params)
                       throws java.sql.SQLException
sql에 해당하는 int 를 반환함. 카운트 계산을 위해서 사용함.

Specified by:
executeQueryForInt in interface SqlUtil
Parameters:
sql -
params -
Returns:
int
Throws:
java.sql.SQLException

executeQueryForMap

public java.util.Map executeQueryForMap(java.lang.String sql)
                                 throws java.sql.SQLException
sql에 해당하는 Map객체를 반환함. 한개데이타를 반환하는 경우사용함.

Specified by:
executeQueryForMap in interface SqlUtil
Parameters:
sql -
Returns:
Map
Throws:
java.sql.SQLException

executeQueryForMap

public java.util.Map executeQueryForMap(java.lang.String sql,
                                        java.lang.Object[] params)
                                 throws java.sql.SQLException
sql에 해당하는 Map객체를 반환함. 한개데이타를 반환하는 경우사용함.

Specified by:
executeQueryForMap in interface SqlUtil
Parameters:
sql -
params -
Returns:
Map
Throws:
java.sql.SQLException

executeQueryForList

public java.util.List executeQueryForList(java.lang.String sql,
                                          java.lang.Object[] params)
                                   throws java.sql.SQLException
sql에 해당하는 List객체를 반환함. 여러개의 데이타를 반환하는 경우사용함.

Specified by:
executeQueryForList in interface SqlUtil
Parameters:
sql -
params -
Returns:
List
Throws:
java.sql.SQLException

executeQueryForList

public java.util.List executeQueryForList(java.lang.String sql,
                                          java.lang.Object[] params,
                                          int startRow,
                                          int maxRows)
                                   throws java.sql.SQLException
sql에 해당하는 List객체를 반환함.
int min = ((int) (pageNo - 0.1) / groupSize) * groupSize * pageSize + 1;
페이지번호기준으로 실행하려면.. min = startRow, maxRows = pageSize

Specified by:
executeQueryForList in interface SqlUtil
Parameters:
sql -
params -
startRow - rs.next() 를 실행하는 횟수...
maxRows - 최대가져오는 행의 갯수.
Returns:
List
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String query,
                         java.lang.Object[] params)
                  throws java.sql.SQLException
sql를 실행함.

Specified by:
executeUpdate in interface SqlUtil
Parameters:
query -
params -
Returns:
int
Throws:
java.sql.SQLException

executeUpdateNCHAR

public int executeUpdateNCHAR(java.lang.String sql,
                              java.lang.Object[] params)
                       throws java.sql.SQLException
다국어 처리를 위하여 사용함. Oracle datatype 이 NCHAR, NVARCHAR 인 경우에 사용함.

Specified by:
executeUpdateNCHAR in interface SqlUtil
Parameters:
sql -
params -
Returns:
int
Throws:
java.sql.SQLException

executeQueryForPagingList

public PagingList executeQueryForPagingList(java.lang.String sql,
                                            java.lang.Object[] params,
                                            int pageNo,
                                            int pageSize)
                                     throws java.sql.SQLException
sql에 해당하는 PagingList 객체를 반환함. 페이징처리시 해당페이지의 리스트를 가져옴. 처리시 전체 카운트와 해당페이지의 리스트객체를 반환함. PagingList paginglist = executeQueryForPagingList(sql, params, 1, 10); int totalCount = paginglist.getTotalCount(); List list = paginglist.getList();

Specified by:
executeQueryForPagingList in interface SqlUtil
Parameters:
sql -
params -
pageNo -
pageSize -
Returns:
PagingList
Throws:
java.sql.SQLException

clearParams

public void clearParams(java.util.ArrayList params)
Specified by:
clearParams in interface SqlUtil

executeQueryForPagingList

public PagingList executeQueryForPagingList(java.lang.String sql,
                                            int pageNo,
                                            int pageSize)
                                     throws java.sql.SQLException
sql에 해당하는 PagingList 객체를 반환함. 페이징처리시 해당페이지의 리스트를 가져옴. 처리시 전체 카운트와 해당페이지의 리스트객체를 반환함. PagingList paginglist = executeQueryForPagingList(sql, params, 1, 10); int totalCount = paginglist.getTotalCount(); List list = paginglist.getList();

Specified by:
executeQueryForPagingList in interface SqlUtil
Parameters:
sql -
pageNo -
pageSize -
Returns:
PagingList
Throws:
java.sql.SQLException

executeQueryForList

public java.util.List executeQueryForList(java.lang.String sql)
                                   throws java.sql.SQLException
sql에 해당하는 List 를 반환함.

Specified by:
executeQueryForList in interface SqlUtil
Parameters:
sql -
Returns:
List
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
sql를 실행함.

Specified by:
executeUpdate in interface SqlUtil
Parameters:
sql -
Returns:
int
Throws:
java.sql.SQLException

commit

public void commit()
            throws java.sql.SQLException
commit 처리를 함.
ex)
String sql = "update .... ";
SqlUtil sqlutil = new SqlUtil();
try{
   sqlutil.getConnection("maags");
   sqlutil.setAutoCommit(false);
   sqlutil.executeUpdate(sql);
   sqlutil.commit();
}catch(SQLException e) {
   e.printStackTrace();
   sqlutil.rollback();
}finally{
   sqlutil.close();
}

Specified by:
commit in interface SqlUtil
Throws:
java.sql.SQLException

rollback

public void rollback()
rollback 처리를 함.
ex)
String sql = "update .... ";
SqlUtil sqlutil = new SqlUtil();
try{
   sqlutil.getConnection("maags");
   sqlutil.setAutoCommit(false);
   sqlutil.executeUpdate(sql);
   sqlutil.commit();
}catch(SQLException e) {
   e.printStackTrace();
   sqlutil.rollback();
}finally{
   sqlutil.close();
}

Specified by:
rollback in interface SqlUtil

close

public void close()
close 처리를 함.

ex)
String sql = "update .... ";
SqlUtil sqlutil = new SqlUtil();
try{
   sqlutil.getConnection("maags");
   sqlutil.setAutoCommit(false);
   sqlutil.executeUpdate(sql);
   sqlutil.commit();
}catch(SQLException e) {
   e.printStackTrace();
   sqlutil.rollback();
}finally{
   sqlutil.close();
}

Specified by:
close in interface SqlUtil

setAutoCommit

public void setAutoCommit(boolean autocommit)
                   throws java.sql.SQLException
트랜잭션 처리를 위해 autoCommit 설정을 함.
ex)
String sql = "update .... ";
SqlUtil sqlutil = new SqlUtil();
try{
   sqlutil.getConnection("maags");
   sqlutil.setAutoCommit(false);
   sqlutil.executeUpdate(sql);
   sqlutil.commit();
}catch(SQLException e) {
   e.printStackTrace();
   sqlutil.rollback();
}finally{
   sqlutil.close();
}

Specified by:
setAutoCommit in interface SqlUtil
Parameters:
autocommit -
Throws:
java.sql.SQLException

getAutoCommit

public boolean getAutoCommit()
Specified by:
getAutoCommit in interface SqlUtil

setConnection

public void setConnection(java.sql.Connection connection)
sqlUtil 에서 사용할 connection을 설정함.

Specified by:
setConnection in interface SqlUtil
Parameters:
connection -

getDataSource

public javax.sql.DataSource getDataSource()
dataSource를 반환함.

Specified by:
getDataSource in interface SqlUtil
Returns:
DataSource

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
dataSource를 설정함.

Specified by:
setDataSource in interface SqlUtil
Parameters:
dataSource -

getRowCallbackHandler

public RowCallbackHandler getRowCallbackHandler()
java.sql.ResultSet 객체를 처리시 사용할 handler객체를 반환함.

Specified by:
getRowCallbackHandler in interface SqlUtil
Returns:
RowCallbackHandler

setRowCallbackHandler

public void setRowCallbackHandler(RowCallbackHandler rowCallbackHandler)
java.sql.ResultSet 객체를 처리시 사용할 handler객체를 설정함.

Specified by:
setRowCallbackHandler in interface SqlUtil

getJndiDataSourceName

public java.lang.String getJndiDataSourceName()
JNDI DataSurceName 을 반환함.

Specified by:
getJndiDataSourceName in interface SqlUtil
Returns:
String

setJndiDataSourceName

public void setJndiDataSourceName(java.lang.String jndiDataSourceName)
JNDI DataSourceName 을 설정함.

Specified by:
setJndiDataSourceName in interface SqlUtil
Parameters:
jndiDataSourceName -

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Specified by:
prepareCall in interface SqlUtil
Throws:
java.sql.SQLException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

loadParams

public static java.util.Properties loadParams(java.lang.String file)
                                       throws java.io.IOException
This method reads the properties file:Connection.properties which is passed as the parameter to it and load it into a java Properties object and returns it.

Parameters:
file - The name of the file having connection details.
Throws:
java.io.IOException


Copyright © 2003 All Rights Reserved.