OSDN Git Service

track
authordobashi <dobashi@lavans.jp>
Mon, 16 Jan 2012 13:44:23 +0000 (22:44 +0900)
committerdobashi <dobashi@lavans.jp>
Mon, 16 Jan 2012 13:44:23 +0000 (22:44 +0900)
119 files changed:
.classpath [new file with mode: 0644]
.project [new file with mode: 0644]
.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
.settings/org.eclipse.jdt.ui.prefs [new file with mode: 0644]
.settings/org.eclipse.jst.common.project.facet.core.prefs [new file with mode: 0644]
.settings/org.eclipse.ltk.core.refactoring.prefs [new file with mode: 0644]
.settings/org.eclipse.wst.common.component [new file with mode: 0644]
.settings/org.eclipse.wst.common.project.facet.core.xml [new file with mode: 0644]
.settings/org.eclipse.wst.validation.prefs [new file with mode: 0644]
conf/luz.xml [new file with mode: 0644]
docs/Cluster.jude [new file with mode: 0644]
docs/memo.txt [new file with mode: 0644]
jsp/stats.jsp [new file with mode: 0644]
lib/asm-3.1.jar [new file with mode: 0644]
lib/cglib-2.2.jar [new file with mode: 0644]
lib/commons-lang-2.4.jar [new file with mode: 0644]
lib/commons-logging-1.0.4.jar [new file with mode: 0644]
lib/ojdbc14.jar [new file with mode: 0644]
src/com/lavans/luz2/commons/ArrayUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/ClassUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/DaoUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/DateUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/JapaneseTextUtil.java [new file with mode: 0644]
src/com/lavans/luz2/commons/NumberUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/ObjectUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/StringEscapeUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/StringUtils.java [new file with mode: 0644]
src/com/lavans/luz2/commons/Validator.java [new file with mode: 0644]
src/com/lavans/luz2/controller/ActionInfo.java [new file with mode: 0644]
src/com/lavans/luz2/controller/ActionServlet.java [new file with mode: 0644]
src/com/lavans/luz2/controller/ActionSupport.java [new file with mode: 0644]
src/com/lavans/luz2/controller/DefaultAction.java [new file with mode: 0644]
src/com/lavans/luz2/http/AccessLogFilter.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/AccessData.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/AccessFilter.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/AccessOverFlowException.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/RemoteHttpServletRequest.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/SessionFilter.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/SessionListener.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/SessionServiceLocal.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/SessionServiceRemote.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/net/SessionServerConnection.java [new file with mode: 0644]
src/com/lavans/luz2/http/session/net/SessionServerConnectionManager.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/annotation/LRemote.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/connector/ConnectManager.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/connector/Connector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/connector/impl/AsyncConnectWrapper.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/connector/impl/GroupConnector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/connector/impl/SingleConnector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/intercetor/RemoteInterceptor.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/node/RemoteNode.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/node/RemoteNodeGroup.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/selector/Selector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/selector/SelectorFactory.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/selector/impl/GroupSelector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/selector/impl/OrderedSelector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/selector/impl/OthersSelector.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/service/ServiceManager.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/service/ServiceManagerXml.java [new file with mode: 0644]
src/com/lavans/luz2/lremote/servlet/RemoteServlet.java [new file with mode: 0644]
src/com/lavans/luz2/sql/ConnectionPool.java [new file with mode: 0644]
src/com/lavans/luz2/sql/DBManager.java [new file with mode: 0644]
src/com/lavans/luz2/sql/DataSourceWrapper.java [new file with mode: 0644]
src/com/lavans/luz2/sql/DriverWrapper.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindCallableStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindCallableStatementImpl.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindConnection.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindConnectionImpl.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindPreparedStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/bind/BindPreparedStatementImpl.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/CalledMethod.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterCallableStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterConnection.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterConnectionPool.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterPreparedStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterResultSet.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/cluster/ClusterStatementInterface.java [new file with mode: 0644]
src/com/lavans/luz2/sql/dao/CommonDao.java [new file with mode: 0644]
src/com/lavans/luz2/sql/logging/Loggable.java [new file with mode: 0644]
src/com/lavans/luz2/sql/logging/LoggingStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledBindCallableStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledBindPreparedStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledCallableStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledConnection.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledPreparedStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/pool/PooledStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/Statistics.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/StatsCallableStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/StatsConnection.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/StatsPreparedStatement.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/StatsRecord.java [new file with mode: 0644]
src/com/lavans/luz2/sql/stats/StatsStatement.java [new file with mode: 0644]
src/com/lavans/luz2/util/BeanManager.java [new file with mode: 0644]
src/com/lavans/luz2/util/CondTypeEnum.java [new file with mode: 0644]
src/com/lavans/luz2/util/Config.java [new file with mode: 0644]
src/com/lavans/luz2/util/EnumAlias.java [new file with mode: 0644]
src/com/lavans/luz2/util/IEntity.java [new file with mode: 0644]
src/com/lavans/luz2/util/IEnum.java [new file with mode: 0644]
src/com/lavans/luz2/util/IParameterizable.java [new file with mode: 0644]
src/com/lavans/luz2/util/MethodUtil.java [new file with mode: 0644]
src/com/lavans/luz2/util/PageInfo.java [new file with mode: 0644]
src/com/lavans/luz2/util/Pager.java [new file with mode: 0644]
src/com/lavans/luz2/util/ParameterUtils.java [new file with mode: 0644]
src/test/BigDecimalTest.java [new file with mode: 0644]
src/test/ConfigTest.java [new file with mode: 0644]
src/test/ConnectTest.java [new file with mode: 0644]
src/test/Entity.java [new file with mode: 0644]
src/test/GDTEst.java [new file with mode: 0644]
src/test/com/lavans/luz2/dao/old/DaoUtils.java [new file with mode: 0644]
src/test/com/lavans/luz2/dao/old/EntityMetaData.java [new file with mode: 0644]
src/test/com/lavans/luz2/dao/old/GenericDao.java [new file with mode: 0644]
src/test/com/lavans/luz2/dao/old/SqlDao.java [new file with mode: 0644]
src/test/com/lavans/luz2/text/NumberUtilTest.java [new file with mode: 0644]
src/test/com/lavans/luz2/text/StringUtilsTest.java [new file with mode: 0644]
src/test/com/lavans/luz2/text/ValidatorTest.java [new file with mode: 0644]
src/test/com/lavans/luz2/util2/InstanceManager.java [new file with mode: 0644]
src/test/com/lavans/luz2/util2/ParameterUtilTest.java [new file with mode: 0644]

diff --git a/.classpath b/.classpath
new file mode 100644 (file)
index 0000000..a8dd7d5
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="src" path="conf"/>\r
+       <classpathentry kind="src" path="jsp"/>\r
+       <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>\r
+       <classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>\r
+       <classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/>\r
+       <classpathentry kind="lib" path="lib/asm-3.1.jar"/>\r
+       <classpathentry kind="lib" path="lib/cglib-2.2.jar"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..7b762be
--- /dev/null
+++ b/.project
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>luz2</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.wst.common.project.facet.core.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.wst.validation.validationbuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.eclipse.wst.common.project.facet.core.nature</nature>\r
+               <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>\r
+               <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..c42ef77
--- /dev/null
@@ -0,0 +1,3 @@
+#Sun Aug 21 00:59:31 JST 2011\r
+eclipse.preferences.version=1\r
+encoding/<project>=UTF-8\r
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..4d47cb5
--- /dev/null
@@ -0,0 +1,12 @@
+#Tue Sep 09 02:57:39 JST 2008\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..dbc497c
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue May 20 03:08:09 JST 2008\r
+eclipse.preferences.version=1\r
+internal.default.compliance=default\r
diff --git a/.settings/org.eclipse.jst.common.project.facet.core.prefs b/.settings/org.eclipse.jst.common.project.facet.core.prefs
new file mode 100644 (file)
index 0000000..1a9f0a3
--- /dev/null
@@ -0,0 +1,6 @@
+#Fri Aug 15 14:24:41 JST 2008\r
+classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:eclipse3.4/owners=jst.java\:6.0\r
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=\#system\#\r
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5x/owners=\#system\#\r
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v6.0/owners=\#system\#\r
+eclipse.preferences.version=1\r
diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644 (file)
index 0000000..be9bf2e
--- /dev/null
@@ -0,0 +1,3 @@
+#Thu Dec 14 03:21:35 JST 2006\r
+eclipse.preferences.version=1\r
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false\r
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
new file mode 100644 (file)
index 0000000..fde8ef7
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project-modules id="moduleCoreId" project-version="1.5.0">\r
+<wb-module deploy-name="luz">\r
+<wb-resource deploy-path="/" source-path="/src"/>\r
+<wb-resource deploy-path="/" source-path="/conf"/>\r
+<wb-resource deploy-path="/" source-path="/jsp"/>\r
+</wb-module>\r
+</project-modules>\r
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644 (file)
index 0000000..8a33cd7
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<faceted-project>\r
+  <fixed facet="jst.java"/>\r
+  <fixed facet="jst.utility"/>\r
+  <installed facet="jst.utility" version="1.0"/>\r
+  <installed facet="jst.java" version="6.0"/>\r
+</faceted-project>\r
diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs
new file mode 100644 (file)
index 0000000..e38ced6
--- /dev/null
@@ -0,0 +1,6 @@
+#Thu Dec 14 03:21:35 JST 2006\r
+DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;\r
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;\r
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;\r
+USER_PREFERENCE=overrideGlobalPreferencesfalse\r
+eclipse.preferences.version=1\r
diff --git a/conf/luz.xml b/conf/luz.xml
new file mode 100644 (file)
index 0000000..27327ad
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE luz>\r
+<luz>\r
+       <database statistics="true">\r
+               <default\r
+                       driver="oracle.jdbc.driver.OracleDriver"\r
+                       url="jdbc:oracle:thin:@192.168.1.1:1521:sid"\r
+                       user="user"\r
+                       pass="pass"\r
+                       init_connections="1"\r
+                       max_connections="50"\r
+                       logging="true"\r
+               />\r
+       </database>\r
+\r
+       <!-- sample\r
+       <debug>true</debug>\r
+       <property>\r
+               <name1 type="as">\r
+                       value1\r
+                       <test aa="bb" />\r
+               </name1>\r
+       </property>\r
+        -->\r
+</luz>
\ No newline at end of file
diff --git a/docs/Cluster.jude b/docs/Cluster.jude
new file mode 100644 (file)
index 0000000..4ac0392
Binary files /dev/null and b/docs/Cluster.jude differ
diff --git a/docs/memo.txt b/docs/memo.txt
new file mode 100644 (file)
index 0000000..70fdaec
--- /dev/null
@@ -0,0 +1,3 @@
+depends on:\r
+commons-logging\r
+commong-lang\r
diff --git a/jsp/stats.jsp b/jsp/stats.jsp
new file mode 100644 (file)
index 0000000..6576cf5
--- /dev/null
@@ -0,0 +1,186 @@
+<!-- $Id: stats.jsp,v 1.11 2005/05/27 20:30:25 yuk Exp $ -->\r
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en"\r
+   "http://www.w3.org/tr/rec-html40/loose.dtd">\r
+<%@ page contentType="text/html; charset=UTF-8" %>\r
+\r
+<%@ page import="java.util.*" %>\r
+<%@ page import="java.text.*" %>\r
+<%-- <%@ page import="com.lavans.util.*" %> --%>\r
+<%@ page import="com.lavans.luz2.sql.stats.*" %>\r
+<%!\r
+       private static String METHOD_EXCLUDE_PACKAGE="com.lavans.util";\r
+\r
+       private static String COMMAND ="cmd";\r
+       private static String C_LIST  ="list";\r
+\r
+       private static String SORT ="sort";\r
+       private static String SORT_TOTAL="total";\r
+       private static String SORT_AVERAGE="ave";\r
+\r
+%>\r
+<%\r
+       Statistics stat = Statistics.getInstance();\r
+\r
+       // 繧ス繝シ繝�
+       String sort = request.getParameter(SORT);\r
+       if(sort==null) sort=SORT_AVERAGE;\r
+\r
+       // 繧ウ繝槭Φ繝�
+       String command = request.getParameter(COMMAND);\r
+       if(command==null) command=C_LIST;\r
+\r
+       NumberFormat nf  = NumberFormat.getInstance();\r
+       DecimalFormat df = new DecimalFormat("#,###.00");\r
+%>\r
+<html lang="ja">\r
+<head>\r
+<title>邨ア險域ュ蝣ア</title>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<style type="text/css">\r
+  body{\r
+    color: #000000;\r
+    background-color: #fffafa;\r
+    font-size: 12px;\r
+  }\r
+\r
+a:link {\r
+       text-decoration: none;\r
+}\r
+\r
+a:visited {\r
+       text-decoration: none;\r
+}\r
+\r
+a:hover {\r
+       color: #FFFFFF;\r
+       background-color: #000066;\r
+}\r
+\r
+  .txt{\r
+    font-size: 12px;\r
+  }\r
+\r
+  div.center{\r
+       text-align: center\r
+  }\r
+\r
+  tr.title{\r
+    color: #ffffff;\r
+    background-color: #000066;\r
+    font-size: 14px;\r
+       font-weight: bold;\r
+       text-align: middle;\r
+  }\r
+\r
+  td.sql{\r
+    color: #000066;\r
+    background-color: #f5f9ff;\r
+    font-size: 12px;\r
+  }\r
+\r
+  td.method{\r
+    color: #991000;\r
+    background-color: #FDFDFF;\r
+    font-size: 12px;\r
+  }\r
+  .hilight{\r
+    color: #FF0000;\r
+  }\r
+\r
+  .white{\r
+    color: #ffffff;\r
+  }\r
+  .gray{\r
+    color: #999999;\r
+  }\r
+</style>\r
+<script language="javascript">\r
+function openSQL(sql){\r
+  w = window.open("","_new","width=500,height=300,scrollbars=yes,resizable=yes,status=no,menbar=no");\r
+  w.document.open("text/html","replace");\r
+  w.document.write("<font face=\"�ュ�ウ 繧エ繧キ繝�け\">");\r
+  w.document.write(sql);\r
+  w.document.write("</font>");\r
+  w.document.close();\r
+  w.focus();\r
+ }\r
+</script>\r
+</head>\r
+<body>\r
+\r
+<table border=1 cellspacing=0 cellpadding=3 width="100%">\r
+<tr class="title">\r
+  <th>蜻シ蜃コ蜈�/th>\r
+  <th rowspan="2" width="30">螳溯。�br>蝗樊焚</th>\r
+<%\r
+       if(sort.equals(SORT_TOTAL)){\r
+%>\r
+  <th rowspan="2">邱丞ョ溯。梧凾髢�br>(msec)<font class="gray">笆シ</font></th>\r
+  <th rowspan="2">蟷ウ蝮�ョ溯。梧凾髢�br>(msec)<a href="stats.jsp?<%= SORT +"="+ SORT_AVERAGE %>" class="white">笆シ</a></th>\r
+<%\r
+       }else{\r
+%>\r
+  <th rowspan="2">邱丞ョ溯。梧凾髢�br>(msec)<a href="stats.jsp?<%= SORT +"="+ SORT_TOTAL %>" class="white">笆シ</a></th>\r
+  <th rowspan="2">蟷ウ蝮�ョ溯。梧凾髢�br>(msec)<font class="gray">笆シ</font></th>\r
+<%\r
+       }\r
+%>\r
+\r
+</tr>\r
+<tr class="title">\r
+  <th>SQL</th>\r
+</tr>\r
+<%\r
+       List list = null;\r
+       if(sort.equals(SORT_TOTAL)){\r
+               list = stat.getStatInfoByTotal();\r
+       }else{\r
+               list = stat.getStatInfoByAverage();\r
+       }\r
+       for(int i=0; i<list.size(); i++){\r
+               StatsRecord rec = (StatsRecord)list.get(i);\r
+               // 蜻シ蜃コ蜈�ク�ヲァ\r
+               StringBuffer buf = new StringBuffer();\r
+               Object methods[] = rec.getMethodNames().toArray();\r
+               for(int j=0; j<methods.length; j++){\r
+                       buf.append(methods[j] + "<br>");\r
+               }\r
+%>\r
+<tr>\r
+<!--  <td class='method'><%= buf.substring(METHOD_EXCLUDE_PACKAGE.length()) %></td>\r
+-->\r
+  <td class='method'><%= buf.toString() %></td>\r
+  <td rowspan="2" align="right"><%= nf.format(rec.getCallCount()) %></td>\r
+  <td rowspan="2" align="right"><%= nf.format(rec.getTotalCostTime()) %></td>\r
+  <td rowspan="2" align="right"><%= df.format(rec.getAverage()) %></td>\r
+</tr>\r
+<tr>\r
+  <td class='sql'>\r
+<%\r
+               if(rec.getSql().length()<200){\r
+                       out.print(rec.getSql());\r
+               }else{\r
+%>\r
+<script> var sql<%= i %>="<%= rec.getSql().replaceAll("\n","<br>").replaceAll(" "," ") %>"; </script>\r
+  <%= rec.getSql().substring(0,200) %><a href="javascript:openSQL(sql<%= i %>)">.....</a>\r
+<%\r
+               }\r
+%>\r
+</td>\r
+</tr>\r
+<%\r
+       }\r
+%>\r
+</table>\r
+<%= Statistics.getInstance().viewConnectionPool() %>\r
+<%\r
+/*\r
+    Enumeration e = DriverManager.getDrivers();\r
+    while(e.hasMoreElements()){\r
+            Driver drivera = (Driver)e.nextElement();\r
+            %><%= drivera.toString() %><br>\n<%\r
+    }\r
+*/\r
+%>\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/lib/asm-3.1.jar b/lib/asm-3.1.jar
new file mode 100644 (file)
index 0000000..b3baf3f
Binary files /dev/null and b/lib/asm-3.1.jar differ
diff --git a/lib/cglib-2.2.jar b/lib/cglib-2.2.jar
new file mode 100644 (file)
index 0000000..084ef6e
Binary files /dev/null and b/lib/cglib-2.2.jar differ
diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar
new file mode 100644 (file)
index 0000000..532939e
Binary files /dev/null and b/lib/commons-lang-2.4.jar differ
diff --git a/lib/commons-logging-1.0.4.jar b/lib/commons-logging-1.0.4.jar
new file mode 100644 (file)
index 0000000..b73a80f
Binary files /dev/null and b/lib/commons-logging-1.0.4.jar differ
diff --git a/lib/ojdbc14.jar b/lib/ojdbc14.jar
new file mode 100644 (file)
index 0000000..2a33709
Binary files /dev/null and b/lib/ojdbc14.jar differ
diff --git a/src/com/lavans/luz2/commons/ArrayUtils.java b/src/com/lavans/luz2/commons/ArrayUtils.java
new file mode 100644 (file)
index 0000000..b020593
--- /dev/null
@@ -0,0 +1,5 @@
+package com.lavans.luz2.commons;\r
+\r
+public class ArrayUtils extends org.apache.commons.lang.ArrayUtils{\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/commons/ClassUtils.java b/src/com/lavans/luz2/commons/ClassUtils.java
new file mode 100644 (file)
index 0000000..612dfb1
--- /dev/null
@@ -0,0 +1,5 @@
+package com.lavans.luz2.commons;\r
+\r
+public class ClassUtils extends org.apache.commons.lang.ClassUtils{\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/commons/DaoUtils.java b/src/com/lavans/luz2/commons/DaoUtils.java
new file mode 100644 (file)
index 0000000..bcda317
--- /dev/null
@@ -0,0 +1,194 @@
+package com.lavans.luz2.commons;\r
+\r
+import java.math.BigDecimal;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.util.CondTypeEnum;\r
+import com.lavans.luz2.util.Config;\r
+\r
+public class DaoUtils {\r
+       /** ロガー */\r
+       private static Log logger = LogFactory.getLog(DaoUtils.class);\r
+       //private static final String CLASSNAME=DaoUtils.class.getName();\r
+\r
+       /**\r
+        * IN句の文字列作成\r
+        * @param <T>\r
+        * @param objs\r
+        * @param prefix\r
+        * @param params パラメータ用Map。ここに格納される。\r
+        * @return\r
+        */\r
+       public static String makeInCond(String[] objs, String prefix, Map<String, String[]> params){\r
+               if(objs.length==0) throw new IllegalArgumentException("target's length==0.");\r
+               StringBuilder str = new StringBuilder();\r
+               for(int i=0; i<objs.length; i++){\r
+                       str.append(",:"+prefix+i);\r
+                       params.put(prefix+i, new String[]{objs[i]});\r
+               }\r
+               return str.substring(1);\r
+       }\r
+\r
+       // どうせWebからStringでしか指定しないんだからジェネリックいらないかも\r
+//     public static <T> String makeInCond(T[] objs, String prefix, HashMap<String, Object> params){\r
+//             if(objs.length==0) throw new IllegalArgumentException("target's length==0.");\r
+//             StringBuilder str = new StringBuilder();\r
+//             for(int i=0; i<objs.length; i++){\r
+//                     str.append(",:"+prefix+i);\r
+//                     params.put(prefix+i, objs[i]);\r
+//             }\r
+//             return " IN ("+ str.substring(1)+ ")";\r
+//     }\r
+\r
+       public static String getSql(Class<?> clazz, String key){\r
+               return getSql(clazz.getName(), key);\r
+       }\r
+       public static String getSql(String className, String key){\r
+               Config config = Config.getInstance(className.replace(".","/")+".xml");\r
+               String sql="";\r
+               try {\r
+                       sql = config.getNodeValue("/sql/"+key).trim();\r
+               } catch (Exception e) {\r
+                       logger.error("SQLが見つかりません。["+ key +"]", e);\r
+               }\r
+\r
+               return sql;\r
+       }\r
+\r
+       /**\r
+        * 検索条件の設定。ここでは特定のprefixがついたkey=valueを取得するだけ\r
+        */\r
+       public static Map<String, String[]> getSearchCond(Map<String, String[]> requestParameters, String prefix){\r
+               Map<String, String[]> map = new HashMap<String, String[]>();\r
+               // just only get "search condition paraemters" here. it use later.\r
+               for(Map.Entry<String, String[]> entry: requestParameters.entrySet()){\r
+                       if(entry.getKey().startsWith(prefix)){\r
+                               map.put(entry.getKey().substring(prefix.length()), entry.getValue());\r
+                       }\r
+               }\r
+               return map;\r
+       }\r
+\r
+       /**\r
+        * make SQL where phrase from search condtions.\r
+        * @return\r
+        */\r
+       public static String getWherePhrase(Set<String> attributeNames, Map<String, String[]> cond){\r
+               // null check.\r
+               if(cond==null){\r
+                       return "";\r
+               }\r
+\r
+               // SQL construction start.\r
+               StringBuilder builder = new StringBuilder();\r
+               for(String attributeName: attributeNames){\r
+                       String key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.EQUAL.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +"= :"+ key);\r
+                       }\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.GREATER_EQUAL.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +">= :"+ key);\r
+                       }\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.LESS_OR_EQUAL.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +"<= :"+ key);\r
+                       }\r
+\r
+                       // fuzzy search\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.FUZZY_SEARCH.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +" LIKE :"+ key);\r
+                               // replace keyword\r
+                               cond.get(key)[0]="%"+cond.get(key)[0]+"%";\r
+                       }\r
+\r
+                       // prefix search\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.PREFIX_SEARCH.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +" LIKE :"+ key);\r
+                               // replace keyword\r
+                               cond.get(key)[0]=cond.get(key)[0]+"%";\r
+                       }\r
+\r
+                       // suffix search\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.SUFFIX_SEARCH.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +" LIKE :"+ key);\r
+                               // replace keyword\r
+                               cond.get(key)[0]="%"+cond.get(key)[0];\r
+                       }\r
+\r
+                       // multiple values\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.MULTIPLE.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +" IN ( "+ makeInCond(cond.get(key),attributeName,cond) +")");\r
+                       }\r
+\r
+                       // comma separated values\r
+                       key = attributeName +"."+ StringUtils.toCamelCase(CondTypeEnum.LIST.toString());\r
+                       if((cond.get(key)!=null) && !StringUtils.isEmpty(cond.get(key)[0])){\r
+                               // separate all keys\r
+                               String conds[] = StringUtils.splitTrim(cond.get(key)[0], ",");\r
+                               builder.append(" AND "+ StringUtils.toUnderscore(attributeName).toUpperCase() +" IN ( "+ makeInCond(conds,attributeName,cond) +")");\r
+                       }\r
+               }\r
+\r
+               return builder.toString();\r
+       }\r
+\r
+       /**\r
+        * 検索条件をMap<String,String[]>からMap<String,Object>に変換。\r
+        * InteterとかLongとか型渡して変換した方がよさそう。\r
+        *\r
+        */\r
+       public static Map<String, Object> convertSearchCond(Map<String, String[]> cond, Map<String,Class<?>> attributeInfo){\r
+               Map<String, Object> result = new HashMap<String, Object>();\r
+               for(Map.Entry<String, String[]> entry: cond.entrySet()){\r
+                       // 値が指定されていなければ評価しない\r
+                       if(StringUtils.isEmpty(entry.getValue()[0])){\r
+                               continue;\r
+                       }\r
+\r
+                       // 属性名は.より前の部分(ex memberId.equal\r
+                       if(!entry.getKey().contains(".")){\r
+                               logger.debug("No condtion ["+ entry.getKey() +"]");\r
+                               continue;\r
+                       }\r
+                       String attributeName = entry.getKey().split("\\.")[0];\r
+                       // この属性の型情報を取得\r
+                       Class<?> clazz = attributeInfo.get(attributeName);\r
+                       // 念のためnullチェック\r
+                       if(clazz==null){\r
+                               logger.debug("No attribute Info,["+ attributeName +"]");\r
+                               continue;\r
+                       }\r
+\r
+                       if(clazz.equals(Integer.class)){\r
+                               result.put(entry.getKey(), Integer.valueOf(entry.getValue()[0]));\r
+                       }else if(clazz.equals(Long.class)){\r
+                               result.put(entry.getKey(), Long.valueOf(entry.getValue()[0]));\r
+                       }else if(clazz.equals(Double.class)){\r
+                               result.put(entry.getKey(), Double.valueOf(entry.getValue()[0]));\r
+                       }else if(clazz.equals(BigDecimal.class)){\r
+                               result.put(entry.getKey(), new BigDecimal(entry.getValue()[0]));\r
+//                     }else if(clazz.equals(byte[].class)){\r
+//                             // バイナリは検索不可\r
+//                             result.put(entry.getKey(), byte.valueOf(entry.getValue()[0]));\r
+                       }else if(clazz.equals(Date.class)){\r
+                               result.put(entry.getKey(), DateUtils.getDate(entry.getValue()[0]));\r
+                       }else{\r
+                               // String\r
+                               result.put(entry.getKey(), entry.getValue()[0]);\r
+                       }\r
+\r
+               }\r
+               return result;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/DateUtils.java b/src/com/lavans/luz2/commons/DateUtils.java
new file mode 100644 (file)
index 0000000..1704524
--- /dev/null
@@ -0,0 +1,115 @@
+package com.lavans.luz2.commons;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+public class DateUtils {\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(DateUtils.class);\r
+\r
+       /**\r
+        * 受け取ったDate型に日付演算した結果をDate型返す。\r
+        * dateがnullなら現在時刻から\r
+        * @param str\r
+        */\r
+       public static Date getDateAdd(Date date, int field, int add){\r
+               Calendar cal =Calendar.getInstance();\r
+               if(date!=null){\r
+                       cal.setTime(date);\r
+               }\r
+               cal.add(field, add);\r
+               return cal.getTime();\r
+       }\r
+\r
+       /**\r
+        * 文字列からDateを作成。\r
+        * パースできない場合はnull。\r
+        *\r
+        * @param dateStr\r
+        * @return\r
+        */\r
+       public static Date getDate(String dateStr){\r
+               return getDate(dateStr, getFormat(dateStr));\r
+       }\r
+       /**\r
+        * yyyy/MM/dd形式の文字列からDate型を作成。\r
+        * 与えられた文字列を見てパース方法を判断する。\r
+        * @param str\r
+        * @return\r
+        */\r
+       private static final String FORMAT_DATE = "yyyy/MM/dd";\r
+       private static final String FORMAT_MIN  = "yyyy/MM/dd HH:mm";\r
+       private static final String FORMAT_MSEC = "yyyy/MM/dd HH:mm:ss";\r
+       private static final String FORMAT_SEC = "yyyy/MM/dd HH:mm:ss.SSS";\r
+       private static String getFormat(String str){\r
+               str = str.trim();\r
+               String result = null;\r
+               if(str.contains(":")){\r
+                       // 時刻含む\r
+                       if(str.indexOf(":")==str.lastIndexOf(":")){\r
+                               // コロンが一つなら\r
+                               result = FORMAT_MIN;\r
+                       }else{\r
+                               // コロンが二つなら\r
+                               if(str.contains(".")){\r
+                                       // ミリ秒も含む\r
+                                       result = FORMAT_MSEC;\r
+                               }else{\r
+                                       // 秒まで\r
+                                       result = FORMAT_SEC;\r
+                               }\r
+                       }\r
+               }else{\r
+                       result = FORMAT_DATE;\r
+               }\r
+               \r
+               // yyyy/MM/ddのの他にもyyyy-MM-ddも使えるようにする\r
+               if(str.length()>10){\r
+                       if(str.charAt(4)=='-' && str.charAt(6)=='-'){\r
+                               FORMAT_DATE.replace("/", "-");\r
+                       }\r
+               }\r
+               \r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * 指定された日付文字列とフォーマットでDate型を作成。\r
+        * @param dateStr\r
+        * @param dateFormat\r
+        * @return\r
+        */\r
+       public static Date getDate(String dateStr, String dateFormat){\r
+               if(dateStr==null) return null;\r
+               SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);\r
+               Date date = null;\r
+               try {\r
+                       date = sdf.parse(dateStr);\r
+               } catch (Exception e) {\r
+                       logger.debug(e.getMessage());\r
+               }\r
+\r
+               return date;\r
+       }\r
+\r
+       /**\r
+        * 時刻を空にする\r
+        * パースできない場合はnull。\r
+        *\r
+        * @param dateStr\r
+        * @return\r
+        */\r
+       public static Date cleartime(Date date){\r
+               Calendar cal = Calendar.getInstance();\r
+               cal.setTime(date);\r
+               cal.set(Calendar.HOUR_OF_DAY, 0);\r
+               cal.set(Calendar.MINUTE, 0);\r
+               cal.set(Calendar.SECOND, 0);\r
+               cal.set(Calendar.MILLISECOND, 0);\r
+               return cal.getTime();\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/JapaneseTextUtil.java b/src/com/lavans/luz2/commons/JapaneseTextUtil.java
new file mode 100644 (file)
index 0000000..ea4f11b
--- /dev/null
@@ -0,0 +1,340 @@
+package com.lavans.luz2.commons;\r
+\r
+import java.io.UnsupportedEncodingException;\r
+\r
+public class JapaneseTextUtil {\r
+       /**\r
+        * strのエンコードを「Windows-31J」に変換し、そのバイト数を返す\r
+        *\r
+        * @param str\r
+        * @return\r
+        */\r
+       public static int getByteLength(String str) {\r
+               if (str == null) {\r
+                       return 0;\r
+               }\r
+\r
+               int len = 0;\r
+               try {\r
+                       byte[] buff = str.getBytes("Windows-31J");\r
+                       len = buff.length;\r
+               } catch (UnsupportedEncodingException e) {}\r
+\r
+               return len;\r
+       }\r
+\r
+       /**\r
+        * 英数字(一部記号)チェック\r
+        *\r
+        */\r
+       private static final String HANKANA = "アイウエオァィゥェォカキクケコサシスセソタチツッテトナニヌネノハヒフヘホマミムメモヤユヨャュョラリルレロワヲンー゙゚";\r
+       private static final String KATAKANA = "アイウエオァィゥェォカキクケコサシスセソタチツッテトナニヌネノハヒフヘホマミムメモヤユヨャュョラリルレロワヲンー゛゜";\r
+       private static final String KATAKANA_D = "ヴガギグゲゴザジズゼゾダヂヅデドバビブベボ";\r
+       private static final String HANKANA_D = "ウカキクケコサシスセソタチツテトハヒフヘホ";\r
+       private static final String KATAKANA_H = "パピプペポ";\r
+       private static final String HANKANA_H = "ハヒフヘホ";\r
+\r
+       // 句読点あり\r
+       private static final String HANKANA_KUTOUEN = "、。";\r
+       private static final String KATAKANA_KUTOUTEN = "、。";\r
+\r
+       // static final java.lang.String ひらがな =\r
+       // "あいうえおぁぃぅぇぉかきくけこさしすせそたちつってとなにぬねのはひふへほまみむめもやゆよゃゅょらりるれろわをんー゛゜、。がぎぐげござじずぜぞだぢづでどヴばびぶべぼぱぴぷぺぽ"\r
+       // ;\r
+\r
+       /**\r
+        * 全角カタカナを半角カタカナに変換する日本語正規化。\r
+        */\r
+       public static String toHankana(String kanaStr) {\r
+               if(kanaStr==null) return null;\r
+               StringBuffer hankanaStr = new StringBuffer(kanaStr.length());\r
+               int index;\r
+               for (int i = 0; i < kanaStr.length(); i++) {\r
+                       char kana = kanaStr.charAt(i);\r
+                       if ((index = KATAKANA.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA.charAt(index));\r
+                       } else if ((index = KATAKANA_D.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA_D.charAt(index) + "゙");\r
+                       } else if ((index = KATAKANA_H.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA_H.charAt(index) + "゚");\r
+                       } else {\r
+                               hankanaStr.append(kana);\r
+                       }\r
+               }\r
+\r
+               return hankanaStr.toString();\r
+       }\r
+\r
+       /**\r
+        * 全角カタカナを半角カタカナに変換。句読点あり。\r
+        */\r
+       public static String toHankanaKutouten(String kanaStr) {\r
+               StringBuffer hankanaStr = new StringBuffer(kanaStr.length());\r
+               int index;\r
+               for (int i = 0; i < kanaStr.length(); i++) {\r
+                       char kana = kanaStr.charAt(i);\r
+                       if ((index = KATAKANA.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA.charAt(index));\r
+                       } else if ((index = KATAKANA_D.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA_D.charAt(index) + "゙");\r
+                       } else if ((index = KATAKANA_H.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA_H.charAt(index) + "゚");\r
+                       } else if ((index = KATAKANA_KUTOUTEN.indexOf(kana)) >= 0) {\r
+                               hankanaStr.append(HANKANA_KUTOUEN.charAt(index));\r
+                       } else {\r
+                               hankanaStr.append(kana);\r
+                       }\r
+               }\r
+\r
+               return hankanaStr.toString();\r
+       }\r
+\r
+       /**\r
+        * 半角カタカナを全角カタカナに変換する日本語正規化 1文字単位。\r
+        */\r
+       public static char toKanaFull(char kana) {\r
+               int index;\r
+\r
+               if ((index = HANKANA.indexOf(kana)) >= 0) {\r
+                       kana = KATAKANA.charAt(index);\r
+               }\r
+\r
+               return kana;\r
+       }\r
+\r
+       /**\r
+        * 半角カタカナを全角カタカナにし、濁点も統合する。 日本語正規化 使用例 郵便番号辞書 JPRS RACEドメイン\r
+        */\r
+       public static String toKanaFull(java.lang.String str) {\r
+               StringBuffer str2;\r
+               char kkv;\r
+               str2 = new StringBuffer();\r
+               for (int i = 0; i < str.length(); i++) {\r
+                       kkv = toKanaFull(str.charAt(i));\r
+                       if (kkv == '゙') {\r
+                               kkv = str2.charAt(str2.length() - 1);\r
+                               kkv++;\r
+                               str2.deleteCharAt(str2.length() - 1);\r
+                       } else if (kkv == '゚') {\r
+                               kkv = str2.charAt(str2.length() - 1);\r
+                               kkv += 2;\r
+                               str2.deleteCharAt(str2.length() - 1);\r
+                       }\r
+                       str2.append(kkv);\r
+\r
+               }\r
+\r
+               return str2.toString();\r
+       }\r
+\r
+       /**\r
+        * 日本語正規化 全角/半角カタカナをひらがなにする\r
+        */\r
+       public static String toHiragana(String str) {\r
+               StringBuffer str2;\r
+               str2 = new StringBuffer();\r
+               char ch;\r
+               str = toKanaFull(str);\r
+               for (int i = 0; i < str.length(); i++) {\r
+                       ch = str.charAt(i);\r
+                       if (ch >= 0x30A0 && ch <= 0x30FA) {\r
+                               ch -= 0x60;\r
+                       }\r
+                       str2.append(ch);\r
+               }\r
+               return str2.toString();\r
+       }\r
+\r
+       /**\r
+        * ひらがなを全角カタカナにする\r
+        */\r
+       public static String toKatakana(String str) {\r
+               StringBuffer str2;\r
+               str2 = new StringBuffer();\r
+               char ch;\r
+               for (int i = 0; i < str.length(); i++) {\r
+                       ch = str.charAt(i);\r
+                       if (ch >= 0x3040 && ch <= 0x309A) {\r
+                               ch += 0x60;\r
+                       }\r
+                       str2.append(ch);\r
+               }\r
+               return str2.toString();\r
+       }\r
+\r
+       private static final java.lang.String twoByte = "+-―‐*/=|!?”#@$%&’`()[],.;:_<>^{}・";\r
+       private static final java.lang.String oneByte = "+---*/=|!?\"#@$%&'`()[],.;:_<>^{}・";\r
+\r
+       /**\r
+        * 英数字列を半角文字に正規化する。 未完全版。 郵便番号、電話番号、日本語ドメイン等\r
+        */\r
+       public static java.lang.String toHalf(java.lang.String str) {\r
+               StringBuffer str2;\r
+               str2 = new StringBuffer();\r
+               char ch;\r
+               int idx;\r
+               for (int i = 0; i < str.length(); i++) {\r
+                       ch = str.charAt(i);\r
+                       if (ch >= 'a' && ch <= 'z') {\r
+                               ch += 'a' - 'a';\r
+                       } else if (ch >= 'A' && ch <= 'Z') {\r
+                               ch += 'A' - 'A';\r
+                       } else if (ch >= '0' && ch <= '9') {\r
+                               ch += '0' - '0';\r
+                       } else if (ch == ' ') {\r
+                               ch = ' ';\r
+                       } else if ((idx = twoByte.indexOf(ch)) >= 0) {\r
+                               ch = oneByte.charAt(idx);\r
+                       } else if (ch == '¥') { // 判断は微妙\r
+                               ch = '\\';\r
+                       }\r
+                       str2.append(ch);\r
+               }\r
+               return str2.toString();\r
+       }\r
+\r
+       /**\r
+        * 英数字列を全角文字に正規化する\r
+        */\r
+       public static java.lang.String toFull(java.lang.String str) {\r
+\r
+               if (str == null || str.length() == 0)\r
+                       return str;\r
+\r
+               StringBuffer str2;\r
+               str2 = new StringBuffer();\r
+               char ch;\r
+               int idx;\r
+               for (int i = 0; i < str.length(); i++) {\r
+                       ch = str.charAt(i);\r
+                       if (ch >= 'a' && ch <= 'z') {\r
+                               ch -= 'a' - 'a';\r
+                       } else if (ch >= 'A' && ch <= 'Z') {\r
+                               ch -= 'A' - 'A';\r
+                       } else if (ch >= '0' && ch <= '9') {\r
+                               ch -= '0' - '0';\r
+                       } else if (ch == ' ') {\r
+                               ch = ' ';\r
+                       } else if ((idx = oneByte.indexOf(ch)) >= 0) {\r
+                               ch = twoByte.charAt(idx);\r
+                       } else if (ch == '\\') { // 判断は微妙\r
+                               ch = '¥';\r
+                       }\r
+                       str2.append(ch);\r
+               }\r
+               return str2.toString();\r
+       }\r
+\r
+       /**\r
+        * 指定文字列を全角から半角に英数字・記号全てを変換します。\r
+        *\r
+        * @param 変換前の文字列\r
+        * @return 変換後の文字列\r
+        */\r
+       public static String toHalfAll(String string) {\r
+\r
+               if (string == null || string.length() == 0)\r
+                       return string;\r
+\r
+               return toHalf(toHankana(string));\r
+       }\r
+\r
+       /**\r
+        * 指定文字列を半角から全角に英数字・記号全てを変換します。\r
+        *\r
+        * @param 変換前の文字列\r
+        * @return 変換後の文字列\r
+        */\r
+       public static String toFullAll(String string) {\r
+\r
+               if (string == null || string.length() == 0)\r
+                       return string;\r
+\r
+               return toFull(toKanaFull(string));\r
+       }\r
+       \r
+       /*\r
+        * This method converts Cp932 to JIS.\r
+        */\r
+       public static String toJIS(String s) {\r
+               StringBuffer sb = new StringBuffer();\r
+               char c;\r
+\r
+               if (s != null) {\r
+                       for (int i = 0; i < s.length(); i++) {\r
+                               c = s.charAt(i);\r
+                               switch (c) {\r
+                                       case 0xff3c:    // FULLWIDTH REVERSE SOLIDUS ->\r
+                                               c = 0x005c;     // REVERSE SOLIDUS\r
+                                               break;\r
+                                       case 0xff5e:    // FULLWIDTH TILDE ->\r
+                                               c = 0x301c;     // WAVE DASH\r
+                                               break;\r
+                                       case 0x2225:    // PARALLEL TO ->\r
+                                               c = 0x2016;     // DOUBLE VERTICAL LINE\r
+                                               break;\r
+                                       case 0xff0d:    // FULLWIDTH HYPHEN-MINUS ->\r
+                                               c = 0x2212;     // MINUS SIGN\r
+                                               break;\r
+                                       case 0xffe0:    // FULLWIDTH CENT SIGN ->\r
+                                               c = 0x00a2;     // CENT SIGN\r
+                                               break;\r
+                                       case 0xffe1:    // FULLWIDTH POUND SIGN ->\r
+                                               c = 0x00a3;     // POUND SIGN\r
+                                               break;\r
+                                       case 0xffe2:    // FULLWIDTH NOT SIGN ->\r
+                                               c = 0x00ac; // NOT SIGN\r
+                                               break;\r
+                                       case 0x2015:    // HORIZONTAL BAR\r
+                                               c = 0x2014;     // EM DASH\r
+                                               break;\r
+                               }\r
+                               sb.append(c);\r
+                       }\r
+               }\r
+\r
+               if (s != null) {\r
+                       return new String(sb);\r
+               }\r
+               return s;\r
+       }\r
+\r
+       /*\r
+        * This method convert JIS to Cp932.\r
+        */\r
+       public static String toCp932(String s) {\r
+\r
+               StringBuffer sb = new StringBuffer();\r
+               char c;\r
+               for (int i = 0; i < s.length(); i++) {\r
+                       c = s.charAt(i);\r
+                       switch (c) {\r
+                               case 0x005c:    // REVERSE SOLIDUS ->\r
+                                       c = 0xff3c;     // FULLWIDTH REVERSE SOLIDUS\r
+                                       break;\r
+                               case 0x301c:    // WAVE DASH ->\r
+                                       c = 0xff5e;     // FULLWIDTH TILDE\r
+                                       break;\r
+                               case 0x2016:    // DOUBLE VERTICAL LINE ->\r
+                                       c = 0x2225;     // PARALLEL TO\r
+                                       break;\r
+                               case 0x2212:    // MINUS SIGN ->\r
+                                       c = 0xff0d;     // FULLWIDTH HYPHEN-MINUS\r
+                                       break;\r
+                               case 0x00a2:    // CENT SIGN ->\r
+                                       c = 0xffe0;     // FULLWIDTH CENT SIGN\r
+                                       break;\r
+                               case 0x00a3:    // POUND SIGN ->\r
+                                       c = 0xffe1;     // FULLWIDTH POUND SIGN\r
+                                       break;\r
+                               case 0x00ac:    // NOT SIGN ->\r
+                                       c = 0xffe2;     // FULLWIDTH NOT SIGN\r
+                                       break;\r
+                               case 0x2014 :   // EM DASH\r
+                                       c = 0x2015;     // HORIZONTAL BAR\r
+                       }\r
+                       sb.append(c);\r
+               }\r
+               return new String(sb);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/NumberUtils.java b/src/com/lavans/luz2/commons/NumberUtils.java
new file mode 100644 (file)
index 0000000..5058d6a
--- /dev/null
@@ -0,0 +1,148 @@
+package com.lavans.luz2.commons;\r
+\r
+import java.math.BigDecimal;\r
+import java.math.RoundingMode;\r
+import java.text.NumberFormat;\r
+import java.util.Locale;\r
+\r
+public class NumberUtils {\r
+       /** 数値フォーマッター */\r
+       private static NumberFormat nf  = NumberFormat.getInstance(Locale.JAPANESE);\r
+\r
+       /** 値段フォーマットの埋め文字 * */\r
+       public static final String      HYPHEN  = "-";\r
+\r
+       /**\r
+        * パラメータに従って数値を修飾する\r
+        *\r
+        * @param value\r
+        *            修飾する対象の数値\r
+        * @param scale\r
+        *            小数点以下桁数。NumberFormatに任せる場合は-1を指定する。\r
+        *                        NumberFormatを使用した場合、小数点桁数を指定できない。\r
+        * @param plusSign\r
+        *            true:正の場合+を付加する false:何もしない\r
+        * @return 修飾後の文字列\r
+        */\r
+       public String numberFormat(BigDecimal value, int scale, boolean plusSign) {\r
+               //対象の数値が未設定の場合"-"(ハイフン)を返す\r
+               if (value == null) {\r
+                       return HYPHEN;\r
+               }\r
+\r
+               String result = null;\r
+\r
+               // 数値のフォーマット\r
+               if(scale<0){\r
+                       // scaleの指定がマイナス指定なら小数点桁数指定なしでフォーマットする。\r
+                       result = nf.format(value);\r
+               }else{\r
+                       // scaleが0以上なら指定した桁数のDecimalFormatを使う\r
+                       result = formatScale(value, scale);\r
+               }\r
+\r
+               // 符号毎の色を付ける\r
+               if (plusSign && (value.signum() == 1)) {\r
+                       // +\r
+                       result = "+" + result;\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        *\r
+        * @param value\r
+        * @return\r
+        */\r
+       public static String numberFormat(BigDecimal value) {\r
+               //対象の数値が未設定の場合"-"(ハイフン)を返す\r
+               if (value == null) {\r
+                       return HYPHEN;\r
+               }\r
+               String result = nf.format(value);\r
+               return result;\r
+       }\r
+\r
+\r
+       /**\r
+        * 小数点桁数指定でフォーマットする。\r
+        * @param decimal\r
+        * @param scale\r
+        * @return String\r
+        */\r
+       public static String formatScale(BigDecimal value, int scale) {\r
+               //対象の数値が未設定の場合"-"(ハイフン)を返す\r
+               if (value == null) {\r
+                       return HYPHEN;\r
+               }\r
+\r
+               String result;\r
+               value = value.setScale(scale, RoundingMode.HALF_UP);\r
+\r
+               NumberFormat scaleFormat = NumberFormat.getInstance();\r
+               scaleFormat.setMinimumFractionDigits(scale);\r
+               scaleFormat.setMaximumFractionDigits(scale);\r
+\r
+//             StringBuffer fill = new StringBuffer("");\r
+//             if (scale > 0) {\r
+//                     fill.append(".");\r
+//                     for (int i = 0; i < scale; i++) {\r
+//                             fill.append("0");\r
+//                     }\r
+//             }\r
+//             DecimalFormat df = new DecimalFormat("#,##0" + fill.toString());\r
+               result = scaleFormat.format(value);\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * 符号付きフォーマット\r
+        * @param value\r
+        * @return\r
+        */\r
+       public static String formatSigned(int value){\r
+               NumberFormat nf = NumberFormat.getInstance();\r
+               String result = nf.format(value);\r
+               if(value>0){\r
+                       result = "+"+result;\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * 数値かどうか判定する。\r
+        * 桁区切りカンマ(,)を許可しない\r
+        *\r
+        * @param src\r
+        * @return\r
+        */\r
+       public static boolean isNumeric(String src) {\r
+               return isNumeric(src, false);\r
+       }\r
+\r
+       /**\r
+        * 数値かどうか判定する。\r
+        * 桁区切りカンマ(,)を許可を指定する。true: 許可 false:非許可\r
+        *\r
+        * @param src\r
+        * @return\r
+        */\r
+       public static boolean isNumeric(String src, boolean hasComma) {\r
+               if (src == null) {\r
+                       return false;\r
+               }\r
+\r
+               src = src.trim();\r
+               for (int i = 0; i < src.length(); i++) {\r
+                       // 数値またはピリオド以外なら\r
+                       if (!Character.isDigit(src.charAt(i)) && src.charAt(i) != '.' &&\r
+                               // カンマ非許可ならカンマ以外もアウト\r
+                               !(hasComma && src.charAt(i) == ',')) {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               return true;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/ObjectUtils.java b/src/com/lavans/luz2/commons/ObjectUtils.java
new file mode 100644 (file)
index 0000000..5d4fb43
--- /dev/null
@@ -0,0 +1,14 @@
+package com.lavans.luz2.commons;\r
+\r
+public class ObjectUtils extends org.apache.commons.lang.ObjectUtils{\r
+       /**\r
+        * return array[0] value. if value is null then return "";\r
+        * @param strs\r
+        * @return\r
+        */\r
+       public static String toString(String strs[]){\r
+               if(strs==null) return "";\r
+               if(strs.length==0) return "";\r
+               return org.apache.commons.lang.ObjectUtils.toString(strs[0]);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/StringEscapeUtils.java b/src/com/lavans/luz2/commons/StringEscapeUtils.java
new file mode 100644 (file)
index 0000000..168402b
--- /dev/null
@@ -0,0 +1,35 @@
+package com.lavans.luz2.commons;\r
+\r
+/**\r
+ * http://commons.apache.org/lang/api-release/index.html\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class StringEscapeUtils extends org.apache.commons.lang.StringEscapeUtils{\r
+       public static String escapeSql(String sql){\r
+               String result = sql;\r
+               // セミコロンは排除\r
+               result = result.replace(";", "");\r
+               // シングルクオートのエスケープは二つ並べる\r
+               result = result.replace("'", "''");\r
+               // バクスラ\r
+               result = result.replace("\\", "\\\\");\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * LIKE検索用のエスケープ処理\r
+        * @param sql\r
+        * @return\r
+        */\r
+       public static String escapeSqlLike(String sql){\r
+               String result = sql;\r
+               // % 任意の文字列\r
+               result = result.replace("%", "\\%");\r
+               // _ 任意の一文字\r
+               result = result.replace("_", "\\_");\r
+\r
+               return result;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/StringUtils.java b/src/com/lavans/luz2/commons/StringUtils.java
new file mode 100644 (file)
index 0000000..3e87bb3
--- /dev/null
@@ -0,0 +1,163 @@
+/* $Id: StringUtils.java 249 2011-02-01 14:28:42Z dobashi $\r
+ * created: 2005/08/10\r
+ */\r
+package com.lavans.luz2.commons;\r
+\r
+\r
+/**\r
+ * commonsのStringUtils拡張クラス\r
+ * TODO commonsと似たようなメソッドの整理\r
+ *\r
+ * @see http://commons.apache.org/lang/api-release/index.html\r
+ * @author dobashi\r
+ */\r
+public class StringUtils extends org.apache.commons.lang.StringUtils{\r
+       /** logger */\r
+       // private static Log logger = LogFactory.getLog(StringUtil.class.getName());\r
+\r
+       /**\r
+        * 意味区切りアンダーバーを大文字に変換。 customer_id -> customerId.\r
+        *\r
+        * @param str\r
+        * @return\r
+        */\r
+       public static String toCamelCase(String str) {\r
+               // check empty\r
+               if(isEmpty(str)) return str;\r
+\r
+               // all letters shoud be lowered\r
+               str = str.toLowerCase();\r
+\r
+               StringBuffer buf = new StringBuffer(str.length());\r
+               String[] token = str.split("_");\r
+               buf.append(token[0]);\r
+               // 2語目以降は最初の文字を大文字にして追加。\r
+               for (int i = 1; i < token.length; i++) {\r
+                       buf.append(capitalize(token[i]));\r
+               }\r
+               return buf.toString();\r
+       }\r
+\r
+       /**\r
+        * 意味区切り大文字をアンダーバーに変換。 customerId -> customer_id\r
+        * 一文字目が大文字の場合は小文字にするだけ。\r
+        * @param str\r
+        * @return\r
+        */\r
+       public static String toUnderscore(String str) {\r
+               // check empty\r
+               if(isEmpty(str)) return str;\r
+\r
+               // toLower first letter.\r
+               if(Character.isUpperCase(str.charAt(0))){\r
+                       str = uncapitalize(str);\r
+               }\r
+\r
+               // change upper case to underscore\r
+               StringBuffer buf = new StringBuffer(str.length());\r
+               for(char ch: str.toCharArray()){\r
+                       if(Character.isUpperCase(ch)){\r
+                               buf.append("_").append(Character.toLowerCase(ch));\r
+                       }else{\r
+                               buf.append(ch);\r
+                       }\r
+               }\r
+               return buf.toString();\r
+       }\r
+\r
+       /**\r
+        * インデント\r
+        *\r
+        * @param str\r
+        * @param indent\r
+        * @return\r
+        */\r
+       public static String indent(String str, int indent){\r
+               StringBuffer buf = new StringBuffer(str.length());\r
+               String[] lines = str.split("\n");\r
+               for(String line: lines){\r
+                       buf.append(repeat("\t", indent)).append(line).append("\n");\r
+               }\r
+\r
+               return buf.toString();\r
+       }\r
+\r
+       /**\r
+        * String配列をカンマ区切り文字列に変換。クオート付き。\r
+        *\r
+        * @param list\r
+        * @param quote\r
+        *            クオート文字列\r
+        * @return\r
+        */\r
+       public static String joinQuote(String strs[], String delim, String quote) {\r
+               StringBuffer buf = new StringBuffer();\r
+               for (int i = 0; i < strs.length; i++) {\r
+                       if(org.apache.commons.lang.StringUtils.isEmpty(strs[i])){\r
+                               continue;\r
+                       }\r
+                       buf.append(delim + quote + strs[i] + quote);\r
+               }\r
+               // 1件も無ければ空文字列\r
+               if(buf.length()==0){\r
+                       return "";\r
+               }\r
+               return buf.substring(delim.length());\r
+       }\r
+\r
+\r
+       /**\r
+        * splitした各itemをtrim()して返す。\r
+        *\r
+        * @param list\r
+        * @return\r
+        */\r
+       public static String[] splitTrim(String str, String delim) {\r
+               if(str==null){\r
+                       return new String[0];\r
+               }\r
+               String strs[] = str.split(delim);\r
+               for (int i = 0; i < strs.length; i++) {\r
+                       strs[i] = strs[i].trim();\r
+               }\r
+               return strs;\r
+       }\r
+\r
+       /**\r
+        * バイト配列を16進数の文字列にする。\r
+        *\r
+        * @param b\r
+        * @param delim\r
+        *            区切り文字":"など\r
+        * @return\r
+        */\r
+       public static String toHex(byte[] b, String delim) {\r
+               StringBuffer buf = new StringBuffer(b.length);\r
+               for (int i = 0; i < b.length; i++) {\r
+                       int c = b[i] & 0xFF;\r
+                       String hex = Integer.toHexString(c);\r
+                       if (hex.length() == 1)\r
+                               hex = "0" + hex;\r
+                       buf.append(delim + hex);\r
+               }\r
+\r
+               return buf.substring(delim.length());\r
+       }\r
+\r
+       /**\r
+        * 16進数テキストをバイト配列に変換する。 toHex()の逆。\r
+        *\r
+        * @param str\r
+        * @param delim\r
+        * @return\r
+        */\r
+       public static byte[] toByte(String str, String delim) {\r
+               int tokenLength = 2 + delim.length();\r
+               byte[] b = new byte[(str.length() + delim.length()) / tokenLength];\r
+               for (int i = 0; i < b.length; i++) {\r
+                       b[i] = (byte) Integer.parseInt(str.substring(i * tokenLength, i * tokenLength + 2), 16);\r
+               }\r
+\r
+               return b;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/commons/Validator.java b/src/com/lavans/luz2/commons/Validator.java
new file mode 100644 (file)
index 0000000..cead71e
--- /dev/null
@@ -0,0 +1,74 @@
+/* $Id: Validator.java 409 2011-07-28 23:04:59Z dobashi $\r
+ * create: 2004/12/28\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.commons;\r
+\r
+import java.util.List;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class Validator {\r
+       private static Log logger = LogFactory.getLog(Validator.class.getName());\r
+\r
+       /**\r
+        * 汎用validator\r
+        * @param item\r
+        * @return\r
+        */\r
+       public static boolean isValid(String xpath, String item){\r
+               // check item is null\r
+               if(org.apache.commons.lang.StringUtils.isEmpty(item)){\r
+                       return false;\r
+               }\r
+\r
+               boolean result = false;\r
+               try {\r
+                       String regex = Config.getInstance().getNodeValue("/luz/validator/"+xpath);\r
+                       result = item.matches(regex);\r
+               } catch (XPathExpressionException e) {\r
+                       logger.info("validator path is invalid["+ xpath +"]");\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * メールアドレスモバイルチェック用一覧。\r
+        */\r
+       private static List<String> domainList = null;\r
+       static{\r
+               try {\r
+                       domainList = Config.getInstance().getNodeValueList("/luz/mobile_mail/domain");\r
+               } catch (XPathExpressionException e) {\r
+                       logger.info("携帯メールドメイン指定無し");\r
+               }\r
+       }\r
+       /**\r
+        * メールアドレス、ドメイン部がモバイルかチェック\r
+        * @param item\r
+        * @return\r
+        */\r
+       public static boolean isValidMailMobile(String item){\r
+               for(String domain: domainList){\r
+                       if(item.contains(domain)){\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+//             if(item.matches("[\\w-._? +]+@[\\w-._]+.[\\w.-_]+")){\r
+                       //              if(item.matches("[\\d]{2,5}-[\\d]{1,4}-[\\d]{4}")){\r
+//             if(item.matches("[\\d]{3}-[\\d]{4}")){\r
+}\r
diff --git a/src/com/lavans/luz2/controller/ActionInfo.java b/src/com/lavans/luz2/controller/ActionInfo.java
new file mode 100644 (file)
index 0000000..591756d
--- /dev/null
@@ -0,0 +1,115 @@
+package com.lavans.luz2.controller;\r
+\r
+import java.lang.reflect.Method;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.util.Config;\r
+\r
+public class ActionInfo {\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(ActionInfo.class);\r
+       private static final String METHOD_DEFAULT="execute";\r
+       /** プレゼンテーション層のパッケージ。ActionとJsp保管場所 */\r
+       private static String basePath;\r
+       private static String actionPath; // "action";\r
+       private static String jspPath; // "jsp";\r
+       private static String actionSuffix=".do";\r
+\r
+       static{\r
+               // TODO 設定ファイル名を指定できるように\r
+               Config config = Config.getInstance("luz2.xml");\r
+               try {\r
+                       basePath = config.getNodeValue("/root/presentationPath/base");\r
+                       actionPath = config.getNodeValue("/root/presentationPath/action");\r
+                       // if path has value, add "."\r
+                       if(!StringUtils.isEmpty(actionPath)){ actionPath += "."; }\r
+                       jspPath = config.getNodeValue("/root/presentationPath/jsp");\r
+                       if(!StringUtils.isEmpty(actionPath)){ jspPath += "."; }\r
+               } catch (XPathExpressionException e) {\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * アクションへのパスからアクションクラスを作成。\r
+        * パスにはsuffix(.do)は含まれていない\r
+        *\r
+        *\r
+        * path: com.company.project.presentation.admin.action.main\r
+        * action: MenuActionのインスタンス\r
+        * method: MenuAction#input()\r
+        *\r
+        * @param actionName\r
+        * @return\r
+        * @throws ClassNotFoundException\r
+        * @throws IllegalAccessException\r
+        * @throws InstantiationException\r
+        * @throws NoSuchMethodException\r
+        * @throws SecurityException\r
+        */\r
+       static ActionInfo getInfo(String actionURI) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException {\r
+               // suffixの除去\r
+               // "action:"で指定された場合はsuffixが付いてないこともある\r
+               if(actionURI.endsWith(actionSuffix)){\r
+                       actionURI = actionURI.substring(0,actionURI.length()-actionSuffix.length());\r
+               }\r
+\r
+\r
+               ActionInfo info = new ActionInfo();\r
+               // actionURI="/admin/action/main/Menu!input"\r
+               String relativePath = actionURI.substring(0,actionURI.lastIndexOf("/")).replace("/",".");\r
+               // path="com.company.project.presentation.admin.action.main";\r
+               info.path=basePath + relativePath+".";\r
+\r
+               // actionName = "MenuAction"\r
+               // methodName = "input"\r
+               String lastPath = actionURI.substring(actionURI.lastIndexOf("/")+1);\r
+               String actionName, methodName;\r
+               if(lastPath.contains("!")){\r
+                       String names[] = lastPath.split("!");\r
+                       actionName = names[0];\r
+                       methodName = names[1];\r
+               }else{\r
+                       // "!"が無い場合\r
+                       actionName = lastPath;\r
+                       methodName = METHOD_DEFAULT;\r
+               }\r
+               actionName +="Action";\r
+\r
+               // Get Action instance\r
+               Class<? extends Object> actionClass = null;\r
+               String actionFqdn=info.path + actionPath + actionName;\r
+               logger.debug(actionFqdn);\r
+\r
+               try {\r
+                       // BeanManagerからとってくればSingletonとprototypeの設定可能。\r
+                       // とりあえずproto\r
+                       //BeanManagerXml.getBean(id)\r
+                       actionClass = Class.forName(actionFqdn);\r
+                       info.action = actionClass.newInstance();\r
+               } catch (ClassNotFoundException e) {\r
+                       // クラスが存在しない場合デフォルトのアクション\r
+                       // このパッケージに対応したものにする?\r
+                       logger.debug("["+ actionFqdn +"] is not exist. Use default action.");\r
+                       actionClass = DefaultAction.class;\r
+                       info.action = new DefaultAction(actionName, actionPath, jspPath);\r
+                       // if action is default, so method should be "execute";\r
+                       if(!methodName.equals(METHOD_DEFAULT)){\r
+                               logger.warn("["+ actionName +"#"+ methodName +"()] does not execute.");\r
+                               methodName = METHOD_DEFAULT;\r
+                       }\r
+               }\r
+               info.method = actionClass.getMethod(methodName);\r
+\r
+               return info;\r
+       }\r
+\r
+       Object action;\r
+       Method method;\r
+       String path;\r
+}\r
diff --git a/src/com/lavans/luz2/controller/ActionServlet.java b/src/com/lavans/luz2/controller/ActionServlet.java
new file mode 100644 (file)
index 0000000..f66e18f
--- /dev/null
@@ -0,0 +1,203 @@
+package com.lavans.luz2.controller;\r
+\r
+import java.io.IOException;\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import javax.servlet.ServletException;\r
+import javax.servlet.http.HttpServlet;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletRequestWrapper;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * lacoder main servlet\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class ActionServlet extends HttpServlet {\r
+       /** logger */\r
+       private static final Log logger = LogFactory.getLog(ActionServlet.class);\r
+\r
+       /**      */\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       private static String encoding=null;\r
+       static{\r
+               // TODO be able to change config file name.\r
+               Config config = Config.getInstance("luz2.xml");\r
+               try {\r
+                       encoding = config.getNodeValue("/root/encoding");\r
+               } catch (XPathExpressionException e) {\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
+\r
+\r
+       @Override\r
+       protected void doPost(HttpServletRequest requestOrg, HttpServletResponse response)\r
+       throws ServletException, IOException {\r
+               doService(requestOrg, response);\r
+       }\r
+       @Override\r
+       protected void doGet(HttpServletRequest requestOrg, HttpServletResponse response)\r
+                       throws ServletException, IOException {\r
+               doService(requestOrg, response);\r
+       }\r
+\r
+       //@SuppressWarnings("unchecked")\r
+       protected void doService(HttpServletRequest requestSrc, HttpServletResponse response)\r
+               throws ServletException, IOException {\r
+               // POSTデータのエンコーディング指定\r
+               // GETで日本語を扱う場合にはserver.xmlのConnectorにURIEncodingを指定する。\r
+               // この設定の前にreq.getParameterしてしまうとキャッシュされてしまうようなので注意。\r
+//             logger.debug(StringUtils.isEmpty(requestSrc.getParameter("member.memberName"))?"":new String(requestSrc.getParameter("member.memberName").getBytes("ISO_8859_1"),"UTF-8"));\r
+               if(!StringUtils.isEmpty(encoding)){\r
+                       requestSrc.setCharacterEncoding(encoding);\r
+               }\r
+\r
+               // wrap for\r
+               HttpRequestParamWrapper request= new HttpRequestParamWrapper(requestSrc);\r
+\r
+               // DynamicMethodInvocation\r
+               // "action:"で始まる指定があればそれを優先。form等でaction先を変更できる。\r
+               String actionURI = getActionFromParam(request);\r
+               if(StringUtils.isEmpty(actionURI)){\r
+                       // パラメータ指定がなければRequestURIから。\r
+                       actionURI = request.getServletPath();\r
+               }\r
+               logger.debug("action.uri="+actionURI);\r
+\r
+\r
+               // Actionの実行。\r
+               // jspのパスはActionからの相対パス。\r
+               String jspFile;\r
+               try {\r
+                       // ActionInfo取得\r
+                       ActionInfo info = ActionInfo.getInfo(actionURI);\r
+//                     logger.debug("action.path  ="+info.path);\r
+//                     logger.debug("action.action="+info.action.getClass().getSimpleName());\r
+//                     logger.debug("action.method="+info.method.getName());\r
+                       ActionSupport actionSupport = null;\r
+\r
+                       // ActionSupport\r
+                       // set request & response.\r
+                       if(info.action instanceof ActionSupport){\r
+                               actionSupport = (ActionSupport)info.action;\r
+                               actionSupport.setRequest(request);\r
+                               ((ActionSupport)info.action).setResponse(response);\r
+                       }\r
+\r
+                       logger.debug("- - - - - - "+ info.action.getClass().getName() +"!"+ info.method.getName() +"() start - - - - - - -");\r
+                       jspFile = (String)info.method.invoke(info.action);\r
+                       logger.debug("- - - - - - "+ info.action.getClass().getName() +"!"+ info.method.getName() +"() end - - - - - - -");\r
+\r
+                       // ActionSupport\r
+                       if(info.action instanceof ActionSupport){\r
+                               // do post method action\r
+                               doPostMethod((ActionSupport)info.action);\r
+                               // check chain action.\r
+                               if(!StringUtils.isEmpty(actionSupport.getChainAction())){\r
+                                       // to remove "ChainAction", request parameter must be modifiable\r
+                                       request.parameterMap.put(actionSupport.getChainAction(), null);\r
+                                       // for action, it must be unmodifiable.\r
+                                       doGet(request, response);\r
+                               }\r
+                       }\r
+                       if(!response.isCommitted()){\r
+                               getServletContext().getRequestDispatcher("/WEB-INF/classes/"+info.path.replace(".","/")+jspFile).forward(request, response);\r
+                       }\r
+                       response.flushBuffer();\r
+               } catch (InvocationTargetException e) {\r
+                       // Actionのメソッドで例外が出た場合\r
+                       // InvocationTargetExceptionを飛ばして実際に起きた例外をcauseとする\r
+                       if(e.getCause()!=null){\r
+                               logger.error("Servlet service error.",e.getCause());\r
+                               throw new ServletException(e.getCause());\r
+                       }\r
+                       throw new ServletException(e);\r
+               } catch (ServletException e) {\r
+                       // Chainして来た場合もInvocationと同様\r
+                       if(e.getCause()!=null){\r
+                               logger.error("Servlet service error.",e.getCause());\r
+                               throw new ServletException(e.getCause());\r
+                       }\r
+                       throw new ServletException(e);\r
+               } catch (Exception e) {\r
+                       logger.error("Servlet service error.",e);\r
+                       throw new ServletException(e);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータからAction!Method取得、\r
+        * "action:"で始まる\r
+        *\r
+        * @param req\r
+        * @return\r
+        */\r
+///    @SuppressWarnings("unchecked")\r
+       private String getActionFromParam(HttpRequestParamWrapper request){\r
+\r
+               String action = null;\r
+               Iterator<String> ite = request.parameterMap.keySet().iterator();\r
+               //request.getParameterNames();\r
+               while(ite.hasNext()){\r
+                       String parameterName = ite.next();\r
+                       // find parameter starting with "action:"\r
+                       if(parameterName.startsWith("action:")){\r
+                               action = parameterName.substring("action:".length());\r
+                               // remove action-parameter from parameter map\r
+                               ite.remove();\r
+                               logger.debug("action.param :"+parameterName);\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               // if action starts with not "/", the next action path is relative path from prev action.\r
+               if(action!=null && !action.startsWith("/")){\r
+                       String servletPath = request.getServletPath();\r
+                       action = servletPath.substring(0, servletPath.lastIndexOf("/")) +"/"+ action;\r
+               }\r
+               return action;\r
+       }\r
+\r
+       /**\r
+        * do somethig after method executed.\r
+        * @param action\r
+        */\r
+       private void doPostMethod(ActionSupport action){\r
+               action.getRequest().setAttribute("actionErrors", action.getActionErrors());\r
+               action.getRequest().setAttribute("fieldErrors", action.getFieldErrors());\r
+       }\r
+\r
+       /**\r
+        * wrap for temporary access to request parameters.\r
+        * @author dobashi\r
+        *\r
+        */\r
+       private class HttpRequestParamWrapper extends HttpServletRequestWrapper {\r
+               private Map<String, Object[]> parameterMap;\r
+               @SuppressWarnings("unchecked")\r
+               public HttpRequestParamWrapper(HttpServletRequest request) {\r
+                       super(request);\r
+                       parameterMap = new HashMap<String, Object[]>(request.getParameterMap());\r
+               }\r
+\r
+               @Override\r
+               public Map<String, Object[]> getParameterMap() {\r
+                       return Collections.unmodifiableMap(parameterMap);\r
+               }\r
+       }\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/controller/ActionSupport.java b/src/com/lavans/luz2/controller/ActionSupport.java
new file mode 100644 (file)
index 0000000..d10a8c8
--- /dev/null
@@ -0,0 +1,96 @@
+package com.lavans.luz2.controller;\r
+\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+\r
+public class ActionSupport {\r
+       private HttpServletRequest request;\r
+       private HttpServletResponse response;\r
+\r
+       /** action error messages */\r
+       private List<String> actionErrors = new ArrayList<String>();\r
+       /** field error messages.  */\r
+       private Map<String, String> fieldErrors = new HashMap<String, String>();\r
+\r
+       private String chainAction = null;\r
+       public String getChainAction() {\r
+               return chainAction;\r
+       }\r
+//     @SuppressWarnings("unchecked")\r
+       public void setChainAction(String chainAction) {\r
+               if(!chainAction.startsWith("action:")){\r
+                       chainAction = "action:"+chainAction;\r
+               }\r
+               this.chainAction = chainAction;\r
+       }\r
+\r
+       /**\r
+        * リダイレクト先を指定\r
+        * @param url\r
+        * @throws IOException\r
+        */\r
+       public void setRedirect(String url) throws IOException {\r
+               // "/"で始まるならContextPathを足す\r
+               if(url.startsWith("/")){\r
+                       url = request.getContextPath()+url;\r
+               }\r
+               url = response.encodeRedirectURL(url);\r
+               response.sendRedirect(url);\r
+       }\r
+\r
+       public HttpServletRequest getRequest() {\r
+               return request;\r
+       }\r
+       public void setRequest(HttpServletRequest request) {\r
+               this.request = request;\r
+       }\r
+       public HttpServletResponse getResponse() {\r
+               return response;\r
+       }\r
+       public void setResponse(HttpServletResponse response) {\r
+               this.response = response;\r
+       }\r
+\r
+       /**\r
+        * set request attribute\r
+        * @param key\r
+        * @param value\r
+        */\r
+       public void setAttribute(String key, Object value){\r
+               request.setAttribute(key, value);\r
+       }\r
+       /**\r
+        * Add Action Error.\r
+        * @param key\r
+        * @param message\r
+        */\r
+       public void addActionError(String message){\r
+               actionErrors.add(message);\r
+       }\r
+       public void addActionErrors(Collection<String> messages){\r
+               actionErrors.addAll(messages);\r
+       }\r
+       public List<String> getActionErrors(){\r
+               return actionErrors;\r
+       }\r
+\r
+       /**\r
+        * Add Field Error.\r
+        * @param key\r
+        * @param message\r
+        */\r
+       public void addFieldError(String key, String message){\r
+               fieldErrors.put(key, message);\r
+       }\r
+       public Map<String, String> getFieldErrors(){\r
+               return fieldErrors;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/controller/DefaultAction.java b/src/com/lavans/luz2/controller/DefaultAction.java
new file mode 100644 (file)
index 0000000..09e9105
--- /dev/null
@@ -0,0 +1,16 @@
+package com.lavans.luz2.controller;\r
+\r
+public class DefaultAction {\r
+       private String actionName;\r
+       private String actionPath;\r
+       private String jspPath;\r
+       public DefaultAction(String actionName, String actionPath, String jspPath){\r
+               this.actionName = actionName;\r
+               this.actionPath = actionPath;\r
+               this.jspPath = jspPath;\r
+       }\r
+       public String execute(){\r
+               // TODO replace last\r
+               return actionName.replace("Action",".jsp").replace(actionPath, jspPath);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/AccessLogFilter.java b/src/com/lavans/luz2/http/AccessLogFilter.java
new file mode 100644 (file)
index 0000000..4294948
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: AccessLogFilter.java 94 2008-12-18 11:07:17Z dobashi $ */\r
+package com.lavans.luz2.http;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.servlet.Filter;\r
+import javax.servlet.FilterChain;\r
+import javax.servlet.FilterConfig;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.ServletRequest;\r
+import javax.servlet.ServletResponse;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class AccessLogFilter implements Filter {\r
+       private static Log logger = LogFactory.getLog(AccessLogFilter.class.getName());\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)\r
+        */\r
+       public void init(FilterConfig filterConfig) throws ServletException {\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)\r
+        */\r
+       public void doFilter(ServletRequest req, ServletResponse res,\r
+                       FilterChain chain) throws IOException, ServletException {\r
+\r
+           // HttpServletRequest\r
+               HttpServletRequest request = (HttpServletRequest) req;\r
+           String userId = getUserId(request);\r
+\r
+               // アクションのレスポンスタイムを表示(jsp処理は含まず)\r
+               long startTime = System.currentTimeMillis();\r
+\r
+               chain.doFilter(req, res);\r
+\r
+           // 実行時間のログを出力\r
+           long delta = System.currentTimeMillis() - startTime;\r
+\r
+               logger.info(userId + "\t"+ request.getServletPath() +"\t"+ delta + " ms\t");\r
+       }\r
+\r
+    /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#destroy()\r
+        */\r
+       public void destroy() {\r
+\r
+       }\r
+\r
+       /**\r
+        * ユーザーIDの取得\r
+        * @param session\r
+        * @return\r
+        */\r
+       protected String getUserId(HttpServletRequest request){\r
+               HttpSession session = request.getSession();\r
+               String userId = request.getRemoteHost()+"\t"+session.getId();\r
+               return userId;\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/AccessData.java b/src/com/lavans/luz2/http/session/AccessData.java
new file mode 100644 (file)
index 0000000..570b3c3
--- /dev/null
@@ -0,0 +1,43 @@
+/* $Id: AccessData.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2006/10/27\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.io.Serializable;\r
+\r
+/**\r
+ * アクセスデータ\r
+ * \r
+ * @author dobashi\r
+ */\r
+public class AccessData implements Serializable{\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = 3602615429345476439L;\r
+       private int count;\r
+       private long lastAccessTime;\r
+       public AccessData(int maxAccessCount){\r
+               init(maxAccessCount);\r
+       }\r
+       public void init(int maxAccessCount){\r
+               count = maxAccessCount+1;\r
+               lastAccessTime = System.currentTimeMillis();\r
+       }\r
+       /**\r
+        * @return count を戻します。\r
+        */\r
+       public int getCount() {\r
+               return count;\r
+       }\r
+       /**\r
+        * @return lastAccessTime を戻します。\r
+        */\r
+       public long getLastAccessTime() {\r
+               return lastAccessTime;\r
+       }\r
+       \r
+       public void decreaseCount(){\r
+               count--;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/AccessFilter.java b/src/com/lavans/luz2/http/session/AccessFilter.java
new file mode 100644 (file)
index 0000000..8827acc
--- /dev/null
@@ -0,0 +1,118 @@
+/* $Id: AccessFilter.java 411 2011-07-28 23:05:04Z dobashi $\r
+ * created: 2006/01/20\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.servlet.Filter;\r
+import javax.servlet.FilterChain;\r
+import javax.servlet.FilterConfig;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.ServletRequest;\r
+import javax.servlet.ServletResponse;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpSession;\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+\r
+/**\r
+ * 連続アクセスを制御するフィルター。\r
+ * セッションIDまたは口座番号をキーとしてアクセス回数をカウントする。\r
+ * 1秒以内に規定回数以上のアクセスがあったら、エラーとする。\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class AccessFilter implements Filter {\r
+       /** 設定ファイル読込クラス */\r
+       private static Config config = Config.getInstance();\r
+\r
+    /** オーバーフローがあった場合のフラグ */\r
+    public static final String ACCESS_FLG = "access_flg";\r
+\r
+    /**  */\r
+    public static final String ACCESSDATA_KEY = "accessdata_key";\r
+\r
+       /** アクセスのインターバル(ミリ秒) */\r
+       private static final long ACCESS_INTERVAL = 1000;\r
+\r
+       /** アクセスの可能回数 */\r
+       private static int maxAccessCount = 10;\r
+\r
+       static{\r
+               String accControl = null;\r
+               try {\r
+                       accControl = config.getNodeValue("/luz/http/access_control");\r
+               } catch (XPathExpressionException e) {\r
+               }\r
+               if(!accControl.equals("")){\r
+                       // 未指定ならデフォルトの10とする。\r
+                       maxAccessCount = Integer.parseInt(accControl);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * 1秒あたりのアクセス回数をチェックする。\r
+        * 個別のActionクラスでアクセス解除できるように、ここではセッションにフラグを\r
+        * 立てるだけで例外はThrowしない。ここで例外をThrowすると、画像の一覧表示などが\r
+        * できなくなる。\r
+        */\r
+       public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {\r
+           // セッション管理ロジック\r
+           HttpSession session = ((HttpServletRequest)req).getSession();\r
+\r
+           // 0以下ならアクセスチェック無し\r
+           if(maxAccessCount<1){\r
+                       chain.doFilter(req, res);\r
+                       return;\r
+           }\r
+\r
+           // セッションIDをキーにアクセス数を取得する。\r
+               AccessData data = (AccessData)session.getAttribute(ACCESSDATA_KEY);\r
+               if(data==null){\r
+                       data = new AccessData(maxAccessCount);\r
+                       session.setAttribute(ACCESSDATA_KEY, data);\r
+               }\r
+           // 毎回時刻比較を行わなくて済むように、maxのカウント数を入れておいて\r
+           // カウントが0になったときだけ比較するようにする。\r
+\r
+        // アクセス可能回数をチェック\r
+        if(data.getCount()>0){\r
+                   // アクセス可能回数を減らす\r
+               data.decreaseCount();\r
+        }else{\r
+               // カウントが0になった\r
+            // 前回のアクセス時刻、現在時刻を取得\r
+           long now = System.currentTimeMillis();\r
+                   // 現在時刻と10回前のアクセス時刻の差をチェック\r
+                   if((now - data.getLastAccessTime()) < ACCESS_INTERVAL){\r
+                       // 1秒以内ならエラーフラグをセット\r
+                       session.setAttribute(ACCESS_FLG, req.getRemoteAddr());\r
+//                     throw new AccessOverFlowException("Too many access from["+ req.getRemoteAddr() +":"+ session.getId() +"]");\r
+                   }else{\r
+                       // 1秒以上たっているなら初期化\r
+                       data.init(maxAccessCount);\r
+                       session.removeAttribute(ACCESS_FLG);\r
+                   }\r
+        }\r
+\r
+               chain.doFilter(req, res);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)\r
+        */\r
+       public void init(FilterConfig arg0) throws ServletException {\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#destroy()\r
+        */\r
+       public void destroy() {\r
+       }\r
+\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/http/session/AccessOverFlowException.java b/src/com/lavans/luz2/http/session/AccessOverFlowException.java
new file mode 100644 (file)
index 0000000..1efcf6e
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Id: AccessOverFlowException.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/13\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+/**\r
+ * @author sannaka\r
+ * @version 1.00\r
+ */\r
+public class AccessOverFlowException extends RuntimeException {\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       public AccessOverFlowException(String msg){\r
+               super(msg);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/RemoteHttpServletRequest.java b/src/com/lavans/luz2/http/session/RemoteHttpServletRequest.java
new file mode 100644 (file)
index 0000000..c8cd21a
--- /dev/null
@@ -0,0 +1,190 @@
+/* $Id: RemoteHttpServletRequest.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2006/01/20\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletRequestWrapper;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * 独自にセッションの実装を行うHttpRequest.\r
+ * jsessionidのjvmRoute部分を見て、他のサーバーのセッションで\r
+ * あればそのサーバーにRemoteSessionを返すよう問い合わせる。\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class RemoteHttpServletRequest extends HttpServletRequestWrapper {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(RemoteHttpServletRequest.class.getName());\r
+\r
+       private HttpSession session = null;\r
+\r
+       private static SessionServiceLocal serviceLocal = SessionServiceLocal.getInstance();\r
+       private static SessionServiceRemote serviceRemote = SessionServiceRemote.getInstance();\r
+\r
+       /**\r
+        * @param arg0\r
+        */\r
+       public RemoteHttpServletRequest(HttpServletRequest arg0) {\r
+               super(arg0);\r
+       }\r
+\r
+       /**\r
+        * セッション取得\r
+        * @see javax.servlet.http.HttpServletRequest#getSession()\r
+        */\r
+       @Override\r
+       public HttpSession getSession() {\r
+               return getSession(true);\r
+       }\r
+\r
+       /**\r
+        * セッション取得。\r
+        * @see javax.servlet.http.HttpServletRequest#getSession(boolean)\r
+        */\r
+       @Override\r
+       public HttpSession getSession(boolean isCreate) {\r
+               // すでに取得済みならそのセッションを返す。\r
+               if(session!=null){\r
+                       return getCacheSession(isCreate);\r
+               }\r
+\r
+               // このHttpRequestのセッションID\r
+               session = super.getSession(false);\r
+               if(session==null){\r
+                       // セッションが取得できないと言うことは、\r
+                       // 初回のアクセスかリモートセッション\r
+                       session = super.getSession();\r
+                       serviceLocal.setSession(session);\r
+               }\r
+\r
+               // このサーバーのセッションID\r
+               String sidSelf = session.getId();\r
+               // リクエストされたセッションID\r
+               String sidReq = super.getRequestedSessionId();\r
+//logger.debug("sidSelf/Request["+ sidSelf +"/"+ sidReq +"]");\r
+               // 上記2つが同一ならセッションをそのまま返す。\r
+               if(sidSelf.equals(sidReq)){\r
+                       return session;\r
+               }\r
+\r
+               // 自分のtomcat jvmRouteを取得。\r
+               String jvmSelf = "";\r
+               try {\r
+                       jvmSelf = sidSelf.split("\\.")[1];\r
+               } catch (Exception e) {\r
+                       logger.error("tomcatのserver.xmlにjvmRouteが指定されていない");\r
+               }\r
+               // リクエスト元のtomcat jvmRouteを取得。\r
+               String jvmReq="";\r
+               try{\r
+                       // sidReq==null, sidReq=""の場合や、.tomXXのついてないセッションIDの\r
+                       // 可能性がある\r
+                       jvmReq = sidReq.split("\\.")[1];\r
+               }catch (Exception e) {\r
+                       // 上記のエラーならローカル扱い\r
+                       sidReq = sidSelf;\r
+                       jvmReq = jvmSelf;\r
+                       logger.debug("sidReq:"+ sidReq);\r
+               }\r
+\r
+               // 同じjvmでsidが異なるケース\r
+               if(jvmReq.equals(jvmSelf)){\r
+                       if(isCreate){\r
+                               return session;\r
+                       }\r
+\r
+                       // 新規に作成してしまっているので破棄する。\r
+                       session.invalidate();\r
+                       return null;\r
+               }\r
+\r
+               // 違うjvmならリモートのセッションサービスを使用してセッション情報を取得。\r
+               return getRemoteSession(jvmReq, sidReq, sidSelf, isCreate);\r
+       }\r
+\r
+\r
+       /**\r
+        * キャッシュされているセッションが有効かどうか判定して返す。\r
+        * 無効の場合は新規作成する。\r
+        * @return\r
+        */\r
+       private HttpSession getCacheSession(boolean isCreate){\r
+               try{\r
+                       if(serviceLocal.exists(session.getId())){\r
+                               // ローカルで管理されているセッションなら\r
+                               return session;\r
+                       }\r
+               }catch (IllegalStateException e) {\r
+               }\r
+               // tomcat5.5.10~5.5.15ではsession.getId()でIllegalStateExceptionをthrowする。\r
+               // tomcat5.5.9以前と5.5.16以降では無効なセッションでもgetId()では例外を生成しない。\r
+               // したがって、前者ではinvalidateを呼ばれた後catchブロックを通ってここにくる。\r
+               // 後者ではinvalidateの後はseviceLocal.exists()==falseとなってここにくる。\r
+               session = super.getSession(isCreate);\r
+               if(session!=null){\r
+                       serviceLocal.setSession(session);\r
+               }\r
+               return session;\r
+       }\r
+\r
+       /**\r
+        * キャッシュされているセッションが有効かどうか判定して返す。\r
+        * 無効の場合は新規作成する。\r
+        * @return\r
+        */\r
+       private HttpSession getRemoteSession(String jvmReq, String sidReq,  String sidSelf, boolean isCreate){\r
+\r
+               logger.debug("session remote:"+ sidReq +"->"+ sidSelf);\r
+\r
+               try {\r
+                       Map<String, Object> remoteSessionAttr = serviceRemote.getRemoteSessionAttribute(jvmReq, sidReq);\r
+                       // 取得に失敗した場合\r
+                       if(remoteSessionAttr==null){\r
+                               if(isCreate){\r
+                                       // 生成モードなら\r
+                                       return session;\r
+                               }\r
+                               // 新規に作成してしまっているので破棄する。\r
+                               session.invalidate();\r
+                               return null;\r
+                       }\r
+\r
+                       // ローカルのセッションにリモートの属性を書き込む\r
+                       Iterator<String> attrNamesIte = remoteSessionAttr.keySet().iterator();\r
+                       StringBuffer debugStr = new StringBuffer();\r
+                       debugStr.append("session copy:");\r
+                       while(attrNamesIte.hasNext()){\r
+                               String attrName = attrNamesIte.next();\r
+                               // ログイン情報は新しいsidで登録\r
+                               if(attrName.equals(sidReq)){\r
+                                       continue;\r
+                               }\r
+                               session.setAttribute(attrName, remoteSessionAttr.get(attrName));\r
+                               debugStr.append("\n"+ attrName +"="+  remoteSessionAttr.get(attrName).toString());\r
+                       }\r
+                       // ログインの情報をコピー\r
+                       // visitorの場合はaccount==null\r
+                       Object account = remoteSessionAttr.get(sidReq);\r
+                       if(account!=null){\r
+                               session.setAttribute(sidSelf, account);\r
+                               debugStr.append("\n"+ sidReq +"="+  remoteSessionAttr.get(sidReq).toString());\r
+                       }\r
+\r
+                       logger.debug(debugStr.toString());\r
+\r
+                       return session;\r
+               } catch (Exception e) {\r
+                       logger.info("remote接続失敗:", e);\r
+               }\r
+\r
+               return session;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/SessionFilter.java b/src/com/lavans/luz2/http/session/SessionFilter.java
new file mode 100644 (file)
index 0000000..589714d
--- /dev/null
@@ -0,0 +1,44 @@
+/* $Id: SessionFilter.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2006/01/20\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.servlet.Filter;\r
+import javax.servlet.FilterChain;\r
+import javax.servlet.FilterConfig;\r
+import javax.servlet.ServletException;\r
+import javax.servlet.ServletRequest;\r
+import javax.servlet.ServletResponse;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+\r
+/**\r
+ * セッションフィルター。\r
+ * RemoteHttpServletRequest, SessionServiceRemoteを使用して複数tomcatでの\r
+ * セッション引き継ぎを使用する場合、本クラスとSessionListenerをweb.xmlに登録しておく。\r
+ * \r
+ * @author dobashi\r
+ */\r
+public class SessionFilter implements Filter {\r
+       public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {\r
+           // セッション管理ロジック\r
+           HttpServletRequest remoteHttpServletRequest = new RemoteHttpServletRequest((HttpServletRequest)req);\r
+               chain.doFilter(remoteHttpServletRequest, res);\r
+       }\r
+       \r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)\r
+        */\r
+       public void init(FilterConfig arg0) throws ServletException {\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.Filter#destroy()\r
+        */\r
+       public void destroy() {\r
+       }\r
+\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/http/session/SessionListener.java b/src/com/lavans/luz2/http/session/SessionListener.java
new file mode 100644 (file)
index 0000000..4bca774
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Id: SessionListener.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2006/01/24\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import javax.servlet.http.HttpSessionEvent;\r
+import javax.servlet.http.HttpSessionListener;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * \r
+ * @author tnoda\r
+ */\r
+public class SessionListener implements HttpSessionListener {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(SessionListener.class.getName());\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)\r
+        */\r
+       public void sessionCreated(HttpSessionEvent e) {\r
+               logger.debug("session:[" + e.getSession().getId() + "] created.");\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)\r
+        */\r
+       public void sessionDestroyed(HttpSessionEvent e) {\r
+               String sessionId = e.getSession().getId();\r
+               SessionServiceLocal.getInstance().invalidate(sessionId);\r
+               logger.debug("session:[" + sessionId + "] destroyed.");\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/SessionServiceLocal.java b/src/com/lavans/luz2/http/session/SessionServiceLocal.java
new file mode 100644 (file)
index 0000000..0e7a26c
--- /dev/null
@@ -0,0 +1,116 @@
+/* $Id: SessionServiceLocal.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * 作成日: 2006/01/20 14:29:33\r
+ *\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.util.Collections;\r
+import java.util.Enumeration;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * SessionServiceApクラス。\r
+ *\r
+ * This is generated by lamen.\r
+ */\r
+public class SessionServiceLocal{\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(SessionServiceLocal.class.getName());\r
+\r
+       /** singleton実体 */\r
+       private static SessionServiceLocal instance = null;\r
+\r
+       /** セッションを格納するMap */\r
+       private Map<String, HttpSession> sessionMap = Collections.synchronizedMap(new HashMap<String, HttpSession>());\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * Singletonのため呼び出し不可。\r
+        */\r
+       protected SessionServiceLocal(){\r
+\r
+       }\r
+\r
+       /**\r
+        * インスタンス取得メソッド。\r
+        * @return\r
+        */\r
+       public static SessionServiceLocal getInstance(){\r
+               if(instance==null){\r
+                       instance = new SessionServiceLocal();\r
+               }\r
+               return instance;\r
+       }\r
+\r
+       /**\r
+        * getSession\r
+        * リモートからの取得用。\r
+        * 要求されたsessionIdが存在しないならnullを返す。\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public Map<String, Object> getRemoteSessionAttribute(String sessionId){\r
+               logger.debug("SessionServiceLocal#getRemoteSessionAttribute("+ sessionId +")");\r
+               HttpSession session = sessionMap.remove(sessionId);\r
+               // 要求されたsessionIdが存在しないならnullを返す。\r
+               if(session == null){\r
+                       //logger.log("is not exist:"+ sessionId);\r
+                       return null;\r
+               }\r
+\r
+               try{\r
+                       Enumeration<String> attrNames = session.getAttributeNames();\r
+                       // 属性の取得\r
+                       Map<String, Object> attr = Collections.synchronizedMap(new HashMap<String, Object>());\r
+                       while(attrNames.hasMoreElements()){\r
+                               String attrName = attrNames.nextElement();\r
+                               attr.put(attrName, session.getAttribute(attrName));\r
+                       }\r
+                       return attr;\r
+               }catch (Exception e) {\r
+                       // sessionが無効な場合はgetAttributeNames()に失敗する。\r
+                       return null;\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        * セッションをこのサービスに登録する。\r
+        * @param session\r
+        */\r
+       public void setSession(HttpSession session){\r
+               logger.debug("set session:"+ session.getId());\r
+               sessionMap.put(session.getId(), session);\r
+       }\r
+\r
+       /**\r
+        *\r
+        * @param session\r
+        * @return\r
+        */\r
+       public boolean exists(String  sessionId){\r
+               return sessionMap.containsKey(sessionId);\r
+       }\r
+\r
+       /**\r
+        * invalidate\r
+        */\r
+       public Boolean invalidate(String sessionId){\r
+               HttpSession session = sessionMap.get(sessionId);\r
+               if(session==null){\r
+//                     logger.log(logLevel,"invalid sessionId invalidate():"+ sessionId);\r
+                       return Boolean.FALSE;\r
+               }\r
+               session.invalidate();\r
+               logger.debug("remove:"+ sessionId);\r
+               sessionMap.remove(sessionId);\r
+               return Boolean.TRUE;\r
+       }\r
+\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/http/session/SessionServiceRemote.java b/src/com/lavans/luz2/http/session/SessionServiceRemote.java
new file mode 100644 (file)
index 0000000..a12bf7e
--- /dev/null
@@ -0,0 +1,78 @@
+/* $Id: SessionServiceRemote.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * 作成日: 2006/01/20 14:30:11\r
+ *\r
+ */\r
+package com.lavans.luz2.http.session;\r
+\r
+import java.io.IOException;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.http.session.net.SessionServerConnection;\r
+import com.lavans.luz2.http.session.net.SessionServerConnectionManager;\r
+\r
+/**\r
+ * SessionServiceWebクラス。\r
+ *\r
+ * This is generated by lamen.\r
+ */\r
+public class SessionServiceRemote {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(SessionServiceRemote.class.getName());\r
+\r
+       /** singleton実体 */\r
+       private static SessionServiceRemote instance = null;\r
+\r
+       /** Apサーバーへの接続 */\r
+       private SessionServerConnectionManager connectionPool = SessionServerConnectionManager.getInstance();\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * Singletonのため呼び出し不可。\r
+        */\r
+       protected SessionServiceRemote(){\r
+\r
+       }\r
+\r
+       /**\r
+        * インスタンス取得メソッド。\r
+        * @return\r
+        */\r
+       public static SessionServiceRemote getInstance(){\r
+               if(instance==null){\r
+                       instance = new SessionServiceRemote();\r
+               }\r
+               return instance;\r
+       }\r
+\r
+       /**\r
+        * getSession\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public Map<String, Object> getRemoteSessionAttribute(String jvm, String sessionId) {\r
+               SessionServerConnection con = null;\r
+               Object result = null;\r
+               try{\r
+                       con = connectionPool.getConnection(jvm);\r
+               } catch (IOException e) {\r
+                       logger.debug("SessionConnection作成失敗。["+ jvm +"]");\r
+                       return null;\r
+               }\r
+\r
+               try{\r
+                       result = con.execute(\r
+                               SessionServiceLocal.class.getName(),            // クラス名\r
+                               "getRemoteSessionAttribute",                            // メソッド名\r
+                               new Class[]{String.class},      // 引数の型\r
+                               new Object[]{sessionId} // 引数\r
+                       );\r
+               } catch (Exception e) {\r
+                       logger.error( "getRemoteSesionAttribute failed.", e);\r
+               }\r
+\r
+               return (Map<String, Object>)result;\r
+       }\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/http/session/net/SessionServerConnection.java b/src/com/lavans/luz2/http/session/net/SessionServerConnection.java
new file mode 100644 (file)
index 0000000..47c22a6
--- /dev/null
@@ -0,0 +1,105 @@
+/* $Id: SessionServerConnection.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/08/03\r
+ */\r
+package com.lavans.luz2.http.session.net;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.BufferedOutputStream;\r
+import java.io.IOException;\r
+import java.io.ObjectInputStream;\r
+import java.io.ObjectOutputStream;\r
+import java.net.URL;\r
+import java.net.URLConnection;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.omg.CORBA.portable.ApplicationException;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class SessionServerConnection {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(SessionServerConnection.class.getName());\r
+\r
+       private URLConnection con = null;\r
+       ObjectOutputStream os = null;\r
+       ObjectInputStream is = null;\r
+       private URL url = null;\r
+\r
+       public SessionServerConnection(URL url) throws IOException{\r
+               init(url);\r
+       }\r
+\r
+       private void init(URL url) throws IOException{\r
+//             logger.debug("create ApJConnection.");\r
+               this.url = url;\r
+               con = url.openConnection();\r
+               con.setRequestProperty("Connection", "Keep-Alive");\r
+               con.setDoOutput(true);\r
+               con.connect();\r
+       }\r
+\r
+       /**\r
+        * APへ問い合わせをかけて応答オブジェクトをもらう。\r
+        * AP側でキャッチした例外はApplicationExceptionとして帰ってくるので\r
+        * 応答オブジェクトがApplicationExceptionだった場合はそのままthrowする。\r
+        * APとの接続エラーの場合は1度だけ再接続を試みる。それ以外のエラーはここで\r
+        * ApplicationExceptionにくるんでActionへ伝える。\r
+        *\r
+        * 「余力不足で注文受付不可」などのエラーはExceptionではなく\r
+        * 戻りオブジェクトの中のパラメータに入っている。\r
+        *\r
+        * @param className\r
+        * @param methodName\r
+        * @param paramTypes\r
+        * @param args\r
+        * @return\r
+        * @throws ApplicationException\r
+        */\r
+       public Object execute(String className, String methodName,\r
+                       Class<?>[] paramTypes, Object[] args) throws Exception{\r
+               String[] shortNames = className.split("\\.");\r
+               String shortName = shortNames[shortNames.length - 1];\r
+               logger.debug("session execute "+ url.toString() +"/"+ shortName +"#"+methodName +"()");\r
+               Object result = null;\r
+               try {\r
+                       os = new ObjectOutputStream(\r
+                                       new BufferedOutputStream(con.getOutputStream()));\r
+                       // クラス名\r
+                       os.writeObject(className);\r
+                       // メソッド名\r
+                       os.writeObject(methodName);\r
+                       // 引数の型\r
+                       os.writeObject(paramTypes);\r
+                       // 引数\r
+                       os.writeObject(args);\r
+\r
+                       os.flush();\r
+\r
+                       is = new ObjectInputStream(\r
+                                       new BufferedInputStream(con.getInputStream()));\r
+                       result = is.readObject();\r
+\r
+                       // 受け取ったものが例外だったら(APで例外が起きた場合)\r
+                       if(result instanceof Exception){\r
+                               // エラーメッセージが入っているのでそのままスローする。\r
+                               throw (Exception)result;\r
+                       }\r
+               }finally{\r
+                       try { os.close(); } catch (Exception e) { logger.warn(null, e); }\r
+                       try { is.close(); } catch (Exception e) { logger.warn(null, e); }\r
+               }\r
+\r
+               return result;\r
+\r
+       }\r
+\r
+       /**\r
+        * @return url を戻します。\r
+        */\r
+       public URL getUrl() {\r
+               return url;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/http/session/net/SessionServerConnectionManager.java b/src/com/lavans/luz2/http/session/net/SessionServerConnectionManager.java
new file mode 100644 (file)
index 0000000..f53e706
--- /dev/null
@@ -0,0 +1,109 @@
+/* $Id: SessionServerConnectionManager.java 411 2011-07-28 23:05:04Z dobashi $\r
+ * created: 2005/08/05\r
+ */\r
+package com.lavans.luz2.http.session.net;\r
+\r
+import java.io.IOException;\r
+import java.net.MalformedURLException;\r
+import java.net.URL;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.omg.CORBA.portable.ApplicationException;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * Web-ApJコネクション管理クラス。\r
+ * httpのプロトコル上一度flushしたコネクションは再利用できない。\r
+ * 同一URLに対するアクセスは、コネクションを新規に作成しても\r
+ * 自動的にHttpKeepaliveになる。したがって本クラスでは\r
+ * コネクション数の管理は行わず、接続先のみ管理し、コネクションは\r
+ * 要求がある度に新規作成する。\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class SessionServerConnectionManager {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(SessionServerConnectionManager.class.getName());\r
+\r
+       /** 接続設定情報 */\r
+       private static Map<String, URL> urlMap = null;\r
+\r
+       /**\r
+        * Singletonの実体。\r
+        */\r
+       private static SessionServerConnectionManager instatnce = new SessionServerConnectionManager();\r
+\r
+       /**\r
+        * インスタンス取得メソッド。\r
+        * @return\r
+        */\r
+       public static SessionServerConnectionManager getInstance(){\r
+               return instatnce;\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * Singletonのため呼び出し不可。\r
+        *\r
+        */\r
+       private SessionServerConnectionManager(){\r
+               init();\r
+       }\r
+\r
+       /**\r
+        * 初期化。\r
+        *\r
+        */\r
+       public void init(){\r
+               try {\r
+                       System.setProperty("http.keepAlive","true");\r
+\r
+                       urlMap = new HashMap<String, URL>();\r
+\r
+                       Config config = Config.getInstance("cayen.xml");\r
+                       Node node = config.getNode("session_server");\r
+                       if(node==null){\r
+                               logger.error("cayen.xmlに<session_server>がありません。");\r
+                       }\r
+                       NodeList nodeList = node.getChildNodes();\r
+                       for(int i=0; i<nodeList.getLength(); i++){\r
+                               Node item = nodeList.item(i);\r
+                               if((item.getNodeType()==Node.TEXT_NODE) ||\r
+                                  (item.getNodeType()==Node.COMMENT_NODE) ){\r
+                                       continue;\r
+                               }\r
+\r
+                               // 接続名取得 ysugisawa@@\r
+                               String name = item.getNodeName();\r
+                               // URL取得\r
+                               Element ele = (Element)item;\r
+                               URL url     = new URL(ele.getAttribute("uri"));\r
+\r
+                               logger.info("session-server:"+ name +"-"+ url);\r
+                               urlMap.put(name, url);\r
+                       }\r
+               } catch (MalformedURLException e) {\r
+                       logger.error("初期化に失敗",e);\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        * Sessionサーバー(webサーバー)への接続を取得。\r
+        * @return\r
+        * @throws ApplicationException\r
+        */\r
+       public SessionServerConnection getConnection(String jvm) throws IOException {\r
+               SessionServerConnection con;\r
+               con = new SessionServerConnection(urlMap.get(jvm));\r
+\r
+               return con;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/annotation/LRemote.java b/src/com/lavans/luz2/lremote/annotation/LRemote.java
new file mode 100644 (file)
index 0000000..132b0ea
--- /dev/null
@@ -0,0 +1,47 @@
+/* $Id: LRemote.java 16 2008-12-02 09:31:01Z lavans $ */\r
+package com.lavans.luz2.lremote.annotation;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+\r
+@Target({ElementType.TYPE, ElementType.METHOD})\r
+@Retention(RetentionPolicy.RUNTIME)\r
+public @interface LRemote {\r
+       public static final String LOCAL="local";\r
+\r
+       public enum Selector { ORDERED, ROUNDROBIN, GROUP, OTHERS };\r
+       /**\r
+        * Node group. Default is LOCAL.\r
+        * Set "local", the method is executed in local servlet container.\r
+        * Set groupname to execute the method in remote node.\r
+        * @return\r
+        */\r
+       String group() default LOCAL;\r
+\r
+       /**\r
+        * Target node. Default is Target.ORDERED.\r
+        * <ul>Single connector\r
+        * <li>ORDERED</li>\r
+        * <li>ROUNDROBIN</li>\r
+        * </ul>\r
+        * <ul>Group connector\r
+        * <li>GROUP: execute in all node of group include itself.</li>\r
+        * <li>OTHERS: execute in all other node. Local server doesn't execute.</li>\r
+        * </ul>\r
+        *\r
+        * @return\r
+        */\r
+       Selector selector() default Selector.ORDERED;\r
+\r
+       /**\r
+        * Synchronized flag. Default is true. For group connector only.\r
+        * If set <code>false</code>, connector does not wait for remote execution,\r
+        * and can't get any results. Logging is the only way for confirm method result.\r
+        * @return\r
+        */\r
+       boolean sync() default true;\r
+       \r
+}\r
diff --git a/src/com/lavans/luz2/lremote/connector/ConnectManager.java b/src/com/lavans/luz2/lremote/connector/ConnectManager.java
new file mode 100644 (file)
index 0000000..4019b7a
--- /dev/null
@@ -0,0 +1,90 @@
+/* $Id: ConnectManager.java 16 2008-12-02 09:31:01Z lavans $\r
+ * created: 2005/08/05\r
+ */\r
+package com.lavans.luz2.lremote.connector;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.omg.CORBA.portable.ApplicationException;\r
+\r
+import com.lavans.luz2.lremote.annotation.LRemote;\r
+import com.lavans.luz2.lremote.connector.impl.AsyncConnectWrapper;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+import com.lavans.luz2.lremote.selector.Selector;\r
+import com.lavans.luz2.lremote.selector.SelectorFactory;\r
+\r
+/**\r
+ * Web-ApJコネクション管理クラス。\r
+ * httpのプロトコル上一度flushしたコネクションは再利用できない。\r
+ * 同一URLに対するアクセスは、コネクションを新規に作成しても\r
+ * 自動的にHttpKeepaliveになる。したがって本クラスでは\r
+ * コネクション数の管理は行わず、接続先のみ管理し、コネクションは\r
+ * 要求がある度に新規作成する。\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class ConnectManager {\r
+       /**\r
+        * Type of connection.\r
+        * single: Normal connection selected in group by Selector.\r
+        * group:               Connect to all of one group.\r
+        * groupAsync:  Like group, but connect async. You can't get the result. Check log file.\r
+        * groupButMe:  Like group, but if the group include my URL then pass it.\r
+        * all:                 Connect to all member of whole group.\r
+        *\r
+        * @author dobashi\r
+        *\r
+        */\r
+       public enum ConnectType {single, group, groupButMe, all};\r
+       public enum SyncType {sync, async};\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ConnectManager.class.getName());\r
+\r
+       /**\r
+        * Singletonの実体。\r
+        */\r
+       private static ConnectManager instatnce = new ConnectManager();\r
+\r
+       /**\r
+        * インスタンス取得メソッド。\r
+        * @return\r
+        */\r
+       public static ConnectManager getInstance(){\r
+               return instatnce;\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * Singletonのため呼び出し不可。\r
+        *\r
+        */\r
+       private ConnectManager(){\r
+//             init();\r
+       }\r
+\r
+       /**\r
+        * ApJへの接続を取得。\r
+        * @return\r
+        * @throws ApplicationException\r
+        */\r
+       public Connector getConnector(LRemote lremote) throws Exception{\r
+               RemoteNodeGroup group = RemoteNodeGroup.getInstance(lremote.group());\r
+               if(group==null){\r
+                       logger.error("No such group ["+ lremote.group() +"].");\r
+                       throw new Exception();\r
+               }\r
+               // get selector\r
+               Selector selector = SelectorFactory.getSelector(lremote, group);\r
+               Connector connector = selector.getConnector();\r
+\r
+               // check sync\r
+               if(!lremote.sync()){\r
+                       connector = new AsyncConnectWrapper(connector);\r
+               }\r
+\r
+               return connector;\r
+       }\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/connector/Connector.java b/src/com/lavans/luz2/lremote/connector/Connector.java
new file mode 100644 (file)
index 0000000..8ad1d10
--- /dev/null
@@ -0,0 +1,21 @@
+package com.lavans.luz2.lremote.connector;\r
+\r
+import org.omg.CORBA.portable.ApplicationException;\r
+\r
+public interface Connector {\r
+       /**\r
+        * Execute remote-procedure-call.\r
+        * If remote server throws exception, result object is the exception.\r
+        * If it is instanceof exception, then throw it. If not, return it.\r
+        *\r
+        * @param className\r
+        * @param methodName\r
+        * @param paramTypes\r
+        * @param args\r
+        * @return\r
+        * @throws ApplicationException\r
+        */\r
+       Object execute(String className, String methodName,\r
+                       Class<?>[] paramTypes, Object[] args) throws Exception;\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/connector/impl/AsyncConnectWrapper.java b/src/com/lavans/luz2/lremote/connector/impl/AsyncConnectWrapper.java
new file mode 100644 (file)
index 0000000..7f2d10b
--- /dev/null
@@ -0,0 +1,66 @@
+package com.lavans.luz2.lremote.connector.impl;\r
+\r
+import java.util.Timer;\r
+import java.util.TimerTask;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+\r
+public class AsyncConnectWrapper implements Connector {\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(GroupConnector.class.getName());\r
+\r
+       /** deleagte */\r
+       private Connector connector;\r
+       public AsyncConnectWrapper(Connector connector){\r
+               this.connector = connector;\r
+       }\r
+\r
+       /**\r
+        * Execution method.\r
+        */\r
+       //@Override\r
+       public Object execute(String className, String methodName,\r
+                       Class<?>[] paramTypes, Object[] args) throws Exception {\r
+               TimerTask task = new AsyncTimerTask(className, methodName, paramTypes, args);\r
+               Timer timer = new Timer();\r
+               timer.schedule(task, 1);\r
+               //timer.cancel();\r
+\r
+               return null;\r
+       }\r
+\r
+       private class AsyncTimerTask extends TimerTask{\r
+               private String className;\r
+               private String methodName;\r
+               private Class<?>[] paramTypes;\r
+               private Object[] args;\r
+               /**\r
+                * constructor.\r
+                *\r
+                * @param className\r
+                * @param methodName\r
+                * @param paramTypes\r
+                * @param args\r
+                */\r
+               public AsyncTimerTask(String className, String methodName,\r
+                       Class<?>[] paramTypes, Object[] args){\r
+                       this.className = className;\r
+                       this.methodName = methodName;\r
+                       this.paramTypes = paramTypes;\r
+                       this.args = args;\r
+               }\r
+               /**\r
+                * execution method\r
+                */\r
+               public void run() {\r
+                       try {\r
+                               connector.execute(className, methodName, paramTypes, args);\r
+                       } catch (Exception e) {\r
+                               logger.error("Aync execution is failed.", e);\r
+                       }\r
+               };\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/connector/impl/GroupConnector.java b/src/com/lavans/luz2/lremote/connector/impl/GroupConnector.java
new file mode 100644 (file)
index 0000000..3c4af0b
--- /dev/null
@@ -0,0 +1,75 @@
+/* $Id: GroupConnector.java 16 2008-12-02 09:31:01Z lavans $\r
+ * created: 2005/11/04\r
+ */\r
+package com.lavans.luz2.lremote.connector.impl;\r
+\r
+import java.util.LinkedHashMap;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+import com.lavans.luz2.lremote.node.RemoteNode;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+\r
+\r
+/**\r
+ * すべてのApJに接続してコマンドを送信するクラス。\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class GroupConnector implements Connector{\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(GroupConnector.class.getName());\r
+\r
+       private RemoteNodeGroup group;\r
+\r
+       /**\r
+        * コンストラクタ\r
+        *\r
+        */\r
+       public GroupConnector(RemoteNodeGroup group){\r
+               this.group = group;\r
+       }\r
+\r
+       /**\r
+        * 全ApJサーバーと接続してメソッド呼び出しを行う。\r
+        *\r
+        * @return java.util.Map 接続先urlと結果Objectを格納。\r
+        * getCustomer\r
+        */\r
+       public Map<RemoteNode, Object> execute(String serviceName, String methodName, Class<?>[] parameterTypes, Object[] args){\r
+               // 結果を格納するリスト\r
+               Map<RemoteNode, Object> resultMap = new LinkedHashMap<RemoteNode, Object>(group.getNodeList().size());\r
+               for(RemoteNode remoteNode: group.getNodeList()){\r
+                       SingleConnector con = new SingleConnector(remoteNode);\r
+                       // check connection\r
+                       if(!con.init()){\r
+                               // if server is down, then continue.\r
+                               continue;\r
+                       }\r
+                       try {\r
+                               Object result = con.execute(\r
+                                               serviceName,            // クラス名\r
+                                               methodName,                     // メソッド名\r
+                                               parameterTypes,         // 引数の型\r
+                                               args                            // 引数\r
+                                       );\r
+                               // 結果がnullの場合はvoidメソッドなので成功とする。\r
+//                             if(result==null){\r
+//                                     result = Boolean.TRUE;\r
+//                             }\r
+                               // 結果を格納\r
+                               resultMap.put(remoteNode, result);\r
+                               // ログへ出力\r
+                               String resultStr = result==null?"<null>":result.toString();\r
+                               logger.info("remote execute["+ con.getremoteNode().getUrl().getHost() +"] "+  serviceName +"#"+ methodName +"() return [" + resultStr +"]");\r
+                       } catch (Exception e) {\r
+                               logger.error( "AllConnect実行に失敗"+ con.getremoteNode().getUrl().toString(), e);\r
+                       }\r
+               }\r
+\r
+               return resultMap;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/connector/impl/SingleConnector.java b/src/com/lavans/luz2/lremote/connector/impl/SingleConnector.java
new file mode 100644 (file)
index 0000000..82b5764
--- /dev/null
@@ -0,0 +1,113 @@
+package com.lavans.luz2.lremote.connector.impl;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.BufferedOutputStream;\r
+import java.io.IOException;\r
+import java.io.ObjectInputStream;\r
+import java.io.ObjectOutputStream;\r
+import java.net.URLConnection;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.omg.CORBA.portable.ApplicationException;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+import com.lavans.luz2.lremote.node.RemoteNode;\r
+\r
+public class SingleConnector implements Connector{\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(RemoteNode.class.getName());\r
+\r
+       /** main connection */\r
+       private RemoteNode remoteNode = null;\r
+       private URLConnection con = null;\r
+\r
+\r
+       /**\r
+        * Constructor.\r
+        */\r
+       public SingleConnector(RemoteNode value){\r
+               this.remoteNode = value;\r
+       }\r
+\r
+       public boolean init(){\r
+               try {\r
+                       con = remoteNode.getUrl().openConnection();\r
+                       con.setConnectTimeout(1000);\r
+                       con.setRequestProperty("Connection", "Keep-Alive");\r
+                       con.setDoOutput(true);\r
+                       con.connect();\r
+                       return true;\r
+               } catch (IOException e) {\r
+                       logger.warn("create connection error["+remoteNode.getUrl()+ "("+ e.getMessage() +")]");\r
+                       logger.debug(null, e);\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * AP�֖₢���킹�������ĉ����I�u�W�F�N�g�����炤�B\r
+        * AP���ŃL���b�`������O��ApplicationException�Ƃ��ċA���Ă���̂�\r
+        * �����I�u�W�F�N�g��ApplicationException�������ꍇ�͂��̂܂�throw����B\r
+        * AP�Ƃ̐ڑ��G���[�̏ꍇ�͂P�x�����Đڑ������݂�B����ȊO�̃G���[�͂�����\r
+        * ApplicationException�ɂ�����Action�֓`����B\r
+        *\r
+        * �u�]�͕s���Œ�����t�s�\81v�Ȃǂ̃G���[��Exception�ł͂Ȃ�\r
+        * �߂�I�u�W�F�N�g�̒��̃p�����[�^�ɓ���Ă���B\r
+        *\r
+        * @param className\r
+        * @param methodName\r
+        * @param paramTypes\r
+        * @param args\r
+        * @return\r
+        * @throws ApplicationException\r
+        */\r
+       public Object execute(String className, String methodName,\r
+                       Class<?>[] paramTypes, Object[] args) throws Exception{\r
+               String[] shortNames = className.split("\\.");\r
+               String shortName = shortNames[shortNames.length - 1];\r
+               logger.debug("remote execute "+ shortName +"#"+methodName +"()");\r
+               Object result = null;\r
+               ObjectOutputStream os = null;\r
+               ObjectInputStream is = null;\r
+               try {\r
+                       os = new ObjectOutputStream(\r
+                                       new BufferedOutputStream(con.getOutputStream()));\r
+                       // �N���X��\r
+                       os.writeObject(className);\r
+                       // ���\�b�h��\r
+                       os.writeObject(methodName);\r
+                       // ��̌^\r
+                       os.writeObject(paramTypes);\r
+                       // ��\r
+                       os.writeObject(args);\r
+                       // �o�b�t�@���t���b�V�����đ��M\r
+                       os.flush();\r
+\r
+                       // ��M����\r
+                       is = new ObjectInputStream(\r
+                                       new BufferedInputStream(con.getInputStream()));\r
+                       result = is.readObject();\r
+\r
+                       // �󂯎�������̂���O��������(AP�ŗ�O���N�����ꍇ)\r
+                       if(result instanceof Exception){\r
+                               logger.info("result is exception", (Exception)result);\r
+                               // �G���[���b�Z�[�W������Ă���̂ł��̂܂܃X���[����B\r
+                               throw (Exception)result;\r
+                       }\r
+               } finally {\r
+                       try { os.close(); } catch (Exception e) { logger.warn(null, e); }\r
+                       try { if(is!=null)is.close(); } catch (Exception e) { logger.warn(null, e); }\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @return con\r
+        */\r
+       public RemoteNode getremoteNode() {\r
+               return remoteNode;\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/intercetor/RemoteInterceptor.java b/src/com/lavans/luz2/lremote/intercetor/RemoteInterceptor.java
new file mode 100644 (file)
index 0000000..6e6d8e1
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id: RemoteInterceptor.java 22 2010-05-18 10:20:25Z lavans $ */\r
+package com.lavans.luz2.lremote.intercetor;\r
+\r
+import java.lang.reflect.Method;\r
+\r
+import net.sf.cglib.proxy.MethodInterceptor;\r
+import net.sf.cglib.proxy.MethodProxy;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.lremote.annotation.LRemote;\r
+import com.lavans.luz2.lremote.connector.ConnectManager;\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+\r
+public class RemoteInterceptor implements MethodInterceptor{\r
+       /** Logger */\r
+       private static Log logger = LogFactory.getLog(ConnectManager.class.getName());\r
+\r
+       //@Override\r
+       public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {\r
+               // Check the method is local\r
+               LRemote lremote = method.getAnnotation(LRemote.class);\r
+               if((lremote==null) || lremote.group().equals(LRemote.LOCAL)){\r
+                       return proxy.invokeSuper(obj, args);\r
+               }\r
+\r
+               // Remote execute\r
+               ConnectManager connectManager = ConnectManager.getInstance();\r
+               Connector connector = connectManager.getConnector(lremote);\r
+               if(connector == null){\r
+                       logger.error("No connector is valid");\r
+                       return null;\r
+               }\r
+\r
+               return connector.execute(method.getDeclaringClass().getName(), method.getName(), method.getParameterTypes(), args);\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/node/RemoteNode.java b/src/com/lavans/luz2/lremote/node/RemoteNode.java
new file mode 100644 (file)
index 0000000..a71eab4
--- /dev/null
@@ -0,0 +1,63 @@
+/* $Id: RemoteNode.java 16 2008-12-02 09:31:01Z lavans $\r
+ * created: 2005/08/03\r
+ */\r
+package com.lavans.luz2.lremote.node;\r
+\r
+import java.io.IOException;\r
+import java.net.MalformedURLException;\r
+import java.net.URL;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class RemoteNode {\r
+\r
+       private String name;\r
+       private URL url = null;\r
+       private boolean isSelf = false;\r
+\r
+       /**\r
+        * Constructor.\r
+        *\r
+        * @param config name.\r
+        * @param connection url.\r
+        * @throws MalformedURLException\r
+        * @throws IOException\r
+        */\r
+       public RemoteNode(String name, String uri) throws MalformedURLException{\r
+               this.name = name;\r
+               this.url = new URL(uri);\r
+       }\r
+\r
+       @Override\r
+       public String toString(){\r
+               return name+"["+url.toString()+"]";\r
+       }\r
+\r
+       /**\r
+        * @return name ��߂��܂��B\r
+        */\r
+       public String getName() {\r
+               return name;\r
+       }\r
+\r
+       /**\r
+        * @return url ��߂��܂��B\r
+        */\r
+       public URL getUrl() {\r
+               return url;\r
+       }\r
+\r
+       public boolean isSelf() {\r
+               return isSelf;\r
+       }\r
+\r
+       /**\r
+        * package scope.\r
+        * @param isSelf\r
+        */\r
+       void setSelf(boolean isSelf) {\r
+               this.isSelf = isSelf;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/node/RemoteNodeGroup.java b/src/com/lavans/luz2/lremote/node/RemoteNodeGroup.java
new file mode 100644 (file)
index 0000000..0aa1433
--- /dev/null
@@ -0,0 +1,147 @@
+package com.lavans.luz2.lremote.node;\r
+\r
+import java.net.MalformedURLException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * NodeGroup.\r
+ * static\r
+ * @author mdobashi\r
+ *\r
+ */\r
+public class RemoteNodeGroup implements Cloneable{\r
+       /** logger */\r
+       private static final Log logger = LogFactory.getLog(RemoteNodeGroup.class);\r
+       /** config reader */\r
+       private static com.lavans.luz2.util.Config config = Config.getInstance("lremote.xml");\r
+       private static Map<String, RemoteNodeGroup> groupMap;\r
+       static {\r
+               init();\r
+       }\r
+\r
+       /**\r
+        * init.\r
+        * Read node setting from lremote.xml.\r
+        */\r
+       private static void init(){\r
+               // Clear cache data.\r
+               if(groupMap!=null){\r
+                       groupMap.clear();\r
+               }\r
+\r
+               groupMap = new ConcurrentHashMap<String, RemoteNodeGroup>();\r
+               try {\r
+                       // read self node.\r
+                       String selfName = config.getNodeValue("/lremote/self_node");\r
+\r
+                       // get node group\r
+                       NodeList groupList  = config.getNodeList("/lremote/node_group");\r
+                       for(int i=0; i<groupList.getLength(); i++){\r
+                               Element groupNode = (Element)groupList.item(i);\r
+                               RemoteNodeGroup group = new RemoteNodeGroup();\r
+                               group.setGroupName(groupNode.getAttribute("name"));\r
+                               groupMap.put(group.getGroupName(), group);\r
+                               // get node\r
+                               NodeList nodeList = config.getNodeList("node", groupNode);\r
+                               for(int j=0; j<nodeList.getLength(); j++){\r
+                                       Element node = (Element)nodeList.item(j);\r
+                                       logger.debug(node.getNamespaceURI()+","+node.getNodeName());\r
+                                       if((node.getNodeType()==Node.TEXT_NODE)||(node.getNodeType()==Node.TEXT_NODE)) continue;\r
+                                       // create Remote node\r
+                                       RemoteNode remoteNode = new RemoteNode(node.getAttribute("name"), node.getAttribute("uri"));\r
+                                       group.nodeList.add(remoteNode);\r
+                                       // check if it is self_node\r
+                                       if(selfName.equals(remoteNode.getName())){\r
+                                               remoteNode.setSelf(true);\r
+                                       }\r
+                               }\r
+                       }\r
+               } catch (XPathExpressionException e) {\r
+                       logger.error("lremote.xml parse node error", e);\r
+               } catch (MalformedURLException e) {\r
+                       logger.error("lremote.xml uri syntax error", e);\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        *\r
+        */\r
+       public static RemoteNodeGroup getInstance(String name){\r
+               return groupMap.get(name);\r
+       }\r
+\r
+       private String groupName;\r
+       private List<RemoteNode> nodeList = new ArrayList<RemoteNode>();\r
+\r
+       /**\r
+        * ��œn���ꂽ���O�����̃O���[�v�ɓ���Ă��邩�ǂ������f����B\r
+        * <code>@LRemote("ap")</code>�Ƃ����w��������Ƃ��ɁA���̐ڑ��悪\r
+        * local��remote���𔻒f���邽�߂Ɏg�p����B\r
+        *\r
+        * @param localName\r
+        * @return\r
+        */\r
+       public boolean contains(String localName){\r
+               boolean result = false;\r
+               for(RemoteNode con: nodeList){\r
+                       if(localName.equals(con.getName())){\r
+                               result = true;\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * Clone RemoteNodeGroup.\r
+        * nodeList must be deep copied.\r
+        *\r
+        */\r
+       public Object clone() throws CloneNotSupportedException {\r
+               RemoteNodeGroup dst = (RemoteNodeGroup)super.clone();\r
+               dst.nodeList = new ArrayList<RemoteNode>();\r
+               dst.nodeList.addAll(this.nodeList);\r
+               return dst;\r
+       }\r
+\r
+       /**\r
+        * @return groupName\r
+        */\r
+       public String getGroupName() {\r
+               return groupName;\r
+       }\r
+       /**\r
+        * @param groupName �Z�b�g���� groupName\r
+        */\r
+       public void setGroupName(String groupName) {\r
+               this.groupName = groupName;\r
+       }\r
+       /**\r
+        * @return connectionList\r
+        */\r
+       public List<RemoteNode> getNodeList() {\r
+               return nodeList;\r
+       }\r
+       /**\r
+        * @param connectionList �Z�b�g���� connectionList\r
+        */\r
+       public void setConnectionList(List<RemoteNode> connectionList) {\r
+               this.nodeList = connectionList;\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/selector/Selector.java b/src/com/lavans/luz2/lremote/selector/Selector.java
new file mode 100644 (file)
index 0000000..4e2d4ea
--- /dev/null
@@ -0,0 +1,19 @@
+package com.lavans.luz2.lremote.selector;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+\r
+\r
+/**\r
+ * Stateful selector class.\r
+ * RoundRobinSelector have to remind last node.\r
+ * Selector classes has state. Selector is instance for each RemoteNodeGroup.\r
+ * OrderedSelector have to check if node is alive.\r
+ * Selector must know connector.\r
+ *\r
+ *\r
+ * @author dobashi\r
+ *\r
+ */\r
+public interface Selector {\r
+       Connector getConnector();\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/selector/SelectorFactory.java b/src/com/lavans/luz2/lremote/selector/SelectorFactory.java
new file mode 100644 (file)
index 0000000..c9e03b6
--- /dev/null
@@ -0,0 +1,90 @@
+package com.lavans.luz2.lremote.selector;\r
+\r
+\r
+import java.lang.reflect.Constructor;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.lremote.annotation.LRemote;\r
+import com.lavans.luz2.lremote.connector.ConnectManager;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+import com.lavans.luz2.lremote.selector.impl.GroupSelector;\r
+import com.lavans.luz2.lremote.selector.impl.OrderedSelector;\r
+import com.lavans.luz2.lremote.selector.impl.OthersSelector;\r
+\r
+/**\r
+ * Selector factory class.\r
+ * Selector is instanced for each RemoteNodeGroup and it is stateful.\r
+ * SelectorFactory caches all instance of selector.\r
+ *\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class SelectorFactory {\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(ConnectManager.class.getName());\r
+\r
+       /** Cache of all selector instance */\r
+       private static Map<Class<? extends Selector>, Map<RemoteNodeGroup, Selector>> selectorMap = Collections.synchronizedMap(new HashMap<Class<? extends Selector>, Map<RemoteNodeGroup,Selector>>());\r
+\r
+       /**\r
+        * Get selector.\r
+        *\r
+        * @param lremote\r
+        * @param group\r
+        * @return\r
+        */\r
+       public static Selector getSelector(LRemote lremote, RemoteNodeGroup group){\r
+               // connect condition\r
+               LRemote.Selector lremoteSelector = lremote.selector();\r
+\r
+               // search selector class\r
+               Class<? extends Selector> selectorClass = null;\r
+               switch (lremoteSelector){\r
+                       case ORDERED:\r
+                               selectorClass = OrderedSelector.class;\r
+                               break;\r
+                       case GROUP:\r
+                               selectorClass = GroupSelector.class;\r
+                               break;\r
+                       case OTHERS:\r
+                               selectorClass = OthersSelector.class;\r
+                               break;\r
+                       default:\r
+                               // TODO from String\r
+               }\r
+\r
+               // check class is valid\r
+               // throw NoSuchSelectorException?\r
+               if(selectorClass == null){\r
+                       return null;\r
+               }\r
+\r
+               // Search groupMap for this class.\r
+               Map<RemoteNodeGroup, Selector> groupMap = selectorMap.get(selectorClass);\r
+               if(groupMap==null){\r
+                       // create new one\r
+                       groupMap = Collections.synchronizedMap(new HashMap<RemoteNodeGroup, Selector>());\r
+                       selectorMap.put(selectorClass, groupMap);\r
+               }\r
+\r
+               // Search selector instance for this group.\r
+               Selector selector = groupMap.get(group);\r
+               if(selector==null){\r
+                       try {\r
+                               Constructor<? extends Selector> constructor = selectorClass.getConstructor(RemoteNodeGroup.class);\r
+                               selector = constructor.newInstance(group);\r
+                               // save cache to map\r
+                               groupMap.put(group, selector);\r
+                       } catch (Exception e) {\r
+                               logger.error("", e);\r
+                       }\r
+               }\r
+\r
+               return selector;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/selector/impl/GroupSelector.java b/src/com/lavans/luz2/lremote/selector/impl/GroupSelector.java
new file mode 100644 (file)
index 0000000..a3958e7
--- /dev/null
@@ -0,0 +1,30 @@
+package com.lavans.luz2.lremote.selector.impl;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+import com.lavans.luz2.lremote.connector.impl.GroupConnector;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+import com.lavans.luz2.lremote.selector.Selector;\r
+\r
+/**\r
+ * Connect to all nodes of same group.\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class GroupSelector implements Selector{\r
+       /** �ڑ��ݒ��� */\r
+       private RemoteNodeGroup group;\r
+\r
+       /**\r
+        * Constructor\r
+        */\r
+       public GroupSelector(RemoteNodeGroup nodeGroup){\r
+               this.group = nodeGroup;\r
+       }\r
+\r
+       public Connector getConnector(){\r
+               Connector con = new GroupConnector(group);\r
+               return con;\r
+       }\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/selector/impl/OrderedSelector.java b/src/com/lavans/luz2/lremote/selector/impl/OrderedSelector.java
new file mode 100644 (file)
index 0000000..47abfbd
--- /dev/null
@@ -0,0 +1,41 @@
+package com.lavans.luz2.lremote.selector.impl;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+import com.lavans.luz2.lremote.connector.impl.SingleConnector;\r
+import com.lavans.luz2.lremote.node.RemoteNode;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+import com.lavans.luz2.lremote.selector.Selector;\r
+\r
+/**\r
+ * xml�t�@�C���̋L�q���ɕԂ�\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class OrderedSelector implements Selector{\r
+       /** �ڑ��ݒ��� */\r
+       private RemoteNodeGroup nodeGroup;\r
+\r
+       /**\r
+        * Constructor\r
+        */\r
+       public OrderedSelector(RemoteNodeGroup nodeGroup){\r
+               this.nodeGroup = nodeGroup;\r
+       }\r
+\r
+       public Connector getConnector(){\r
+               SingleConnector con = null;\r
+               // �ڑ��ł���܂Ń`�������W\r
+               for(RemoteNode remoteNode: nodeGroup.getNodeList()){\r
+                       con = new SingleConnector(remoteNode);\r
+                       if(con.init()){\r
+                               // �ڑ����������烋�[�v�𔲂���B\r
+                               break;\r
+                       }\r
+                       con = null;\r
+               }\r
+               return con;\r
+\r
+       }\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/selector/impl/OthersSelector.java b/src/com/lavans/luz2/lremote/selector/impl/OthersSelector.java
new file mode 100644 (file)
index 0000000..541613b
--- /dev/null
@@ -0,0 +1,43 @@
+package com.lavans.luz2.lremote.selector.impl;\r
+\r
+import com.lavans.luz2.lremote.connector.Connector;\r
+import com.lavans.luz2.lremote.connector.impl.GroupConnector;\r
+import com.lavans.luz2.lremote.node.RemoteNode;\r
+import com.lavans.luz2.lremote.node.RemoteNodeGroup;\r
+import com.lavans.luz2.lremote.selector.Selector;\r
+\r
+/**\r
+ * Connecto to other nodes of same group.\r
+ * Selector must be singleton.\r
+ *\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class OthersSelector implements Selector{\r
+       /** �ڑ��ݒ��� */\r
+       private RemoteNodeGroup group;\r
+\r
+       /**\r
+        * Constructor\r
+        */\r
+       public OthersSelector(RemoteNodeGroup nodeGroup){\r
+               try {\r
+                       this.group = (RemoteNodeGroup)nodeGroup.clone();\r
+                       // remove self\r
+                       for(RemoteNode node: group.getNodeList()){\r
+                               if(node.isSelf()){\r
+                                       group.getNodeList().remove(node);\r
+                                       break;\r
+                               }\r
+                       }\r
+               } catch (CloneNotSupportedException e) {\r
+               }\r
+       }\r
+\r
+       public Connector getConnector(){\r
+               Connector con = new GroupConnector(group);\r
+               return con;\r
+       }\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/service/ServiceManager.java b/src/com/lavans/luz2/lremote/service/ServiceManager.java
new file mode 100644 (file)
index 0000000..82880ea
--- /dev/null
@@ -0,0 +1,10 @@
+/* $Id: ServiceManager.java 18 2010-03-01 18:52:27Z lavans $ */\r
+\r
+package com.lavans.luz2.lremote.service;\r
+\r
+public interface ServiceManager {\r
+       Object getService(String group, String id);\r
+       Object getService(String id);\r
+       Object getServiceLocal(String group, String id);\r
+       Object getServiceLocal(String id);\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/service/ServiceManagerXml.java b/src/com/lavans/luz2/lremote/service/ServiceManagerXml.java
new file mode 100644 (file)
index 0000000..937dcf1
--- /dev/null
@@ -0,0 +1,75 @@
+package com.lavans.luz2.lremote.service;\r
+\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import net.sf.cglib.proxy.Enhancer;\r
+\r
+import com.lavans.luz2.lremote.intercetor.RemoteInterceptor;\r
+import com.lavans.luz2.util.BeanManager;\r
+\r
+/**\r
+ * Service Manager Implementation for XML file(default).\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class ServiceManagerXml implements ServiceManager{\r
+       /** logger */\r
+       //private static final Log logger = LogFactory.getLog(ServiceManagerXml.class);\r
+       /** singleton instance */\r
+       private static ServiceManager instance = new ServiceManagerXml();\r
+\r
+       /** cache of all service */\r
+       private Map<String, Object> serviceMap = Collections.synchronizedMap(new HashMap<String, Object>());\r
+\r
+       /**\r
+        * constructor\r
+        */\r
+       public static ServiceManager getInstance(){\r
+               return instance;\r
+       }\r
+\r
+       private ServiceManagerXml(){\r
+               init();\r
+       }\r
+\r
+       /** initialize */\r
+       public void init(){\r
+       }\r
+\r
+       public Object getService(String group, String id) {\r
+               return getService(BeanManager.toFullId(group, id));\r
+       }\r
+       public Object getService(String id) {\r
+               // search from cache\r
+               Object service = serviceMap.get(id);\r
+               // If service is found, return cache.\r
+               if(service!=null){\r
+                       return service;\r
+               }\r
+\r
+               // If the service is not cached then create new one.\r
+               Class<? extends Object> clazz = BeanManager.getBeanClass(id);\r
+\r
+               // intercept by CGLIB\r
+               Enhancer enhancer = new Enhancer();\r
+               enhancer.setSuperclass(clazz);\r
+               enhancer.setCallback(new RemoteInterceptor());\r
+               service = enhancer.create();\r
+               serviceMap.put(id, service);\r
+\r
+        return service;\r
+       }\r
+\r
+       /**\r
+        * Get for local. Never set Interceptor. This methos equals to BeanManager.\r
+        */\r
+       public Object getServiceLocal(String group, String id) {\r
+               return BeanManager.getBean(group, id);\r
+       }\r
+       public Object getServiceLocal(String id) {\r
+               return BeanManager.getBean(id);\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/lremote/servlet/RemoteServlet.java b/src/com/lavans/luz2/lremote/servlet/RemoteServlet.java
new file mode 100644 (file)
index 0000000..bc8b756
--- /dev/null
@@ -0,0 +1,125 @@
+/* $Id: RemoteServlet.java 18 2010-03-01 18:52:27Z lavans $\r
+ * created: 2005/08/03\r
+ */\r
+package com.lavans.luz2.lremote.servlet;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.IOException;\r
+import java.io.ObjectInputStream;\r
+import java.io.ObjectOutputStream;\r
+import java.io.OutputStream;\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import javax.servlet.ServletException;\r
+import javax.servlet.http.HttpServlet;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.lremote.service.ServiceManager;\r
+import com.lavans.luz2.lremote.service.ServiceManagerXml;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ */\r
+public class RemoteServlet extends HttpServlet {\r
+       /**\r
+        *\r
+        */\r
+       private static final long serialVersionUID = -4697771162210548502L;\r
+\r
+       /** ���K�[�Bdebug�p */\r
+       private static Log logger = LogFactory.getLog(RemoteServlet.class.getName());\r
+\r
+       private Map<String, Object> classMap = Collections.synchronizedMap(new HashMap<String, Object>());\r
+\r
+       /** service manager */\r
+       private ServiceManager serviceManager = ServiceManagerXml.getInstance();\r
+\r
+       /* (�� Javadoc)\r
+        * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)\r
+        */\r
+       protected void doGet(HttpServletRequest request, HttpServletResponse response)\r
+                       throws ServletException, IOException {\r
+               OutputStream os = response.getOutputStream();\r
+               os.write("...lremote...".getBytes());\r
+               os.flush();\r
+       }\r
+       /* (�� Javadoc)\r
+        * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       protected void doPost(HttpServletRequest request, HttpServletResponse response)\r
+                       throws ServletException, IOException {\r
+               ObjectInputStream is = new ObjectInputStream(\r
+                               new BufferedInputStream(request.getInputStream()));\r
+               ObjectOutputStream os = null;\r
+               String className=null;\r
+               String methodName=null;\r
+               try {\r
+                       // --------------------------------------\r
+                       // �N���X\r
+                       // --------------------------------------\r
+                       className = (String)is.readObject();\r
+                       // ���̃N���X���̃T�[�r�X�N���X�̃C���X�^���X���L���b�V��������o��\r
+                       Object service = classMap.get(className);\r
+                       if(service==null){\r
+                               // ���Ȃ��ꍇ�͐V�K�C���X�^���X�𐶐����ăL���b�V���Ɋi�[\r
+//                             Class<? extends Object> clazz = Class.forName(className);\r
+////                           service = clazz.newInstance();\r
+//                             Method method = clazz.getMethod("getInstance", (Class[])null);\r
+//                             service = method.invoke((Class[])null,(Object[])null);\r
+\r
+                               service = serviceManager.getServiceLocal(className);\r
+                               classMap.put(className, service);\r
+                       }\r
+\r
+                       // --------------------------------------\r
+                       // ���\�b�h\r
+                       // --------------------------------------\r
+                       methodName = (String)is.readObject();\r
+\r
+                       // --------------------------------------\r
+                       // ��̌^\r
+                       // --------------------------------------\r
+                       Class<? extends Object>[] paramTypes = (Class<? extends Object>[])is.readObject();\r
+\r
+                       // --------------------------------------\r
+                       // ��\r
+                       // --------------------------------------\r
+                       Object[] args = (Object[])is.readObject();\r
+\r
+                       Method method = service.getClass().getMethod(methodName, paramTypes);\r
+                       Object result = null;\r
+                       // ���\�b�h���s��O��Web���ɑ���B\r
+                       try{\r
+                               result = method.invoke(service, args);\r
+                       }catch(InvocationTargetException e){\r
+                               // ���\�b�h���s���ɃG���[�ɂȂ����ꍇ�́A���̃G���[���Ăяo�����ɓ]������B\r
+                               result = e.getCause();\r
+                       }\r
+\r
+                       // --------------------------------------\r
+                       // �����o������\r
+                       // --------------------------------------\r
+                       os = new ObjectOutputStream(\r
+                                       response.getOutputStream());\r
+                       os.writeObject(result);\r
+                       os.flush();\r
+\r
+               } catch (Exception e) {\r
+                       logger.error( "RemoteServlet#invoke() failed.",e);\r
+        }finally{\r
+               is.close();\r
+               os.close();\r
+        }\r
+\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/ConnectionPool.java b/src/com/lavans/luz2/sql/ConnectionPool.java
new file mode 100644 (file)
index 0000000..b943f9c
--- /dev/null
@@ -0,0 +1,514 @@
+/**\r
+ * $Id: ConnectionPool.java 222 2010-09-06 19:20:24Z dobashi $\r
+ *\r
+ * Copyright Lavans Networks Inc.\r
+ */\r
+package com.lavans.luz2.sql;\r
+\r
+import java.sql.Connection;\r
+import java.sql.Driver;\r
+import java.sql.SQLException;\r
+import java.sql.Statement;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+import java.util.Properties;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindConnectionImpl;\r
+import com.lavans.luz2.sql.pool.PooledConnection;\r
+import com.lavans.luz2.sql.stats.Statistics;\r
+import com.lavans.luz2.sql.stats.StatsConnection;\r
+\r
+/**\r
+ * ConnectionPool。\r
+ * DBManagerからのみ利用される。\r
+ *\r
+ * @author     dobashi\r
+ * @version 1.0\r
+ * @version 1.1 dobashi20040707 接続の有効性はcreateStatement()だけでチェックできるはず\r
+ */\r
+public class ConnectionPool{\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ConnectionPool.class);\r
+\r
+       /**\r
+        * DB接続用定義\r
+        */\r
+       private String driverName = null;\r
+       private String url     = null;\r
+       private String user   = null;\r
+       private String pass   = null;\r
+\r
+       /**\r
+        * NativeDriver.\r
+        * ConnectionPoolは接続先ごとにインスタンス化されるので、\r
+        * DriverManagerに管理させる必要はなく、ConnectionPool毎に\r
+        * 実Driverインスタンスを持つ。\r
+        */\r
+       private Driver driver = null;\r
+\r
+       /**\r
+        * SQL統計情報を収集するか。\r
+        * trueならcreateConnectionしたときにStatsConnectionでラップする。\r
+        */\r
+       private boolean statistics = false;\r
+\r
+       /**\r
+        * SQLログを出力するか。\r
+        */\r
+       private boolean isLogging = true;\r
+\r
+       /**\r
+        * コネクション最大数。\r
+        * デフォルトは10。lavansutil.xmlのinit_connectionsで変更可能。\r
+        */\r
+       private int max_connections  = 10;\r
+\r
+       /**\r
+        * 初期コネクション数。\r
+        * デフォルトは2。lavansutil.xmlのinit_connectionsで変更可能。\r
+        */\r
+       private int init_connections = 2;\r
+\r
+       /**\r
+        * 空きコネクションリスト。\r
+        */\r
+       private final List<PooledConnection> poolList = Collections.synchronizedList(new ArrayList<PooledConnection>());\r
+       /**\r
+        * 使用中コネクションリスト。\r
+        */\r
+       private final List<PooledConnection> useList  = Collections.synchronizedList(new ArrayList<PooledConnection>());\r
+\r
+       /**\r
+        * トランザクション管理\r
+        */\r
+       private final ThreadLocal<PooledConnection> transactionList = new ThreadLocal<PooledConnection>();\r
+\r
+       protected static final String MSG_ERR_TOOMANYCONNECTIONS = "接続数が最大値を超えています。";\r
+       protected static final String SQLSTATE_CONNECTION_EXCEPTION = "08000";\r
+       public static final int ERR_CONNECTION_OVERFLOW = 1;\r
+\r
+       /**\r
+        * 強制チェックフラグ。\r
+        */\r
+       private boolean isForceCheck=false;\r
+       /**\r
+        * 強制チェック用SQL。\r
+        */\r
+       private String validSql=null;\r
+\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        **/\r
+       public ConnectionPool(String aDriver, String aUrl,String aUser,String aPass){\r
+               driverName    = aDriver;\r
+               url       = aUrl;\r
+               user      = aUser;\r
+               pass      = aPass;\r
+       }\r
+\r
+       /**\r
+        * 接続数最大値設定\r
+        **/\r
+       public void setMaxConnections(int value){\r
+               max_connections = value;\r
+       }\r
+\r
+       /**\r
+        * 接続数初期値設定\r
+        **/\r
+       public void setInitConnections(int value){\r
+               init_connections = value;\r
+       }\r
+\r
+       /**\r
+        * 初期化\r
+        **/\r
+       public void init()\r
+               throws ClassNotFoundException,IllegalAccessException,InstantiationException, SQLException\r
+       {\r
+               driver = (Driver)Class.forName(driverName).newInstance();\r
+               for(int i=0; i<init_connections; i++){\r
+                       poolList.add(createConnection());\r
+               }\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション作成。\r
+        * 設定ファイルが間違っていてDriverManager#getConnection()の戻りが遅いときに、\r
+        * 何度もcreateConnectionするのを防ぐためsynchronizedとする。\r
+        * ただし、DoSアタックによるスタックオーバーフローは避けられないので\r
+        * 間違った設定ファイルのまま運用すべきでない。\r
+        */\r
+       protected synchronized PooledConnection createConnection()\r
+         throws SQLException\r
+       {\r
+               // from java.sql.DriverManager\r
+               Properties info = new Properties();\r
+               if (user != null) {\r
+                   info.put("user", user);\r
+               }\r
+               if (pass != null) {\r
+                   info.put("password", pass);\r
+               }\r
+\r
+               // 最大数チェック\r
+               if((poolList.size() + useList.size()) >= max_connections){\r
+                       throw new SQLException(MSG_ERR_TOOMANYCONNECTIONS, SQLSTATE_CONNECTION_EXCEPTION, ERR_CONNECTION_OVERFLOW);\r
+               }\r
+               Connection conn = null;\r
+               logger.info(url+":"+user+":"+pass);\r
+               try {\r
+                       conn = driver.connect(url, info);\r
+               } catch (SQLException e) {\r
+                       throw e;\r
+               }\r
+\r
+               // Loggableを実装しないラッパークラスを作る場合はこれらの前にnewすること。\r
+\r
+               // 統計情報を収集するなら\r
+               if(statistics){\r
+                       conn = new StatsConnection(conn);\r
+               }\r
+\r
+               // BindConnection型を返すので、BindConnectionでラップするのは\r
+               // 一番最後でないといけない。\r
+               BindConnection bcon = new BindConnectionImpl(conn);\r
+\r
+               // さらにConnection#close()で物理的に閉じずにDBManagerに\r
+               // 返却するためPooledConnectionでラップする。\r
+               // ConnectionPoolではなくDBManagerを通すのは\r
+               // 統計情報取得時に貸し出し管理を行うため。\r
+               PooledConnection pcon = new PooledConnection(this,bcon);\r
+\r
+               return pcon;\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクションチェック。\r
+        * force_checkを再導入することでDB(postgres)を再起動したときにも\r
+        * 自動で再接続出来る事を確認。\r
+        */\r
+       protected boolean checkConnection(Connection conn)\r
+       {\r
+               boolean result = false;\r
+               Statement st = null;\r
+               //ResultSet rs = null;\r
+               try\r
+               {\r
+                       st = conn.createStatement();\r
+                       if(isForceCheck){\r
+                               st.executeQuery(validSql);\r
+                       }\r
+\r
+                       result = true;                  // 例外がなければOK\r
+               }catch (SQLException e) {\r
+                       // ここでキャッチしておかないとgetConnection()自身が\r
+                       // 例外を生成してしまう。\r
+               }finally{\r
+                       try{\r
+                               st.close();\r
+                               //rs.close();\r
+                       }catch(Exception e){\r
+                       }\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション取得\r
+        */\r
+       public PooledConnection getConnection() throws SQLException{\r
+               return getConnection(true);\r
+       }\r
+       /**\r
+        * DBへのコネクション取得\r
+        *\r
+        * @param countStats StatsでgetConnection()をカウントするかどうか。startTransaction()からはカウントしない。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private PooledConnection getConnection(boolean countStats) throws SQLException {\r
+               PooledConnection conn=null;\r
+               // トランザクション中なら該当するコネクションを返す\r
+               conn = transactionList.get();\r
+               if(conn!=null){\r
+                       // トランザクション中のカウント\r
+                       if(statistics){\r
+                               Statistics.getInstance().getConnectionTran();\r
+                       }\r
+                       // 接続チェックはしない。トランザクション中にエラーになるようであれば\r
+                       // 利用側がエラーハンドリングする必要がある。\r
+                       return conn;\r
+               }\r
+\r
+               // 空きプールから捜す\r
+               synchronized(poolList){\r
+                       if(poolList.size()>0){                  // プールがあれば\r
+                               conn=poolList.remove(0);        //\r
+                               if(!checkConnection(conn)){             // 接続失敗したら\r
+                                       try{\r
+                                               conn.getRealConnection().close();\r
+                                       }catch(Exception e){\r
+                                       }\r
+                                       conn=null;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               if(conn==null){\r
+                       conn=createConnection();\r
+               }\r
+               if(logger.isDebugEnabled()) logger.debug("□□ "+conn.toString());\r
+               useList.add(conn);\r
+               if(logger.isDebugEnabled()) logger.debug(useList.toString());\r
+\r
+               // 接続状態管理をする場合 ----------------\r
+               if(statistics && countStats){\r
+                       Statistics.getInstance().getConnection();\r
+               }\r
+\r
+               return conn;\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション返却\r
+        */\r
+       public void releaseConnection(Connection conn) throws SQLException{\r
+               releaseConnection(conn, true);\r
+       }\r
+       /**\r
+        * DBへのコネクション返却\r
+        *\r
+        * @param conn\r
+        * @param countStats StatsでgetConnection()をカウントするかどうか。commit/rollback()からはカウントしない。\r
+        * @throws SQLException\r
+        */\r
+       private void releaseConnection(Connection conn, boolean countStats) throws SQLException{\r
+               // トランザクション中かどうかチェック\r
+               PooledConnection connTran = transactionList.get();\r
+               if(connTran==conn){\r
+                       // トランザクション中のカウント\r
+                       if(statistics){\r
+                               Statistics.getInstance().releaseConnectionTran();\r
+                       }                       // トランザクション中の場合はなにもしない\r
+                       return;\r
+               }\r
+\r
+               conn.setAutoCommit(true);                       // 返却時は必ずcommit()されている状態にする。\r
+               // statement.close()を行ってないものがいたら閉じておく\r
+               if(conn instanceof PooledConnection){\r
+                       ((PooledConnection)conn).clearStatementList();\r
+               }\r
+               if(logger.isDebugEnabled()) logger.debug("□□ "+conn.toString());\r
+               if(logger.isDebugEnabled()) logger.debug(useList.toString());\r
+               if(!useList.remove(conn)){              // 使用中リストに存在しなければ\r
+                       throw new SQLException("This is not my connection.");\r
+               }\r
+\r
+               // 接続状態管理をする場合 ----------------\r
+               if(statistics && countStats){\r
+                       Statistics.getInstance().releaseConnection();\r
+               }\r
+\r
+               poolList.add((PooledConnection)conn);\r
+       }\r
+\r
+       /**\r
+        * トランザクションスタート\r
+        * すでにトランザクションがスタートしていてもOK。\r
+        *\r
+        * @throws SQLException\r
+        */\r
+       public void startTransaction() throws SQLException{\r
+               // すでにトランザクション中の場合\r
+               if(isTransaction()){\r
+                       if(statistics){\r
+                               Statistics.getInstance().startTransactionTran();\r
+                       }\r
+                       return;\r
+               }\r
+\r
+               PooledConnection conn = getConnection(false);\r
+               conn.setAutoCommit(false);\r
+               transactionList.set(conn);\r
+               // 接続状態管理をする場合 ----------------\r
+               if(statistics){\r
+                       Statistics.getInstance().startTransaction();\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        * トランザクションコミット\r
+        * @throws SQLException\r
+        */\r
+       public void commit() throws SQLException{\r
+               PooledConnection conn = transactionList.get();\r
+               if(conn==null){\r
+                       // 接続状態管理をする場合 ----------------\r
+                       if(statistics){\r
+                               Statistics.getInstance().commitNoTran();\r
+                       }\r
+                       // トランザクション中で無い場合\r
+                       // エラーにしない\r
+                       return;\r
+               }\r
+               conn.commit();\r
+               transactionList.remove();\r
+               releaseConnection(conn, false);\r
+               // 接続状態管理をする場合 ----------------\r
+               if(statistics){\r
+                       Statistics.getInstance().commit();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * トランザクションロールバック\r
+        * @throws SQLException\r
+        */\r
+       public void rollback() throws SQLException{\r
+               PooledConnection conn = transactionList.get();\r
+               if(conn==null){\r
+                       // 接続状態管理をする場合 ----------------\r
+                       if(statistics){\r
+                               Statistics.getInstance().rollbackNoTran();\r
+                       }\r
+                       // トランザクション中で無い場合\r
+                       // エラーにしない\r
+                       return;\r
+               }\r
+               conn.rollback();\r
+               transactionList.remove();\r
+               releaseConnection(conn, false);\r
+               // 接続状態管理をする場合 ----------------\r
+               if(statistics){\r
+                       Statistics.getInstance().rollback();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * トランザクション実行中かどうかを返す。\r
+        * @return\r
+        */\r
+       public boolean isTransaction(){\r
+               return transactionList.get()!=null;\r
+       }\r
+\r
+       /**\r
+        * @param b\r
+        */\r
+       public void setStatistics(boolean b) {\r
+               statistics = b;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       public Log getLogger() {\r
+               return logger;\r
+       }\r
+\r
+       /**\r
+        * @param logger\r
+        */\r
+       public void setLogger(Log logger) {\r
+               ConnectionPool.logger = logger;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected int getMaxConnections() {\r
+               return max_connections;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected Driver getDriver() {\r
+               return driver;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected String getUser() {\r
+               return user;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected String getPass() {\r
+               return pass;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected List<PooledConnection> getPoolList() {\r
+               return poolList;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected boolean isStatistics() {\r
+               return statistics;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       protected List<PooledConnection> getUseList() {\r
+               return useList;\r
+       }\r
+\r
+       /**\r
+        * @param isForceCheck isForceCheck を設定。\r
+        */\r
+       public void setForceCheck(boolean isForceCheck) {\r
+               this.isForceCheck = isForceCheck;\r
+       }\r
+       /**\r
+        * @param validSql validSql を設定。\r
+        */\r
+       public void setValidSql(String validSql) {\r
+               this.validSql = validSql;\r
+       }\r
+       /**\r
+        * @return isLogging を戻します。\r
+        */\r
+       public boolean isLogging() {\r
+               return isLogging;\r
+       }\r
+       /**\r
+        * @param isLogging isLogging を設定。\r
+        */\r
+       public void setLogging(boolean isLogging) {\r
+               this.isLogging = isLogging;\r
+       }\r
+\r
+       /**\r
+        * 現在使用中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public int getUseCount(){\r
+               return useList.size();\r
+       }\r
+\r
+       /**\r
+        * 現在待機中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public int getPoolCount(){\r
+               return poolList.size();\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/DBManager.java b/src/com/lavans/luz2/sql/DBManager.java
new file mode 100644 (file)
index 0000000..7803915
--- /dev/null
@@ -0,0 +1,403 @@
+/**\r
+ * $Id: DBManager.java 413 2011-07-28 23:05:11Z dobashi $\r
+ *\r
+ * Copyright Lavans Networks Inc.\r
+ */\r
+package com.lavans.luz2.sql;\r
+\r
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.sql.ConnectionPool;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.cluster.ClusterConnectionPool;\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * DBManager.\r
+ * ログはdefaultのロガーに書き出すので、別のログファイルに\r
+ * 出したい場合はDBManagerを使う前にLogger#init()を行うこと。\r
+ *\r
+ * @author     dobashi\r
+ * @version    1.0\r
+ */\r
+public class DBManager{\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(DBManager.class);\r
+\r
+//     private static final String CLASSNAME=DBManager.class.getName();\r
+       /**\r
+        * 設定ファイルのセクション名。\r
+        */\r
+       private static final String CONFIG_SECTION="database";\r
+\r
+       /**\r
+        * Database一覧。ConnectionPoolを保存する配列。\r
+        */\r
+       private static Map<String, ConnectionPool>  dbMap = null;\r
+\r
+       /**\r
+        * 初期化済みフラグ。\r
+        */\r
+//     private static boolean initFlg=false;\r
+\r
+\r
+       /**\r
+        * 設定ファイル名。\r
+        */\r
+       private static final String MSG_ERR_CLUSTER_UNMATCH="クラスタノードの設定がありません。ノード番号:";\r
+       /**\r
+        * 初期化。\r
+        */\r
+       static{\r
+               init();\r
+       }\r
+\r
+       /**\r
+        * 初期化。\r
+        */\r
+       public static void init(){\r
+               // databaseセクションの取得 ----------------------------\r
+               dbMap = new HashMap<String, ConnectionPool>();\r
+               Element conf = (Element)Config.getInstance().getNode(CONFIG_SECTION);\r
+               NodeList nodeList = conf.getChildNodes();\r
+               if(nodeList==null){     // 設定ファイルにdatabase指定が無い場合は\r
+                       return;                 // なにもしない。\r
+               }\r
+\r
+               // 統計情報、接続管理 ----------------------------------\r
+               boolean statistics = false;\r
+               try{\r
+                       statistics = Boolean.valueOf(conf.getAttribute("statistics")).booleanValue();\r
+               }catch (Exception e) {\r
+                       // 失敗したらfalseのまま\r
+               }\r
+\r
+               String name=null,driver=null,url=null,user=null,pass=null,valid_sql=null,max=null,init=null;\r
+               for(int i=0; i<nodeList.getLength(); i++){\r
+\r
+                       if((nodeList.item(i).getNodeType()==Node.TEXT_NODE) ||\r
+                          (nodeList.item(i).getNodeType()==Node.COMMENT_NODE) ){\r
+                               continue;\r
+                       }\r
+                       Element dbConf = (Element)nodeList.item(i);\r
+\r
+                       name   = dbConf.getNodeName();\r
+                       driver = dbConf.getAttribute("driver");\r
+                       url    = dbConf.getAttribute("url");\r
+                       user   = dbConf.getAttribute("user");\r
+                       pass   = dbConf.getAttribute("pass");\r
+                       max    = dbConf.getAttribute("max_connections");\r
+                       init   = dbConf.getAttribute("init_connections");\r
+                       logger.debug("max:"+max+", init:"+init);\r
+//                     isForceCheck = Boolean.parseBoolean(dbConf.getAttribute("force_check_connection"));\r
+                       boolean isForceCheck = Boolean.valueOf(dbConf.getAttribute("force_check_connection")).booleanValue();\r
+               valid_sql    = dbConf.getAttribute("valid_sql");\r
+\r
+                       ConnectionPool pool = null;\r
+                       // ClusterConnection判定\r
+                       int node = 1;\r
+                       try{\r
+                               node = Integer.parseInt(dbConf.getAttribute("cluster_node"));\r
+                       }catch (Exception e) {}\r
+\r
+                       if(node>1){\r
+                               pool = new ClusterConnectionPool(driver,url,user,pass);\r
+                               // 接続先urlの設定\r
+                               List<String> urlList = new ArrayList<String>(node);\r
+                               urlList.add(url);\r
+                               for(int j=1; j<node; j++){\r
+                                       String cluster_url = dbConf.getAttribute("url"+(j+1));\r
+                                       if(cluster_url.equals("")){\r
+                                               logger.warn(MSG_ERR_CLUSTER_UNMATCH+"["+j+"].");\r
+                                       }else{\r
+                                               urlList.add(cluster_url);\r
+                                       }\r
+                               }\r
+                               ((ClusterConnectionPool)pool).setUrlList(urlList);\r
+                       }else{\r
+                               logger.debug("★ConnectionPool作成:"+ name);\r
+                               pool = new ConnectionPool(driver,url,user,pass);\r
+                       }\r
+\r
+                       // 最大接続数\r
+                       try{\r
+                               pool.setMaxConnections(Integer.parseInt(max));\r
+                       }catch(NumberFormatException e){}\r
+                       // 接続初期数\r
+                       try{\r
+                               pool.setInitConnections(Integer.parseInt(init));\r
+                       }catch(NumberFormatException e){}\r
+                       // SQL統計情報\r
+                       pool.setStatistics(statistics);\r
+                       // Log4J対応に伴いSQLログ分離機能停止\r
+//                     String logger_name = dbConf.getAttribute("logger");\r
+//                     if(!logger_name.equals("")){\r
+//                             Logger logger = Logger.getInstance(logger_name);\r
+//                             pool.setLogger(logger);\r
+//                     }\r
+                       // 強制チェック\r
+                       if(isForceCheck){\r
+                               pool.setForceCheck(isForceCheck);\r
+                               pool.setValidSql(valid_sql);\r
+                       }\r
+                       // SQLロギング\r
+                       boolean isLogging = true;\r
+                       try{\r
+                               isLogging = Boolean.valueOf(dbConf.getAttribute("logging")).booleanValue();\r
+                       }catch (Exception e) {\r
+                       }\r
+                       pool.setLogging(isLogging);\r
+\r
+                       // 初期化開始\r
+                       try{\r
+                               pool.init();\r
+                       }catch(Exception e){\r
+                               logger.error("ConnectionPool init failed.", e);\r
+                       }\r
+                       dbMap.put(name,pool);\r
+                       logger.debug( "create ConnectionPool["+name+"]");\r
+               }\r
+\r
+//             initFlg = true;\r
+       }\r
+\r
+\r
+       /**\r
+        * DBへのコネクション取得\r
+        */\r
+       public static BindConnection getConnection()\r
+         throws SQLException\r
+       {\r
+               return getConnection("default");\r
+       }\r
+       /**\r
+        * DBへのコネクション取得\r
+        */\r
+       public static BindConnection getConnection(String dbName)\r
+         throws SQLException                           // 例外は呼び出し元へ丸投げ\r
+       {\r
+               // 初期化チェック。毎回チェックするのは避けたい。\r
+//             if(!initFlg){\r
+//                     init(configFile);\r
+//             }\r
+\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+\r
+               return pool.getConnection();\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション返却\r
+        */\r
+       public static void releaseConnection(Connection conn)\r
+         throws SQLException                           // 例外は呼び出し元へ丸投げ\r
+       {\r
+               releaseConnection(conn,"default");\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション返却。\r
+        */\r
+       public static void releaseConnection(Connection conn,String dbName)\r
+               throws SQLException\r
+       {\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               releaseConnection(conn,pool);\r
+       }\r
+\r
+       /**\r
+        * DBへのコネクション返却。\r
+        * ConnectionPool指定。PooledConnection#close()から呼ばれる。\r
+        */\r
+       public static void releaseConnection(Connection conn,ConnectionPool pool)\r
+               throws SQLException\r
+       {\r
+               pool.releaseConnection(conn);\r
+       }\r
+\r
+       /**\r
+        * 使用中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public static int getConnectionCount(){\r
+               return getConnectionCount("default");\r
+       }\r
+\r
+       /**\r
+        * 使用中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public static int getConnectionCount(String dbName){\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               return pool.getUseCount();\r
+       }\r
+\r
+       /**\r
+        * 待機中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public static int getPoolCount(){\r
+               return getPoolCount("default");\r
+       }\r
+\r
+       /**\r
+        * 待機中のコネクション数を返す。\r
+        * @return\r
+        */\r
+       public static int getPoolCount(String dbName){\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               return pool.getPoolCount();\r
+       }\r
+\r
+       /**\r
+        * コネクション最大数を返す。\r
+        * @return\r
+        */\r
+       public static int getMaxConnections(){\r
+               return getMaxConnections("default");\r
+       }\r
+       /**\r
+        * コネクション最大数を返す。DB指定。\r
+        * @return\r
+        */\r
+       public static int getMaxConnections(String dbName){\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               return pool.getMaxConnections();\r
+       }\r
+\r
+       /**\r
+        * コネクション最大数をセットする。DB指定。\r
+        * @return\r
+        */\r
+       public static void setMaxConnections(int count){\r
+               setMaxConnections("default", count);\r
+       }\r
+\r
+       /**\r
+        * コネクション最大数をセットする。DB指定。\r
+        * @return\r
+        */\r
+       public static void setMaxConnections(String dbName, int count){\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               pool.setMaxConnections(count);\r
+       }\r
+\r
+       /**\r
+        * トランザクションスタート\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void startTransaction() throws SQLException{\r
+               startTransaction("default");\r
+       }\r
+\r
+       /**\r
+        * トランザクションスタート。DB指定。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void startTransaction(String dbName) throws SQLException{\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               pool.startTransaction();\r
+       }\r
+\r
+       /**\r
+        * トランザクションコミット\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void commit() throws SQLException{\r
+               commit("default");\r
+       }\r
+\r
+       /**\r
+        * トランザクションコミット。DB指定。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void commit(String dbName) throws SQLException{\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               pool.commit();\r
+       }\r
+\r
+       /**\r
+        * トランザクションコミット\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void rollback() throws SQLException{\r
+               rollback("default");\r
+       }\r
+\r
+       /**\r
+        * トランザクションロールバック。DB指定。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static void rollback(String dbName) throws SQLException{\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               pool.rollback();\r
+       }\r
+\r
+       /**\r
+        * トランザクション実行中かどうかを返す。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public static boolean isTransaction(){\r
+               return isTransaction("default");\r
+       }\r
+\r
+       /**\r
+        * トランザクション実行中かどうかを返す。\r
+        * @param dbName\r
+        * @return\r
+        */\r
+       public static boolean isTransaction(String dbName){\r
+               ConnectionPool pool = dbMap.get(dbName);\r
+               if(pool==null){\r
+                       throw new NullPointerException("no such database name:"+ dbName);\r
+               }\r
+               return pool.isTransaction();\r
+       }\r
+\r
+       /**\r
+        * トランザクション実行中かどうかを返す。\r
+        * すべてのコネクションプールを対象とする。\r
+        *\r
+        * @return\r
+        */\r
+       public static boolean isTransactionAll(){\r
+               for(ConnectionPool pool: dbMap.values()){\r
+                       if(pool.isTransaction()){\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+       /**\r
+        * コミット処理。\r
+        * すべてのコネクションプールを対象とする。\r
+        *\r
+        * @return\r
+        */\r
+       public static void commitAll() throws SQLException{\r
+               for(ConnectionPool pool: dbMap.values()){\r
+                       if(pool.isTransaction()){\r
+                               pool.commit();\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/DataSourceWrapper.java b/src/com/lavans/luz2/sql/DataSourceWrapper.java
new file mode 100644 (file)
index 0000000..3d2a71d
--- /dev/null
@@ -0,0 +1,100 @@
+/* $Id: DataSourceWrapper.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2005/01/27\r
+ * (c)2005 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql;\r
+\r
+import java.io.PrintWriter;\r
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+\r
+import javax.sql.DataSource;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class DataSourceWrapper implements DataSource{\r
+       private int loginTimeout=0;\r
+       private String dbName="default";\r
+\r
+       /** logwriter.この実装でいいのか? */\r
+       private PrintWriter logWriter = null;\r
+//     private Logger logger = Logger.getLogger(DataSourceWrapper.class);\r
+\r
+       /**\r
+        * コンストラクタ。データベース名指定なし。\r
+        * 設定ファイルのdefaultセクションを使用する。\r
+        * @param dbName\r
+        */\r
+       public DataSourceWrapper(){\r
+\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。データベース名指定あり。\r
+        * 設定ファイルのセクション名を指定できる。\r
+        * @param dbName\r
+        */\r
+       public DataSourceWrapper(String dbName){\r
+               this.dbName = dbName;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.sql.DataSource#getConnection()\r
+        */\r
+       public Connection getConnection() throws SQLException {\r
+               return DBManager.getConnection(dbName);\r
+       }\r
+\r
+       /**\r
+        * コネクションの取得。user/pass指定。\r
+        * user/passは設定ファイルから取得するのでここで指定した値は無効。\r
+        * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)\r
+        */\r
+       public Connection getConnection(String arg0, String arg1)\r
+                       throws SQLException {\r
+               return DBManager.getConnection(dbName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see javax.sql.DataSource#getLoginTimeout()\r
+        */\r
+       public int getLoginTimeout() throws SQLException {\r
+               return loginTimeout;\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see javax.sql.DataSource#getLogWriter()\r
+        */\r
+       public PrintWriter getLogWriter() throws SQLException {\r
+               return logWriter;\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see javax.sql.DataSource#setLoginTimeout(int)\r
+        */\r
+       public void setLoginTimeout(int arg0) throws SQLException {\r
+               loginTimeout = arg0;\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter)\r
+        */\r
+       public void setLogWriter(PrintWriter logWriter) throws SQLException {\r
+               this.logWriter = logWriter;\r
+       }\r
+\r
+//     @Override\r
+       public boolean isWrapperFor(Class<?> arg0) throws SQLException {\r
+               // とりあえずfalse\r
+//             if(arg0 instanceof DataSource){\r
+//                     return true;\r
+//             }\r
+               return false;\r
+       }\r
+\r
+       @SuppressWarnings("unchecked")\r
+//     @Override\r
+       public <T> T unwrap(Class<T> arg0) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/DriverWrapper.java b/src/com/lavans/luz2/sql/DriverWrapper.java
new file mode 100644 (file)
index 0000000..be24838
--- /dev/null
@@ -0,0 +1,169 @@
+/* $Id: DriverWrapper.java 413 2011-07-28 23:05:11Z dobashi $\r
+ * created: 2005/05/24\r
+ *\r
+ */\r
+package com.lavans.luz2.sql;\r
+\r
+import java.sql.Connection;\r
+import java.sql.Driver;\r
+import java.sql.DriverManager;\r
+import java.sql.DriverPropertyInfo;\r
+import java.sql.SQLException;\r
+import java.util.Properties;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * Driverラッパークラス。\r
+ * DBManagerを直接使用できない環境でClusterConnectionを使用するためのラッパー。\r
+ * lavansutil.xmlのdatabase-defaultに定義したDB接続情報でConnectionを返す。\r
+ *\r
+ * DriverWrapperを使用する場合はlavansutil.xmlの設定ではなく\r
+ * 渡されたurlを元に\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class DriverWrapper implements Driver{\r
+       /** Logger */\r
+       private static final Log logger = LogFactory.getLog(DriverWrapper.class);\r
+\r
+       /**\r
+        * 設定ファイル名。\r
+        */\r
+       private static final String CONFIG_FILE ="lavansutil.xml";\r
+\r
+       /**\r
+        * 設定ファイルのセクション名。\r
+        */\r
+       private static final String CONFIG_SECTION="database";\r
+\r
+       /**\r
+        * DriverWrapperを呼び出す側で設定する接続url\r
+        */\r
+       private static final String DRIVER_URL="jdbc:lavans";\r
+\r
+       /** 処理移譲先 */\r
+       private Driver driver = null;\r
+\r
+       static{\r
+               try {\r
+                       DriverManager.registerDriver(new DriverWrapper());\r
+               } catch (Exception e) {\r
+                       logger.error("driver resgister failed.", e);\r
+\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ\r
+        */\r
+       public DriverWrapper() {\r
+               Element conf = (Element)Config.getInstance(CONFIG_FILE).getNode(CONFIG_SECTION);\r
+               NodeList nodeList = conf.getChildNodes();\r
+               String driverName = null;\r
+               for(int i=0; i<nodeList.getLength(); i++){\r
+                       if((nodeList.item(i).getNodeType()==Node.TEXT_NODE) ||\r
+                          (nodeList.item(i).getNodeType()==Node.COMMENT_NODE) ){\r
+                               continue;\r
+                       }\r
+                       Element dbConf = (Element)nodeList.item(i);\r
+                       String name = dbConf.getNodeName();\r
+                       if(name.equals("default")){\r
+                               driverName = dbConf.getAttribute("driver");\r
+                               break;\r
+                       }\r
+               }\r
+\r
+\r
+               if(driverName==null){\r
+                       logger.error("database-default設定情報が見つからない。");\r
+                       return;\r
+               }\r
+\r
+               try{\r
+                       driver = (Driver)Class.forName(driverName).newInstance();\r
+                       logger.debug("load success.["+ driver.getClass().getName() +"]");\r
+               }catch (Exception e) {\r
+                       logger.error("load failed.["+ driver.getClass().getName() +"]", e);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Connection connect(String arg0, Properties arg1) throws SQLException {\r
+               logger.debug("DriverWrapper#connect()");\r
+               return DBManager.getConnection();\r
+       }\r
+\r
+       /**\r
+        * 接続urlを受け付けるかどうかの判定。\r
+        * @param url\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean acceptsURL(String url) throws SQLException {\r
+               logger.debug("DriverWrapper#acceptsURL()");\r
+               return url.startsWith(DRIVER_URL);\r
+       }\r
+\r
+       //以下すべてただの委譲メソッド\r
+       /* (非 Javadoc)\r
+        * @see java.lang.Object#equals(java.lang.Object)\r
+        */\r
+       @Override\r
+       public boolean equals(Object arg0) {\r
+               return driver.equals(arg0);\r
+       }\r
+       /**\r
+        * @return\r
+        */\r
+       public int getMajorVersion() {\r
+               return driver.getMajorVersion();\r
+       }\r
+       /**\r
+        * @return\r
+        */\r
+       public int getMinorVersion() {\r
+               return driver.getMinorVersion();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public DriverPropertyInfo[] getPropertyInfo(String arg0, Properties arg1)\r
+                       throws SQLException {\r
+               return driver.getPropertyInfo(arg0, arg1);\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see java.lang.Object#hashCode()\r
+        */\r
+       @Override\r
+       public int hashCode() {\r
+               return driver.hashCode();\r
+       }\r
+       /**\r
+        * @return\r
+        */\r
+       public boolean jdbcCompliant() {\r
+               return driver.jdbcCompliant();\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see java.lang.Object#toString()\r
+        */\r
+//     public String toString() {\r
+//             return driver.toString();\r
+//     }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/bind/BindCallableStatement.java b/src/com/lavans/luz2/sql/bind/BindCallableStatement.java
new file mode 100644 (file)
index 0000000..e1030ec
--- /dev/null
@@ -0,0 +1,7 @@
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.sql.CallableStatement;\r
+\r
+public interface BindCallableStatement extends BindPreparedStatement, CallableStatement{\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/bind/BindCallableStatementImpl.java b/src/com/lavans/luz2/sql/bind/BindCallableStatementImpl.java
new file mode 100644 (file)
index 0000000..34b7804
--- /dev/null
@@ -0,0 +1,1063 @@
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import com.lavans.luz2.sql.logging.Loggable;\r
+\r
+public class BindCallableStatementImpl extends BindPreparedStatementImpl implements BindCallableStatement{\r
+       //private static Log logger = LogFactory.getLog(BindCallableStatementImpl.class);\r
+\r
+       private CallableStatement st=null;      // 処理移譲先\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        *\r
+        * @param st\r
+        */\r
+       public BindCallableStatementImpl(CallableStatement st, String sql, Map<String, List<Integer>> paramMap) {\r
+               super(st, sql, paramMap);\r
+\r
+               // 移譲先もLoggableな場合は移譲先にもlog用sqlを渡す。\r
+               if (st instanceof Loggable) {\r
+                       ((Loggable) st).setLogsql(sql);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getArray(int)\r
+        */\r
+       public Array getArray(int i) throws SQLException {\r
+               return st.getArray(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getArray(java.lang.String)\r
+        */\r
+       public Array getArray(String parameterName) throws SQLException {\r
+               return st.getArray(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBigDecimal(int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {\r
+               return st.getBigDecimal(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBigDecimal(java.lang.String)\r
+        */\r
+       public BigDecimal getBigDecimal(String parameterName) throws SQLException {\r
+               return st.getBigDecimal(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param scale\r
+        * @return\r
+        * @throws SQLException\r
+        * @deprecated\r
+        * @see java.sql.CallableStatement#getBigDecimal(int, int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {\r
+               return st.getBigDecimal(parameterIndex, scale);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBlob(int)\r
+        */\r
+       public Blob getBlob(int i) throws SQLException {\r
+               return st.getBlob(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBlob(java.lang.String)\r
+        */\r
+       public Blob getBlob(String parameterName) throws SQLException {\r
+               return st.getBlob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBoolean(int)\r
+        */\r
+       public boolean getBoolean(int parameterIndex) throws SQLException {\r
+               return st.getBoolean(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBoolean(java.lang.String)\r
+        */\r
+       public boolean getBoolean(String parameterName) throws SQLException {\r
+               return st.getBoolean(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getByte(int)\r
+        */\r
+       public byte getByte(int parameterIndex) throws SQLException {\r
+               return st.getByte(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getByte(java.lang.String)\r
+        */\r
+       public byte getByte(String parameterName) throws SQLException {\r
+               return st.getByte(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBytes(int)\r
+        */\r
+       public byte[] getBytes(int parameterIndex) throws SQLException {\r
+               return st.getBytes(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBytes(java.lang.String)\r
+        */\r
+       public byte[] getBytes(String parameterName) throws SQLException {\r
+               return st.getBytes(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getClob(int)\r
+        */\r
+       public Clob getClob(int i) throws SQLException {\r
+               return st.getClob(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getClob(java.lang.String)\r
+        */\r
+       public Clob getClob(String parameterName) throws SQLException {\r
+               return st.getClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(int)\r
+        */\r
+       public Date getDate(int parameterIndex) throws SQLException {\r
+               return st.getDate(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String)\r
+        */\r
+       public Date getDate(String parameterName) throws SQLException {\r
+               return st.getDate(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)\r
+        */\r
+       public Date getDate(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getDate(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Date getDate(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getDate(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDouble(int)\r
+        */\r
+       public double getDouble(int parameterIndex) throws SQLException {\r
+               return st.getDouble(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDouble(java.lang.String)\r
+        */\r
+       public double getDouble(String parameterName) throws SQLException {\r
+               return st.getDouble(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getFloat(int)\r
+        */\r
+       public float getFloat(int parameterIndex) throws SQLException {\r
+               return st.getFloat(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getFloat(java.lang.String)\r
+        */\r
+       public float getFloat(String parameterName) throws SQLException {\r
+               return st.getFloat(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getInt(int)\r
+        */\r
+       public int getInt(int parameterIndex) throws SQLException {\r
+               return st.getInt(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getInt(java.lang.String)\r
+        */\r
+       public int getInt(String parameterName) throws SQLException {\r
+               return st.getInt(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getLong(int)\r
+        */\r
+       public long getLong(int parameterIndex) throws SQLException {\r
+               return st.getLong(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getLong(java.lang.String)\r
+        */\r
+       public long getLong(String parameterName) throws SQLException {\r
+               return st.getLong(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(int)\r
+        */\r
+       public Object getObject(int parameterIndex) throws SQLException {\r
+               return st.getObject(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String)\r
+        */\r
+       public Object getObject(String parameterName) throws SQLException {\r
+               return st.getObject(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @param map\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(int, java.util.Map)\r
+        */\r
+       public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {\r
+               return st.getObject(i, map);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param map\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String, java.util.Map)\r
+        */\r
+       public Object getObject(String parameterName, Map<String, Class<?>> map) throws SQLException {\r
+               return st.getObject(parameterName, map);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRef(int)\r
+        */\r
+       public Ref getRef(int i) throws SQLException {\r
+               return st.getRef(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRef(java.lang.String)\r
+        */\r
+       public Ref getRef(String parameterName) throws SQLException {\r
+               return st.getRef(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getShort(int)\r
+        */\r
+       public short getShort(int parameterIndex) throws SQLException {\r
+               return st.getShort(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getShort(java.lang.String)\r
+        */\r
+       public short getShort(String parameterName) throws SQLException {\r
+               return st.getShort(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getString(int)\r
+        */\r
+       public String getString(int parameterIndex) throws SQLException {\r
+               return st.getString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getString(java.lang.String)\r
+        */\r
+       public String getString(String parameterName) throws SQLException {\r
+               return st.getString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(int)\r
+        */\r
+       public Time getTime(int parameterIndex) throws SQLException {\r
+               return st.getTime(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String)\r
+        */\r
+       public Time getTime(String parameterName) throws SQLException {\r
+               return st.getTime(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)\r
+        */\r
+       public Time getTime(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getTime(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Time getTime(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getTime(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(int)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex) throws SQLException {\r
+               return st.getTimestamp(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName) throws SQLException {\r
+               return st.getTimestamp(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getTimestamp(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getTimestamp(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getURL(int)\r
+        */\r
+       public URL getURL(int parameterIndex) throws SQLException {\r
+               return st.getURL(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getURL(java.lang.String)\r
+        */\r
+       public URL getURL(String parameterName) throws SQLException {\r
+               return st.getURL(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {\r
+               st.registerOutParameter(parameterIndex, sqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param sqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {\r
+               st.registerOutParameter(parameterIndex, sqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param paramIndex\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException {\r
+               st.registerOutParameter(paramIndex, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {\r
+               st.setDate(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {\r
+               st.setNull(parameterName, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param targetSqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {\r
+               st.setObject(parameterName, x, targetSqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param targetSqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {\r
+               st.setObject(parameterName, x, targetSqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {\r
+               st.setTime(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {\r
+               st.setTimestamp(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param val\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)\r
+        */\r
+       public void setURL(String parameterName, URL val) throws SQLException {\r
+               st.setURL(parameterName, val);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#wasNull()\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return st.wasNull();\r
+       }\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(int)\r
+        */\r
+       public Reader getCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getCharacterStream(String parameterName) throws SQLException {\r
+               return st.getCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(int)\r
+        */\r
+       public Reader getNCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getNCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getNCharacterStream(String parameterName) throws SQLException {\r
+               return st.getNCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(int)\r
+        */\r
+       public NClob getNClob(int parameterIndex) throws SQLException {\r
+               return st.getNClob(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(java.lang.String)\r
+        */\r
+       public NClob getNClob(String parameterName) throws SQLException {\r
+               return st.getNClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(int)\r
+        */\r
+       public String getNString(int parameterIndex) throws SQLException {\r
+               return st.getNString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(java.lang.String)\r
+        */\r
+       public String getNString(String parameterName) throws SQLException {\r
+               return st.getNString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(int)\r
+        */\r
+       public RowId getRowId(int parameterIndex) throws SQLException {\r
+               return st.getRowId(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(java.lang.String)\r
+        */\r
+       public RowId getRowId(String parameterName) throws SQLException {\r
+               return st.getRowId(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(int)\r
+        */\r
+       public SQLXML getSQLXML(int parameterIndex) throws SQLException {\r
+               return st.getSQLXML(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(java.lang.String)\r
+        */\r
+       public SQLXML getSQLXML(String parameterName) throws SQLException {\r
+               return st.getSQLXML(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream,\r
+                       long length) throws SQLException {\r
+               st.setBlob(parameterName, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterName, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.sql.Clob)\r
+        */\r
+       public void setClob(String parameterName, Clob x) throws SQLException {\r
+               st.setClob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterName, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.sql.NClob)\r
+        */\r
+       public void setNClob(String parameterName, NClob value) throws SQLException {\r
+               st.setNClob(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setNString(String parameterName, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setRowId(java.lang.String, java.sql.RowId)\r
+        */\r
+       public void setRowId(String parameterName, RowId x) throws SQLException {\r
+               st.setRowId(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setSQLXML(java.lang.String, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(String parameterName, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterName, xmlObject);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/bind/BindConnection.java b/src/com/lavans/luz2/sql/bind/BindConnection.java
new file mode 100644 (file)
index 0000000..001ded8
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Id: BindConnection.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/08/24\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+\r
+//import com.lavans.util.Logger;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public interface BindConnection extends Connection {\r
+       public BindPreparedStatement bindPrepareStatement(String sql) throws SQLException;\r
+       public BindCallableStatement bindPrepareCall(String sql) throws SQLException;\r
+}\r
diff --git a/src/com/lavans/luz2/sql/bind/BindConnectionImpl.java b/src/com/lavans/luz2/sql/bind/BindConnectionImpl.java
new file mode 100644 (file)
index 0000000..4795203
--- /dev/null
@@ -0,0 +1,694 @@
+/* $Id: BindConnectionImpl.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2005/01/27\r
+ * (c)2005 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Connection;\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.NClob;\r
+import java.sql.PreparedStatement;\r
+import java.sql.SQLClientInfoException;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.SQLXML;\r
+import java.sql.Savepoint;\r
+import java.sql.Statement;\r
+import java.sql.Struct;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+import java.util.StringTokenizer;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.logging.LoggingStatement;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class BindConnectionImpl implements BindConnection {\r
+       private static Log logger = LogFactory.getLog(BindConnectionImpl.class);\r
+\r
+       private static final String REMOVE_SINGLEQUOTE = "__remove_singlequote__";\r
+       /**\r
+        * Postgresで"::timestamp"等と指定した時用。\r
+        * :param::timestampとされた場合、バインド変数とくっついてしまわないように前後にスペースをいれる。\r
+        */\r
+       private static final String REMOVE_DOUBLECOLON = " __remove_doublecolon__ ";\r
+\r
+       /** 処理委譲先 */\r
+       private Connection con=null;\r
+       /**\r
+        * コンストラクタ。\r
+        */\r
+       public BindConnectionImpl(Connection con){\r
+               this.con = con;\r
+       }\r
+\r
+       /**\r
+        * SQL変換データ格納用\r
+        * @author Yuki\r
+        *\r
+        */\r
+       private class BindData{\r
+               /** 変換後のSQL */\r
+               String sql;\r
+               /**\r
+                * パラメータ名と「何番目のパラメータか」を保持するMap。 一つのパラメータ名で複数のパラメータを表す場合があるので、\r
+                * valueはIntegerのListとする。 配列が可変長なので、int[]型では配列数制御の実装をしなければならない。\r
+                */\r
+               Map<String, List<Integer>> paramMap = new HashMap<String, List<Integer>>();\r
+               /** シングルクオート待避用 */\r
+               List<String> squoteList = new ArrayList<String>();\r
+       }\r
+\r
+       protected BindData convertSql(String beforeSql){\r
+               // SQLの編集。編集結果はthis.sqlに入れるようにして\r
+               // 元のsqlは修正しない(ログ取得のため)。\r
+               BindData bindData = removeSQuote(beforeSql); // シングルクォーテーションを排除\r
+               logger.debug( "SQuote end." + bindData.sql);\r
+               // this.sql.replaceAll("\\:\\:",REMOVE_DOUBLECOLON); // ダブルコロン(::)を排除\r
+               bindData.sql = bindData.sql.replaceAll("::", REMOVE_DOUBLECOLON); // ダブルコロン(::)を排除\r
+               logger.debug( ":: end." + bindData.sql);\r
+               bindData = transBindName(bindData); // バインド変数名を?に変換。\r
+               logger.debug(bindData.sql);\r
+               bindData.sql = putSQuote(bindData); // シングルクォーテーションを元に戻す。\r
+               logger.debug( "PUT SQuote end." + bindData.sql);\r
+               bindData.sql = bindData.sql.replaceAll(REMOVE_DOUBLECOLON, "::"); // ダブルコロン(::)を戻す\r
+               logger.debug( "完了\n" + bindData.sql);\r
+\r
+               return bindData;\r
+       }\r
+       /**\r
+        * シングルクォーテーションで括られているものを待避させ、 "__bind_remove__"に置換する。\r
+        *\r
+        * @param sql\r
+        * @params List<String> squoteList シングルクォートで括られていた文字列を代入。output用。\r
+        *\r
+        * @return 変換後のsql\r
+        */\r
+       private BindData removeSQuote(String beforeSql) {\r
+               BindData bindData = new BindData();\r
+               StringBuffer buf = new StringBuffer(beforeSql.length());\r
+               int crnt = 0, from = 0, to = 0;\r
+               while (beforeSql.indexOf("'", crnt) != -1) {\r
+                       from = beforeSql.indexOf("'", crnt); // 最初の'\r
+                       to = beforeSql.indexOf("'", from + 1) + 1; // 終わりの'\r
+                       bindData.squoteList.add(beforeSql.substring(from, to));\r
+                       // logger.debug(sql.substring(from,to));\r
+                       buf.append(beforeSql.substring(crnt, from));\r
+                       buf.append(REMOVE_SINGLEQUOTE);\r
+                       // logger.debug(buf.toString());\r
+                       crnt = to;\r
+               }\r
+\r
+               buf.append(beforeSql.substring(crnt, beforeSql.length())); // 残りのsqlの最後までをbufに追加\r
+               // logger.debug(buf.toString());\r
+               bindData.sql = buf.toString();\r
+               return bindData;\r
+       }\r
+\r
+       /**\r
+        * バインド変数名を?に変換。どのバインド変数名が何番目の変数なのかを paramMapに保持する。\r
+        *\r
+        * @param sql\r
+        */\r
+       private BindData transBindName(BindData bindData) {\r
+               /**\r
+                * :paramを?に変換する。 SQLが"SELECT NAME FROM A WHERE ID=:id AND\r
+                * CLS=:cls"なら、以下のようになる。 1.最初のtoken.nextToken()で"SELECT NAME FROM A\r
+                * WHERE ID="まで取得。 2.次のtolen.nextToken()で"id AND CLS="を取得。\r
+                * 3.endToken.nextToken()で"id"が取得できるので、パラメータ文字列の長さは2である。\r
+                * 4.bufに"?"を足して、nextStrから頭2文字除いた物をbufに追加。\r
+                */\r
+               StringTokenizer token = new StringTokenizer(bindData.sql, ":");\r
+               int tokenCount = token.countTokens(); // 途中でデリミタを変更するので、ここでカウントしておく\r
+               StringBuffer buf = new StringBuffer(bindData.sql.length());\r
+               // :が含まれていなければなにもしない\r
+               if(!token.hasMoreTokens()){\r
+                       return bindData;\r
+               }\r
+               buf.append(token.nextToken()); // 最初の":"までを取得\r
+               for (int i = 1; i < tokenCount; i++) {\r
+                       // logger.debug("["+i+"]"+ buf.toString());\r
+                       String param = token.nextToken(")=, \t\r\n").substring(1);\r
+                       List<Integer> paramNums = bindData.paramMap.get(param); // パラメータ番号の取り出し\r
+                       if (paramNums == null) { // 存在しないなら(初出のparamなら)\r
+                               paramNums = new ArrayList<Integer>(2); // 格納用Listを作成\r
+                               bindData.paramMap.put(param, paramNums); // Mapに登録しておく。\r
+                       }\r
+                       paramNums.add(new Integer(i));\r
+\r
+                       String nextStr = "";\r
+                       try {\r
+                               nextStr = token.nextToken(":");\r
+                       } catch (Exception e) {\r
+                               // 文字列の最後まで来ているときはExceptionが発生するが無視してよい。\r
+                       }\r
+                       buf.append("?" + nextStr);\r
+               }\r
+               bindData.sql = buf.toString();\r
+\r
+               return bindData;\r
+       }\r
+\r
+       /**\r
+        * 待避したシングルクォーテーションを元に戻す。\r
+        *\r
+        * @param sql\r
+        */\r
+       private String putSQuote(BindData bindData) {\r
+               String sql = bindData.sql;\r
+               List<String> squoteList = bindData.squoteList;\r
+               StringBuffer buf = new StringBuffer(sql.length());\r
+               int crnt = 0, from = 0; // , to = 0;\r
+               for (int i = 0; i < squoteList.size(); i++) {\r
+                       from = sql.indexOf(REMOVE_SINGLEQUOTE, crnt); // REMOVE_SINGLEQUOTEの最初\r
+                       buf.append(sql.substring(crnt, from));\r
+                       logger.debug( sql.substring(crnt, from));\r
+                       buf.append(squoteList.get(i));\r
+                       crnt = from + REMOVE_SINGLEQUOTE.length();\r
+                       logger.debug( buf.toString());\r
+               }\r
+\r
+               buf.append(sql.substring(crnt, sql.length())); // 残りのsqlの最後までをbufに追加\r
+               logger.debug( buf.toString());\r
+               return buf.toString();\r
+       }\r
+\r
+\r
+\r
+       /**\r
+        * BindPreapaerdStatementを返す。\r
+        * このメソッドだけが独自の実装。これ以外は移譲先のConnectionに投げるだけ。\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String)\r
+        */\r
+       public BindPreparedStatement bindPrepareStatement(String sql) throws SQLException {\r
+               BindData bindData = convertSql(sql);\r
+               PreparedStatement st = con.prepareStatement(bindData.sql);\r
+               BindPreparedStatement bst = new BindPreparedStatementImpl(st, sql, bindData.paramMap);\r
+               return bst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String)\r
+        */\r
+       public BindCallableStatement bindPrepareCall(String sql) throws SQLException {\r
+               BindData bindData = convertSql(sql);\r
+               CallableStatement st = con.prepareCall(sql);\r
+               BindCallableStatement bst = new BindCallableStatementImpl(st, sql, bindData.paramMap);\r
+               return bst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int)\r
+        */\r
+       public BindCallableStatement bindPrepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+\r
+               BindData bindData = convertSql(sql);\r
+               CallableStatement st = con.prepareCall(sql,resultSetType,resultSetConcurrency);\r
+               BindCallableStatement bst = new BindCallableStatementImpl(st, sql, bindData.paramMap);\r
+               return bst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)\r
+        */\r
+       public BindCallableStatement bindPrepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+\r
+               BindData bindData = convertSql(sql);\r
+               CallableStatement st = con.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);\r
+               BindCallableStatement bst = new BindCallableStatementImpl(st, sql, bindData.paramMap);\r
+               return bst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement()\r
+        */\r
+       public Statement createStatement() throws SQLException {\r
+               LoggingStatement st = new LoggingStatement(con.createStatement());\r
+               return st;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement(int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               LoggingStatement st = new LoggingStatement(con.createStatement(resultSetType, resultSetConcurrency));\r
+               return st;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement(int, int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               LoggingStatement st = new LoggingStatement(con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));\r
+               return st;\r
+       }\r
+\r
+//     /**\r
+//      * @see java.sql.Connection#createStatement()\r
+//      */\r
+//     public Statement createStatement() throws SQLException {\r
+//             return con.createStatement();\r
+//     }\r
+//\r
+//     /**\r
+//      * @see java.sql.Connection#createStatement(int, int)\r
+//      */\r
+//     public Statement createStatement(\r
+//             int resultSetType,\r
+//             int resultSetConcurrency)\r
+//             throws SQLException {\r
+//             return con.createStatement(resultSetType, resultSetConcurrency);\r
+//     }\r
+//\r
+//     /**\r
+//      * @see java.sql.Connection#createStatement(int, int, int)\r
+//      */\r
+//     public Statement createStatement(\r
+//             int resultSetType,\r
+//             int resultSetConcurrency,\r
+//             int resultSetHoldability)\r
+//             throws SQLException {\r
+//             return con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);\r
+//     }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String)\r
+        */\r
+       public CallableStatement prepareCall(String sql) throws SQLException {\r
+               return con.prepareCall(sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               return con.prepareCall(sql,resultSetType,resultSetConcurrency);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               return con.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String)\r
+        */\r
+       public PreparedStatement prepareStatement(String sql) throws SQLException {\r
+               return con.prepareStatement(sql);\r
+       }\r
+\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int autoGeneratedKeys)\r
+               throws SQLException {\r
+               return con.prepareStatement(sql,autoGeneratedKeys);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               return con.prepareStatement(sql,resultSetType, resultSetConcurrency);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               return con.prepareStatement(sql,resultSetType, resultSetConcurrency, resultSetHoldability);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               return con.prepareStatement(sql,columnIndexes);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               return con.prepareStatement(sql,columnNames);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getHoldability()\r
+        */\r
+       public int getHoldability() throws SQLException {\r
+               return con.getHoldability();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTransactionIsolation()\r
+        */\r
+       public int getTransactionIsolation() throws SQLException {\r
+               return con.getTransactionIsolation();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               con.clearWarnings();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               con.close();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#commit()\r
+        */\r
+       public void commit() throws SQLException {\r
+               con.commit();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#rollback()\r
+        */\r
+       public void rollback() throws SQLException {\r
+               con.rollback();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getAutoCommit()\r
+        */\r
+       public boolean getAutoCommit() throws SQLException {\r
+               return con.getAutoCommit();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return con.isClosed();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isReadOnly()\r
+        */\r
+       public boolean isReadOnly() throws SQLException {\r
+               return con.isReadOnly();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setHoldability(int)\r
+        */\r
+       public void setHoldability(int holdability) throws SQLException {\r
+               con.setHoldability(holdability);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTransactionIsolation(int)\r
+        */\r
+       public void setTransactionIsolation(int level) throws SQLException {\r
+               con.setTransactionIsolation(level);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setAutoCommit(boolean)\r
+        */\r
+       public void setAutoCommit(boolean autoCommit) throws SQLException {\r
+               con.setAutoCommit(autoCommit);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setReadOnly(boolean)\r
+        */\r
+       public void setReadOnly(boolean readOnly) throws SQLException {\r
+               con.setReadOnly(readOnly);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getCatalog()\r
+        */\r
+       public String getCatalog() throws SQLException {\r
+               return con.getCatalog();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setCatalog(java.lang.String)\r
+        */\r
+       public void setCatalog(String catalog) throws SQLException {\r
+               con.setCatalog(catalog);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getMetaData()\r
+        */\r
+       public DatabaseMetaData getMetaData() throws SQLException {\r
+               return con.getMetaData();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return con.getWarnings();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setSavepoint()\r
+        */\r
+       public Savepoint setSavepoint() throws SQLException {\r
+               return con.setSavepoint();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)\r
+        */\r
+       public void releaseSavepoint(Savepoint savepoint) throws SQLException {\r
+               con.releaseSavepoint(savepoint);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#rollback(java.sql.Savepoint)\r
+        */\r
+       public void rollback(Savepoint savepoint) throws SQLException {\r
+               con.rollback(savepoint);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTypeMap()\r
+        */\r
+       public Map<String,Class<?>> getTypeMap() throws SQLException {\r
+               return con.getTypeMap();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTypeMap(java.util.Map)\r
+        */\r
+       public void setTypeMap(Map<String,Class<?>> map) throws SQLException {\r
+               con.setTypeMap(map);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#nativeSQL(java.lang.String)\r
+        */\r
+       public String nativeSQL(String sql) throws SQLException {\r
+               return con.nativeSQL(sql);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setSavepoint(java.lang.String)\r
+        */\r
+       public Savepoint setSavepoint(String name) throws SQLException {\r
+               return con.setSavepoint(name);\r
+       }\r
+       /**\r
+        * @param typeName\r
+        * @param elements\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createArrayOf(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Array createArrayOf(String typeName, Object[] elements)\r
+                       throws SQLException {\r
+               return con.createArrayOf(typeName, elements);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createBlob()\r
+        */\r
+       public Blob createBlob() throws SQLException {\r
+               return con.createBlob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createClob()\r
+        */\r
+       public Clob createClob() throws SQLException {\r
+               return con.createClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createNClob()\r
+        */\r
+       public NClob createNClob() throws SQLException {\r
+               return con.createNClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createSQLXML()\r
+        */\r
+       public SQLXML createSQLXML() throws SQLException {\r
+               return con.createSQLXML();\r
+       }\r
+\r
+       /**\r
+        * @param typeName\r
+        * @param attributes\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createStruct(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Struct createStruct(String typeName, Object[] attributes)\r
+                       throws SQLException {\r
+               return con.createStruct(typeName, attributes);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo()\r
+        */\r
+       public Properties getClientInfo() throws SQLException {\r
+               return con.getClientInfo();\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo(java.lang.String)\r
+        */\r
+       public String getClientInfo(String name) throws SQLException {\r
+               return con.getClientInfo(name);\r
+       }\r
+\r
+       /**\r
+        * @param timeout\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#isValid(int)\r
+        */\r
+       public boolean isValid(int timeout) throws SQLException {\r
+               return con.isValid(timeout);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return con.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param properties\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.util.Properties)\r
+        */\r
+       public void setClientInfo(Properties properties)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(properties);\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @param value\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.lang.String, java.lang.String)\r
+        */\r
+       public void setClientInfo(String name, String value)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(name, value);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/sql/bind/BindPreparedStatement.java b/src/com/lavans/luz2/sql/bind/BindPreparedStatement.java
new file mode 100644 (file)
index 0000000..abce6db
--- /dev/null
@@ -0,0 +1,152 @@
+/* $Id: BindPreparedStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/08/24\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.math.BigDecimal;\r
+import java.sql.Blob;\r
+import java.sql.Date;\r
+import java.sql.PreparedStatement;\r
+import java.sql.SQLException;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public interface BindPreparedStatement extends PreparedStatement {\r
+       /**\r
+        * 複数パラメータ一括設定。\r
+        * @throws SQLException\r
+        */\r
+       void setParams(Map<String, Object> params) throws SQLException;\r
+       /**\r
+        * パラメータ名での設定(String)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setString(String key, String x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(int)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setInt(String key, int x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(byte)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setByte(String key, byte x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(float)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setFloat(String key, float x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(double)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setDouble(String key, double x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(null)。\r
+        * @param key\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        */\r
+       void setNull(String key, int sqlType) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(long)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setLong(String key, long x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(short)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setShort(String key, short x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(boolean)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setBoolean(String key, boolean x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(byte[])。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setBytes(String key, byte[] x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Date)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setDate(String key, Date x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Time)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setTime(String key, Time x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Timestamp)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       void setTimestamp(String key, Timestamp x) throws SQLException;\r
+\r
+       /**\r
+        * パラメータ名での設定(java.math.BigDecimal)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBigDecimal(String key, BigDecimal x) throws SQLException;\r
+       \r
+       /**\r
+        * パラメータ名での設定(java.sql.Blob)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBlob(String key, Blob x) throws SQLException;\r
+       /**\r
+        * パラメータ名での設定(java.lang.Object)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setObject(String key, Object x) throws SQLException;\r
+}\r
diff --git a/src/com/lavans/luz2/sql/bind/BindPreparedStatementImpl.java b/src/com/lavans/luz2/sql/bind/BindPreparedStatementImpl.java
new file mode 100644 (file)
index 0000000..2b85466
--- /dev/null
@@ -0,0 +1,1090 @@
+/* $Id: BindPreparedStatementImpl.java 413 2011-07-28 23:05:11Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.bind;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.ParameterMetaData;\r
+import java.sql.PreparedStatement;\r
+import java.sql.Ref;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.sql.logging.Loggable;\r
+import com.lavans.luz2.sql.logging.LoggingStatement;\r
+import com.lavans.luz2.util.MethodUtil;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class BindPreparedStatementImpl extends LoggingStatement implements BindPreparedStatement {\r
+       private static Log logger = LogFactory.getLog(BindPreparedStatementImpl.class);\r
+       /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */\r
+       private static final String CLASSNAME=BindPreparedStatementImpl.class.getName();\r
+       /** 処理移譲先。 */\r
+       private PreparedStatement st = null;\r
+\r
+       /**\r
+        * パラメータ名と「何番目のパラメータか」を保持するMap。 一つのパラメータ名で複数のパラメータを表す場合があるので、\r
+        * valueはIntegerのListとする。 配列が可変長なので、int[]型では配列数制御の実装をしなければならない。\r
+        */\r
+       private Map<String, List<Integer>> paramMap = null;\r
+\r
+       /** ログ出力用のsql */\r
+       private String sql;\r
+\r
+       /**\r
+        * ログ用にバインドキー文字列(:member_id)を実際の値に変換する。\r
+        *\r
+        * @param sql\r
+        */\r
+       private void logParam(String key, String value){\r
+               // 値に正規表現があったらエスケープ\r
+               value = value.replace("$", "\\$");\r
+\r
+               // ログの書き換え\r
+               sql = sql.replaceAll(key+" ",  value+" ");\r
+               sql = sql.replaceAll(key+",",  value+",");\r
+               sql = sql.replaceAll(key+"\t", value+"\t");\r
+               sql = sql.replaceAll(key+"\n", value+"\n");\r
+               sql = sql.replaceAll(key+"\r", value+"\r");\r
+               sql = sql.replaceAll(key+"\\)",  value+"\\)");\r
+               sql = sql.replaceAll(key+"$",  value+"");\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        *\r
+        * @param st\r
+        */\r
+       public BindPreparedStatementImpl(PreparedStatement st, String sql, Map<String, List<Integer>> paramMap) {\r
+               super(st);\r
+               this.st = st;\r
+               this.sql = sql;\r
+               this.paramMap = paramMap;\r
+\r
+               // 移譲先もLoggableな場合は移譲先にもlog用sqlを渡す。\r
+               if (st instanceof Loggable) {\r
+                       ((Loggable) st).setLogsql(sql);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * 複数パラメータ一括設定。\r
+        * LIMIT OFFSETに対するセットを実装するときにはsetIntにする必要あり(Postgres)。\r
+        * ソート順は顧客に入力させずにコンボで選ばせるようにすればよい。\r
+        * @throws SQLException\r
+        */\r
+       public void setParams(Map<String, Object> params) throws SQLException{\r
+               if(params==null) return;\r
+\r
+               List<String> list = new ArrayList<String>(params.keySet());\r
+               for(int i=0; i < list.size(); i++){\r
+                       String key = list.get(i);\r
+                       Object value = params.get(key);\r
+                       if(value instanceof String){\r
+                               setString(key, (String)value);\r
+                       }else if(value instanceof Integer){\r
+                               setInt(key, ((Integer)value).intValue());\r
+                       }else if(value instanceof Long){\r
+                               setLong(key, (Long)value);\r
+                       }else if(value instanceof java.util.Date){\r
+                               setTimestamp(key,new Timestamp(((java.util.Date)value).getTime()));\r
+                       }else if(value instanceof Boolean){\r
+                               setBoolean(key, (Boolean)value);\r
+                       }else if(value instanceof byte[]){\r
+                               // setObjectまかせでいいかもしれない\r
+                               setBytes(key, (byte[])value);\r
+                       }else{\r
+                               setObject(key, value);\r
+                               if(value==null){\r
+                                       logger.debug("bind as object["+ key +":NULL]");\r
+                               }else{\r
+                                       logger.debug("bind as object["+ key +":"+ value.getClass().getName() +"]");\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(String)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setString(String key, String x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setString(num.intValue(), x);\r
+                       logger.debug( "[" + num + "]:" + key + "[" + x + "]");\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       logParam(":"+key, "'"+x+"'");\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(int)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setInt(String key, int x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setInt(num.intValue(), x);\r
+                       logger.debug( "[" + num + "]:" + key + "[" + x + "]");\r
+               }\r
+\r
+               // ログ\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(byte)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setByte(String key, byte x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setByte(num.intValue(), x);\r
+               }\r
+               // ログ\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(float)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setFloat(String key, float x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setFloat(num.intValue(), x);\r
+               }\r
+               // ログ\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(double)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setDouble(String key, double x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setDouble(num.intValue(), x);\r
+               }\r
+               // ログ\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(null)。\r
+        *\r
+        * @param key\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        */\r
+       public void setNull(String key, int sqlType) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setNull(num.intValue(), sqlType);\r
+               }\r
+               // ログ\r
+               logParam(":"+key, "NULL");\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(long)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setLong(String key, long x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setLong(num.intValue(), x);\r
+               }\r
+               // ログ\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(short)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setShort(String key, short x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setShort(num.intValue(), x);\r
+               }\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(boolean)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBoolean(String key, boolean x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setBoolean(num.intValue(), x);\r
+               }\r
+               logParam(":"+key, String.valueOf(x));\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(byte[])。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBytes(String key, byte[] x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setBytes(num.intValue(), x);\r
+               }\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else if(x.length<=10){\r
+                       // 先頭の10バイトだけ\r
+                       logParam(":"+key, "'"+StringUtils.toHex(x, ":")+"'");\r
+               }else{\r
+                       byte[] x2 = new byte[10];\r
+                       System.arraycopy(x, 0, x2, 0, 10);\r
+                       logParam(":"+key, "'"+StringUtils.toHex(x2, ":")+"...'");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Date)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setDate(String key, Date x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setDate(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");\r
+                       logParam(":"+key, "'"+sdf.format(x)+"'");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Time)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setTime(String key, Time x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setTime(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");\r
+                       logParam(":"+key, "'"+sdf.format(x)+"'");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Timestamp)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setTimestamp(String key, Timestamp x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setTimestamp(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");\r
+                       logParam(":"+key, "'"+sdf.format(x)+"'");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.math.BigDecimal)。\r
+        *\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBigDecimal(String key, BigDecimal x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setBigDecimal(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       logParam(":"+key, x.toString());\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Blob)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBlob(String key, Blob x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setBlob(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       logParam(":"+key, "'"+x+"'");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.lang.Object)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setObject(String key, Object x) throws SQLException {\r
+               List<Integer> paramNums = paramMap.get(key);\r
+               if (paramNums == null) {\r
+                       throw new SQLException("No such key [" + key + "]");\r
+               }\r
+               for (int i = 0; i < paramNums.size(); i++) {\r
+                       Integer num = paramNums.get(i);\r
+                       st.setObject(num.intValue(), x);\r
+               }\r
+\r
+               // ログ\r
+               if(x==null){\r
+                       logParam(":"+key, "NULL");\r
+               }else{\r
+                       logParam(":"+key, "'"+x+"'");\r
+               }\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#executeQuery()\r
+        */\r
+       public ResultSet executeQuery() throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               ResultSet result = st.executeQuery();\r
+               return result;\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#executeUpdate()\r
+        */\r
+       public int executeUpdate() throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               int result = st.executeUpdate();\r
+               return result;\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#execute()\r
+        */\r
+       public boolean execute() throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               boolean result = st.execute();\r
+               return result;\r
+       }\r
+\r
+       /*\r
+        * ------------------------------------------------------ PreaparedStatement\r
+        * ------------------------------------------------------\r
+        */\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#addBatch()\r
+        */\r
+       public void addBatch() throws SQLException {\r
+               st.addBatch();\r
+\r
+       }\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#clearParameters()\r
+        */\r
+       public void clearParameters() throws SQLException {\r
+               st.clearParameters();\r
+\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setByte(int, byte)\r
+        */\r
+       public void setByte(int parameterIndex, byte x) throws SQLException {\r
+               st.setByte(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setDouble(int, double)\r
+        */\r
+       public void setDouble(int parameterIndex, double x) throws SQLException {\r
+               st.setDouble(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setFloat(int, float)\r
+        */\r
+       public void setFloat(int parameterIndex, float x) throws SQLException {\r
+               st.setFloat(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setInt(int, int)\r
+        */\r
+       public void setInt(int parameterIndex, int x) throws SQLException {\r
+               st.setInt(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setNull(int, int)\r
+        */\r
+       public void setNull(int parameterIndex, int sqlType) throws SQLException {\r
+               st.setNull(parameterIndex, sqlType);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setLong(int, long)\r
+        */\r
+       public void setLong(int parameterIndex, long x) throws SQLException {\r
+               st.setLong(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setShort(int, short)\r
+        */\r
+       public void setShort(int parameterIndex, short x) throws SQLException {\r
+               st.setShort(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setBoolean(int, boolean)\r
+        */\r
+       public void setBoolean(int parameterIndex, boolean x) throws SQLException {\r
+               st.setBoolean(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setBytes(int, byte[])\r
+        */\r
+       public void setBytes(int parameterIndex, byte[] x) throws SQLException {\r
+               st.setBytes(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream,\r
+        *      int)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, int length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream,\r
+        *      int)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, int length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#setUnicodeStream(int,\r
+        *      java.io.InputStream, int)\r
+        * @deprecated\r
+        */\r
+       public void setUnicodeStream(int parameterIndex, InputStream x, int length)\r
+                       throws SQLException {\r
+               st.setUnicodeStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader,\r
+        *      int)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader, int length)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader, length);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)\r
+        */\r
+       public void setObject(int parameterIndex, Object x) throws SQLException {\r
+               st.setObject(parameterIndex, x);\r
+\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)\r
+        */\r
+       public void setObject(int parameterIndex, Object x, int targetSqlType)\r
+                       throws SQLException {\r
+               st.setObject(parameterIndex, x, targetSqlType);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int,\r
+        *      int)\r
+        */\r
+       public void setObject(int parameterIndex, Object x, int targetSqlType,\r
+                       int scale) throws SQLException {\r
+               st.setObject(parameterIndex, x, targetSqlType, scale);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)\r
+        */\r
+       public void setNull(int paramIndex, int sqlType, String typeName)\r
+                       throws SQLException {\r
+               st.setNull(paramIndex, sqlType, typeName);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setString(int, java.lang.String)\r
+        */\r
+       public void setString(int parameterIndex, String x) throws SQLException {\r
+               st.setString(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)\r
+        */\r
+       public void setBigDecimal(int parameterIndex, BigDecimal x)\r
+                       throws SQLException {\r
+               st.setBigDecimal(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setURL(int, java.net.URL)\r
+        */\r
+       public void setURL(int parameterIndex, URL x) throws SQLException {\r
+               st.setURL(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)\r
+        */\r
+       public void setArray(int i, Array x) throws SQLException {\r
+               st.setArray(i, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)\r
+        */\r
+       public void setBlob(int i, Blob x) throws SQLException {\r
+               st.setBlob(i, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)\r
+        */\r
+       public void setClob(int i, Clob x) throws SQLException {\r
+               st.setClob(i, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)\r
+        */\r
+       public void setDate(int parameterIndex, Date x) throws SQLException {\r
+               st.setDate(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#getParameterMetaData()\r
+        */\r
+       public ParameterMetaData getParameterMetaData() throws SQLException {\r
+               return st.getParameterMetaData();\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)\r
+        */\r
+       public void setRef(int i, Ref x) throws SQLException {\r
+               st.setRef(i, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#getMetaData()\r
+        */\r
+       public ResultSetMetaData getMetaData() throws SQLException {\r
+               return st.getMetaData();\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)\r
+        */\r
+       public void setTime(int parameterIndex, Time x) throws SQLException {\r
+               st.setTime(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x)\r
+                       throws SQLException {\r
+               st.setTimestamp(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date,\r
+        *      java.util.Calendar)\r
+        */\r
+       public void setDate(int parameterIndex, Date x, Calendar cal)\r
+                       throws SQLException {\r
+               st.setDate(parameterIndex, x);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time,\r
+        *      java.util.Calendar)\r
+        */\r
+       public void setTime(int parameterIndex, Time x, Calendar cal)\r
+                       throws SQLException {\r
+               st.setTime(parameterIndex, x, cal);\r
+       }\r
+\r
+       /*\r
+        * (非 Javadoc)\r
+        *\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp,\r
+        *      java.util.Calendar)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)\r
+                       throws SQLException {\r
+               st.setTimestamp(parameterIndex, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream, long length)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)\r
+        */\r
+       public void setNClob(int parameterIndex, NClob value) throws SQLException {\r
+               st.setNClob(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setNClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNString(int, java.lang.String)\r
+        */\r
+       public void setNString(int parameterIndex, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId)\r
+        */\r
+       public void setRowId(int parameterIndex, RowId x) throws SQLException {\r
+               st.setRowId(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(int parameterIndex, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterIndex, xmlObject);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/src/com/lavans/luz2/sql/cluster/CalledMethod.java b/src/com/lavans/luz2/sql/cluster/CalledMethod.java
new file mode 100644 (file)
index 0000000..748c5c6
--- /dev/null
@@ -0,0 +1,131 @@
+/* $Id: CalledMethod.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/28\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+class CalledMethod {\r
+       private String methodName = null;\r
+       private Object[] args = null;\r
+       private Class<?>[] parameterTypes = null;\r
+       private int[] objectTypes = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @deprecated\r
+        * @param methodName\r
+        * @param args\r
+        */\r
+//     public CalledMethod(String methodName, Object[] args){\r
+//             this.methodName = methodName;\r
+//             this.args = args;\r
+//     }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * parameterType指定有り。\r
+        * @param methodName\r
+        * @param args\r
+        * @param parameterTypes\r
+        */\r
+       public CalledMethod(String methodName, Object[] args, Class<?>[] parameterTypes){\r
+               this.methodName = methodName;\r
+               this.args = args;\r
+               this.parameterTypes = parameterTypes;\r
+       }\r
+\r
+       /**\r
+        * クラスタリングメソッド呼出処理。\r
+        * @param target\r
+        * @return\r
+        * @throws NoSuchMethodException\r
+        * @throws InvocationTargetException\r
+        * @throws IllegalAccessException\r
+        */\r
+       public Object invoke(Object target)\r
+               throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {\r
+               // すべてのclusterCall呼出にClass<?>[]を指定するまでの暫定処理\r
+               if(parameterTypes==null){\r
+                       parameterTypes = getParameterTypes();\r
+               }\r
+\r
+               Method method = target.getClass().getMethod(methodName,parameterTypes);\r
+               if(!method.isAccessible()){\r
+                       method.setAccessible(true);\r
+               }\r
+\r
+               return method.invoke(target,args);\r
+\r
+       }\r
+\r
+       /**\r
+        * class型設定。\r
+        * @return\r
+        */\r
+       private Class<?>[] getParameterTypes(){\r
+               // getMethodに必要な引数の型の取り出し。\r
+               Class<?>[] parameterTypes = null;\r
+               if(args!=null){                                                         // 引数がnull(引数無し)じゃなければ\r
+                       parameterTypes = new Class[args.length];        // 引数の型を用意する。\r
+                       for(int i=0; i<args.length; i++){\r
+                               // プリミティブ型の場合はラッパークラスで入っているので\r
+                               // プリミティブ型のClassインスタンスを取り出す。\r
+                               // 8typeについてそれぞれinstanceofで比較した方が速いか?要実験。\r
+                               try{\r
+                                       if(contains(objectTypes, i)){\r
+                                               parameterTypes[i] = Object.class;\r
+                                       }else{\r
+                                               parameterTypes[i] = (Class<?>)args[i].getClass().getField("TYPE").get(null);\r
+                                       }\r
+                               }catch (Exception e) {\r
+                                       //NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException\r
+                                       parameterTypes[i] = args[i].getClass();\r
+                               }\r
+                       }\r
+               }\r
+\r
+               return parameterTypes;\r
+       }\r
+\r
+       @Override\r
+       public String toString(){\r
+               String argStr = "";\r
+               if(args!=null){\r
+                       for(int i=0; i<args.length; i++){\r
+                               if(args[i]==null){\r
+                                       argStr += ",null";\r
+                               }else{\r
+                                       argStr += ","+ args[i].toString();\r
+                               }\r
+                       }\r
+                       if(argStr.length()>1){\r
+                               argStr = argStr.substring(1);\r
+                       }\r
+               }\r
+               return methodName +"("+ argStr +")";\r
+       }\r
+\r
+       /**\r
+        * intの配列の中にvalueがあるかどうか判定する。\r
+        * @param array\r
+        * @param value\r
+        * @return\r
+        */\r
+       private boolean contains(int[] array, int value){\r
+               if(array==null) return false;\r
+\r
+               for(int i=0; i<array.length; i++){\r
+                       if(array[i]==value){\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterCallableStatement.java b/src/com/lavans/luz2/sql/cluster/ClusterCallableStatement.java
new file mode 100644 (file)
index 0000000..39f65a3
--- /dev/null
@@ -0,0 +1,1095 @@
+/* $Id: ClusterCallableStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/25\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Statement;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterCallableStatement\r
+       extends ClusterPreparedStatement\r
+       implements CallableStatement {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterCallableStatement.class);\r
+\r
+       /** 処理移譲先。 */\r
+       private CallableStatement st=null;\r
+\r
+       /** コネクション。障害時に別のStaementを作るよう依頼する。 */\r
+       private ClusterConnection con = null;\r
+\r
+       /**\r
+        * 保存しておくメソッドのリスト。\r
+        * 障害が発生した場合、ClusterPreparedStatementに対する操作を操作が行われた\r
+        * 順序どおりに再実行する必要がある。\r
+        */\r
+       private List<CalledMethod> methodList = null;\r
+\r
+       /**\r
+        * @param con\r
+        * @param st\r
+        */\r
+       public ClusterCallableStatement(ClusterConnection con, CallableStatement st) {\r
+               super(con, st);\r
+               this.con = con;\r
+               this.st = st;\r
+               methodList = new ArrayList<CalledMethod>();\r
+       }\r
+\r
+       /**\r
+        * DB切替時、新たに取得したStatementに対して\r
+        * 更新処理を再実行する。\r
+        * @param\r
+        */\r
+       @Override\r
+       public void reupdateStatement(Statement st) throws SQLException{\r
+               try { this.st.close(); } catch (SQLException se) {}\r
+               this.st = (CallableStatement)st;\r
+\r
+               super.reupdateStatement(st);    // ベースクラスでも再実行\r
+               for(int i=0; i<methodList.size(); i++){\r
+                       CalledMethod calledMethod = methodList.get(i);\r
+                       try{\r
+                               logger.debug(calledMethod.toString());\r
+                               calledMethod.invoke(st);        // 戻り値は無視して良い\r
+                       }catch (Exception e) {\r
+                               logger.error(MSG_ERR_REUPDATE, e);\r
+                               throw new SQLException(MSG_ERR_REUPDATE);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        *\r
+        * @param methodName\r
+        * @param args\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(String methodName, Object[] args, Class<?>[] parameterTypes, boolean saveMethod) throws SQLException{\r
+\r
+               Object result = null;\r
+               CalledMethod calledMethod = new CalledMethod(methodName, args, parameterTypes);\r
+               logger.debug(calledMethod.toString());\r
+\r
+               try{\r
+                       result = calledMethod.invoke(st);\r
+               }catch (Exception e) {\r
+                       logger.warn(MSG_WARN_SWITCH_DB, e);\r
+//                     try { st.close(); } catch (SQLException se) {}\r
+                       con.notifyError(this);\r
+                       try{\r
+                               result = calledMethod.invoke(st);\r
+                       }catch (Exception e2) {\r
+                               // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。\r
+                               throw new SQLException(e2.getMessage());\r
+                       }\r
+               }\r
+               if(saveMethod){\r
+                       methodList.add(calledMethod);\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#wasNull()\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return ((Boolean)clusterCall("wasNull", null, null, false)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getByte(int)\r
+        */\r
+       public byte getByte(int parameterIndex) throws SQLException {\r
+               return ((Byte)clusterCall("getByte", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).byteValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDouble(int)\r
+        */\r
+       public double getDouble(int parameterIndex) throws SQLException {\r
+               return ((Double)clusterCall("getDouble", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).doubleValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getFloat(int)\r
+        */\r
+       public float getFloat(int parameterIndex) throws SQLException {\r
+               return ((Float)clusterCall("getFloat", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).floatValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getInt(int)\r
+        */\r
+       public int getInt(int parameterIndex) throws SQLException {\r
+               return ((Integer)clusterCall("getInt", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).intValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getLong(int)\r
+        */\r
+       public long getLong(int parameterIndex) throws SQLException {\r
+               return ((Long)clusterCall("getLong", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).longValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getShort(int)\r
+        */\r
+       public short getShort(int parameterIndex) throws SQLException {\r
+               return ((Short)clusterCall("getShort", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).shortValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBoolean(int)\r
+        */\r
+       public boolean getBoolean(int parameterIndex) throws SQLException {\r
+               return ((Boolean)clusterCall("getBoolean", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBytes(int)\r
+        */\r
+       public byte[] getBytes(int parameterIndex) throws SQLException {\r
+               return (byte[])clusterCall("getBytes", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType)\r
+               throws SQLException {\r
+               clusterCall("registerOutParameter", new Object[]{new Integer(parameterIndex), new Integer(sqlType)},\r
+                               new Class<?>[]{Integer.TYPE, Integer.TYPE}, true);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, int)\r
+        */\r
+       public void registerOutParameter(\r
+               int parameterIndex,\r
+               int sqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       new Integer(parameterIndex),\r
+                       new Integer(sqlType),\r
+                       new Integer(scale)\r
+               };\r
+\r
+               Class<?>[] types = {\r
+                       Integer.TYPE,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+\r
+               clusterCall("registerOutParameter", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(int)\r
+        */\r
+       public Object getObject(int parameterIndex) throws SQLException {\r
+               return clusterCall("getObject", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getString(int)\r
+        */\r
+       public String getString(int parameterIndex) throws SQLException {\r
+               return (String)clusterCall("getString", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(\r
+               int paramIndex,\r
+               int sqlType,\r
+               String typeName)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       new Integer(paramIndex),\r
+                       new Integer(sqlType),\r
+                       typeName\r
+               };\r
+               Class<?>[] types = {\r
+                       Integer.TYPE,\r
+                       Integer.TYPE,\r
+                       String.class\r
+               };\r
+\r
+               clusterCall("registerOutParameter", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getByte(java.lang.String)\r
+        */\r
+       public byte getByte(String parameterName) throws SQLException {\r
+               return ((Byte)clusterCall("getByte", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).byteValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDouble(java.lang.String)\r
+        */\r
+       public double getDouble(String parameterName) throws SQLException {\r
+               return ((Double)clusterCall("getDouble", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).doubleValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getFloat(java.lang.String)\r
+        */\r
+       public float getFloat(String parameterName) throws SQLException {\r
+               return ((Float)clusterCall("getFloat", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).floatValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getInt(java.lang.String)\r
+        */\r
+       public int getInt(String parameterName) throws SQLException {\r
+               return ((Integer)clusterCall("getInt", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).intValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getLong(java.lang.String)\r
+        */\r
+       public long getLong(String parameterName) throws SQLException {\r
+               return ((Long)clusterCall("getLong", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).longValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getShort(java.lang.String)\r
+        */\r
+       public short getShort(String parameterName) throws SQLException {\r
+               return ((Short)clusterCall("getShort", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).shortValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBoolean(java.lang.String)\r
+        */\r
+       public boolean getBoolean(String parameterName) throws SQLException {\r
+               return ((Boolean)clusterCall("getBoolean", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBytes(java.lang.String)\r
+        */\r
+       public byte[] getBytes(String parameterName) throws SQLException {\r
+               return (byte[])clusterCall("getBytes", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setByte(java.lang.String, byte)\r
+        */\r
+       public void setByte(String parameterName, byte x) throws SQLException {\r
+               clusterCall("setByte", new Object[]{parameterName, new Byte(x)},\r
+                               new Class<?>[]{String.class, Byte.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDouble(java.lang.String, double)\r
+        */\r
+       public void setDouble(String parameterName, double x) throws SQLException {\r
+               clusterCall("setDouble", new Object[]{parameterName, new Double(x)},\r
+                               new Class<?>[]{String.class, Double.TYPE}, true);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setFloat(java.lang.String, float)\r
+        */\r
+       public void setFloat(String parameterName, float x) throws SQLException {\r
+               clusterCall("setFloat", new Object[]{parameterName, new Float(x)},\r
+                               new Class<?>[]{String.class, Float.TYPE}, true);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType)\r
+               throws SQLException {\r
+               clusterCall("registerOutParameter", new Object[]{parameterName, new Integer(sqlType)},\r
+                               new Class<?>[]{String.class, Integer.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setInt(java.lang.String, int)\r
+        */\r
+       public void setInt(String parameterName, int x) throws SQLException {\r
+               clusterCall("setInt", new Object[]{parameterName, new Integer(x)},\r
+                               new Class<?>[]{String.class, Integer.TYPE}, true);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int)\r
+        */\r
+       public void setNull(String parameterName, int sqlType)\r
+               throws SQLException {\r
+               clusterCall("setNull", new Object[]{parameterName, new Integer(sqlType)},\r
+                               new Class<?>[]{String.class, Integer.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, int)\r
+        */\r
+       public void registerOutParameter(\r
+               String parameterName,\r
+               int sqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       new Integer(sqlType),\r
+                       new Integer(scale)\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               clusterCall("registerOutParameter", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setLong(java.lang.String, long)\r
+        */\r
+       public void setLong(String parameterName, long x) throws SQLException {\r
+               clusterCall("setLong", new Object[]{parameterName, new Long(x)},\r
+                               new Class<?>[]{String.class, Long.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setShort(java.lang.String, short)\r
+        */\r
+       public void setShort(String parameterName, short x) throws SQLException {\r
+               clusterCall("setShort", new Object[]{parameterName, new Short(x)},\r
+                               new Class<?>[]{String.class, Short.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBoolean(java.lang.String, boolean)\r
+        */\r
+       public void setBoolean(String parameterName, boolean x)\r
+               throws SQLException {\r
+               clusterCall("setBoolean", new Object[]{parameterName, new Boolean(x)},\r
+                               new Class<?>[]{String.class, Boolean.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBytes(java.lang.String, byte[])\r
+        */\r
+       public void setBytes(String parameterName, byte[] x) throws SQLException {\r
+               clusterCall("setBytes", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, byte[].class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBigDecimal(int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.CallableStatement#getBigDecimal(int, int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex, int scale)\r
+               throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal", new Object[]{new Integer(parameterIndex), new Integer(scale)},\r
+                               new Class<?>[]{Integer.TYPE, Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getURL(int)\r
+        */\r
+       public URL getURL(int parameterIndex) throws SQLException {\r
+               return (URL)clusterCall("getURL", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getArray(int)\r
+        */\r
+       public Array getArray(int i) throws SQLException {\r
+               return (Array)clusterCall("getArray", new Object[]{new Integer(i)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBlob(int)\r
+        */\r
+       public Blob getBlob(int i) throws SQLException {\r
+               return (Blob)clusterCall("getBlob", new Object[]{new Integer(i)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getClob(int)\r
+        */\r
+       public Clob getClob(int i) throws SQLException {\r
+               return (Clob)clusterCall("getClob", new Object[]{new Integer(i)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(int)\r
+        */\r
+       public Date getDate(int parameterIndex) throws SQLException {\r
+               return (Date)clusterCall("getDate", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getRef(int)\r
+        */\r
+       public Ref getRef(int i) throws SQLException {\r
+               return (Ref)clusterCall("getRef", new Object[]{new Integer(i)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(int)\r
+        */\r
+       public Time getTime(int parameterIndex) throws SQLException {\r
+               return (Time)clusterCall("getTime", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(int)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex) throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp", new Object[]{new Integer(parameterIndex)},\r
+                               new Class<?>[]{Integer.TYPE}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, int length)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       x,\r
+                       new Integer(length)\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       InputStream.class,\r
+                       Integer.TYPE\r
+               };\r
+               clusterCall("setAsciiStream", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(\r
+               String parameterName,\r
+               InputStream x,\r
+               int length)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       x,\r
+                       new Integer(length)\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       InputStream.class,\r
+                       Integer.TYPE\r
+               };\r
+               clusterCall("setBinaryStream", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(\r
+               String parameterName,\r
+               Reader reader,\r
+               int length)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       reader,\r
+                       new Integer(length)\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       Reader.class,\r
+                       Integer.TYPE\r
+               };\r
+               clusterCall("setCharacterStream", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String)\r
+        */\r
+       public Object getObject(String parameterName) throws SQLException {\r
+               return clusterCall("getObject", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object)\r
+        */\r
+       public void setObject(String parameterName, Object x) throws SQLException {\r
+               clusterCall("setObject", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, Object.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType)\r
+               throws SQLException {\r
+               clusterCall("setObject", new Object[]{parameterName, x, new Integer(targetSqlType)},\r
+                               new Class<?>[]{String.class, Object.class, Integer.TYPE}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(\r
+               String parameterName,\r
+               Object x,\r
+               int targetSqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       x,\r
+                       new Integer(targetSqlType),\r
+                       new Integer(scale)\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       Object.class,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               clusterCall("setObject", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(int, java.util.Map)\r
+        */\r
+       public Object getObject(int i,  Map<String, Class<?>> map) throws SQLException {\r
+               return clusterCall("getObject", new Object[]{new Integer(i), map},\r
+                               new Class<?>[]{Integer.TYPE, Map.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getString(java.lang.String)\r
+        */\r
+       public String getString(String parameterName) throws SQLException {\r
+               return (String)clusterCall("getString", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(\r
+               String parameterName,\r
+               int sqlType,\r
+               String typeName)\r
+               throws SQLException {\r
+               Object[] args = {\r
+                       parameterName,\r
+                       new Integer(sqlType),\r
+                       typeName\r
+               };\r
+               Class<?>[] types = {\r
+                       String.class,\r
+                       Integer.TYPE,\r
+                       String.class\r
+               };\r
+               clusterCall("registerOutParameter", args, types, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void setNull(String parameterName, int sqlType, String typeName)\r
+               throws SQLException {\r
+               clusterCall("setNull", new Object[]{parameterName, new Integer(sqlType), typeName},\r
+                               new Class<?>[]{String.class, Integer.TYPE, String.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setString(String parameterName, String x) throws SQLException {\r
+               clusterCall("setString", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, String.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBigDecimal(java.lang.String)\r
+        */\r
+       public BigDecimal getBigDecimal(String parameterName) throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBigDecimal(java.lang.String, java.math.BigDecimal)\r
+        */\r
+       public void setBigDecimal(String parameterName, BigDecimal x)\r
+               throws SQLException {\r
+               clusterCall("setBigDecimal", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, BigDecimal.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getURL(java.lang.String)\r
+        */\r
+       public URL getURL(String parameterName) throws SQLException {\r
+               return (URL)clusterCall("getURL", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)\r
+        */\r
+       public void setURL(String parameterName, URL val) throws SQLException {\r
+               clusterCall("setURL", new Object[]{parameterName, val},\r
+                               new Class<?>[]{String.class, URL.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getArray(java.lang.String)\r
+        */\r
+       public Array getArray(String parameterName) throws SQLException {\r
+               return (Array)clusterCall("getArray", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBlob(java.lang.String)\r
+        */\r
+       public Blob getBlob(String parameterName) throws SQLException {\r
+               return (Blob)clusterCall("getBlob", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getClob(java.lang.String)\r
+        */\r
+       public Clob getClob(String parameterName) throws SQLException {\r
+               return (Clob)clusterCall("getClob", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String)\r
+        */\r
+       public Date getDate(String parameterName) throws SQLException {\r
+               return (Date)clusterCall("getDate", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date)\r
+        */\r
+       public void setDate(String parameterName, Date x) throws SQLException {\r
+               clusterCall("setDate", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, Date.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)\r
+        */\r
+       public Date getDate(int parameterIndex, Calendar cal) throws SQLException {\r
+               return (Date)clusterCall("getDate", new Object[]{new Integer(parameterIndex), cal},\r
+                               new Class<?>[]{String.class, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getRef(java.lang.String)\r
+        */\r
+       public Ref getRef(String parameterName) throws SQLException {\r
+               return (Ref)clusterCall("getRef", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String)\r
+        */\r
+       public Time getTime(String parameterName) throws SQLException {\r
+               return (Time)clusterCall("getTime", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time)\r
+        */\r
+       public void setTime(String parameterName, Time x) throws SQLException {\r
+               clusterCall("setTime", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, Time.class}, true);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)\r
+        */\r
+       public Time getTime(int parameterIndex, Calendar cal) throws SQLException {\r
+               return (Time)clusterCall("getTime", new Object[]{new Integer(parameterIndex), cal},\r
+                               new Class<?>[]{String.class, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName) throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp", new Object[]{parameterName},\r
+                               new Class<?>[]{String.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x)\r
+               throws SQLException {\r
+               clusterCall("setTimestamp", new Object[]{parameterName, x},\r
+                               new Class<?>[]{String.class, Timestamp.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex, Calendar cal)\r
+               throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp", new Object[]{new Integer(parameterIndex), cal},\r
+                               new Class<?>[]{Integer.TYPE, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String, java.util.Map)\r
+        */\r
+       public Object getObject(String parameterName,  Map<String, Class<?>> map)\r
+               throws SQLException {\r
+               return clusterCall("getObject", new Object[]{parameterName, map},\r
+                               new Class<?>[]{String.class, Map.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Date getDate(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return (Date)clusterCall("getDate", new Object[]{parameterName, cal},\r
+                               new Class<?>[]{String.class, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Time getTime(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return (Time)clusterCall("getTime", new Object[]{parameterName, cal},\r
+                               new Class<?>[]{String.class, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp", new Object[]{parameterName, cal},\r
+                               new Class<?>[]{String.class, Calendar.class}, false);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(String parameterName, Date x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setDate", new Object[]{parameterName, x, cal},\r
+                               new Class<?>[]{String.class, Date.class, Calendar.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(String parameterName, Time x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setTime", new Object[]{parameterName, x, cal},\r
+                               new Class<?>[]{String.class, Time.class, Calendar.class}, true);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setTimestamp", new Object[]{parameterName, x, cal},\r
+                               new Class<?>[]{String.class, Timestamp.class, Calendar.class}, true);\r
+       }\r
+\r
+       // ---\r
+       // 以下未実装\r
+       // ---\r
+       //@Override\r
+       public Reader getCharacterStream(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public Reader getCharacterStream(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public Reader getNCharacterStream(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public Reader getNCharacterStream(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public NClob getNClob(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public NClob getNClob(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public String getNString(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public String getNString(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public RowId getRowId(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public RowId getRowId(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public SQLXML getSQLXML(int parameterIndex) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public SQLXML getSQLXML(String parameterName) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public void setAsciiStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setAsciiStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setBinaryStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setBinaryStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setBlob(String parameterName, Blob x) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setBlob(String parameterName, InputStream inputStream)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setBlob(String parameterName, InputStream inputStream,\r
+                       long length) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setCharacterStream(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setCharacterStream(String parameterName, Reader reader,\r
+                       long length) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setClob(String parameterName, Clob x) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNCharacterStream(String parameterName, Reader value)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNCharacterStream(String parameterName, Reader value,\r
+                       long length) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNClob(String parameterName, NClob value) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setNString(String parameterName, String value)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setRowId(String parameterName, RowId x) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void setSQLXML(String parameterName, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterConnection.java b/src/com/lavans/luz2/sql/cluster/ClusterConnection.java
new file mode 100644 (file)
index 0000000..00a785f
--- /dev/null
@@ -0,0 +1,846 @@
+/* $Id: ClusterConnection.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/09/17\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Connection;\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.NClob;\r
+import java.sql.PreparedStatement;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLClientInfoException;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.SQLXML;\r
+import java.sql.Savepoint;\r
+import java.sql.Statement;\r
+import java.sql.Struct;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+\r
+/**\r
+ * クラスタ接続用Connectionクラス。\r
+ *\r
+ * Connectionクラスに対して行う設定処理(setAutoCommit()等)は、\r
+ * 更新処理を行う前に実行しておくこと。DB切替が発生した際に、\r
+ * AutoCommitがTrueの時に作成したStatementは再実行されない。\r
+ *\r
+ * 制限事項\r
+ * クラスタ接続ではセーブポイントの管理は行わない。\r
+ * SQLWarningsはDB切替時に引き継がれない。\r
+ *\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterConnection implements Connection {\r
+       /** Messageクラスに移動? */\r
+       private static final String MSG_WARN_SWITCH_DB="障害が出たので接続先を切り替えます。";\r
+//     private static final String MSG_ERR_RECREATE="Statementの再生成に失敗。";\r
+       /** 処理委譲先 */\r
+       private Connection con=null;\r
+\r
+       /**\r
+        * コネクションプール。障害時に別のコネクションを取得するため、\r
+        * インスタンス変数として参照しておく必要がある。\r
+        */\r
+       private ClusterConnectionPool pool = null;\r
+\r
+       /**\r
+        * setAutoCommit実行フラグ。\r
+        * setAutoCommit()を明示的に呼ばないでクラスタの切り替えが起こった際に、\r
+        * 新しいConnectionでsetAutoCommit()を実行しないようにする。\r
+        * executeBatch内でSET TRANSACTIONしている時などにこの判断が必要。\r
+        * TODO 判定処理未実装\r
+        */\r
+//     private boolean setAutoCommitFlag = false; //\r
+\r
+       /**\r
+        * 保存しておくConnectionの状態。\r
+        * 障害が発生した場合、Connectionに対する操作(setAutoCommit()等)を\r
+        * 再実行するために保持しておく。\r
+        */\r
+       private boolean isAutoCommit = true;\r
+       private String catalog = null;\r
+       private int holdability = ResultSet.CLOSE_CURSORS_AT_COMMIT;\r
+       private boolean isReadOnly = false;\r
+       private int transactionIsolation = TRANSACTION_READ_COMMITTED;\r
+       private Map<String, Class<?>> typeMap = null;\r
+\r
+       /**\r
+        * Statement/PreparedStatement保存用リスト。\r
+        * 作成した順序を保存しておかなければならないので\r
+        * List型にて保存する。各Statementを作成したときの引数は\r
+        * 別途Mapにて保存。\r
+        */\r
+       private List<ClusterStatement> statementList = null;\r
+\r
+       /**\r
+        * Statement/PreparedStatementを作成したときの引数保存用。\r
+        * 障害時にStatementを再作成するのに必要。\r
+        * キーはStatement,値が作成時の引数を入れたCalledMethod。\r
+        * 障害時にはまだclose()されていないStatementに対して\r
+        * 再更新処理を行う。\r
+        */\r
+       private Map<ClusterStatement, CalledMethod> statementMap = null;\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterConnection.class);\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @throws SQLException\r
+        */\r
+       public ClusterConnection(Connection con, ClusterConnectionPool pool) throws SQLException{\r
+               this.con = con;\r
+               this.pool = pool;\r
+//             methodList = new ArrayList();\r
+               statementList = new ArrayList<ClusterStatement> ();\r
+               statementMap = new HashMap<ClusterStatement, CalledMethod> ();\r
+//             prepareMap = new HashMap();\r
+\r
+               // 障害時にコネクションに対して行った操作を再実行できるように保持しておく。\r
+               isAutoCommit = con.getAutoCommit();\r
+               catalog = con.getCatalog();\r
+               // Oracle9が未サポートのためコメントアウト\r
+               //holdability = con.getHoldability();\r
+               isReadOnly = con.isReadOnly();\r
+               transactionIsolation = con.getTransactionIsolation();\r
+               typeMap = con.getTypeMap();\r
+\r
+       }\r
+\r
+       /**\r
+        * 過去の実行履歴のクリア処理。\r
+        * ClusterConnectionPoolから取得するときに呼ばれる。\r
+        *\r
+        */\r
+//     public void init(){\r
+//             methodList.clear();\r
+//             statementList.clear();\r
+//             statementMap.clear();\r
+//     }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        * @param methodName\r
+        * @param args\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(String methodName, Object[] args, Class<?>[] parameterTypes) throws SQLException{\r
+               return clusterCall(new CalledMethod(methodName, args, parameterTypes));\r
+       }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        * @param calledMethod\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(CalledMethod calledMethod) throws SQLException{\r
+               logger.debug( calledMethod.toString());\r
+\r
+               Object result = null;\r
+               try{\r
+                       result = calledMethod.invoke(con);\r
+               }catch (Exception e) {\r
+                       try{\r
+                               logger.error(MSG_WARN_SWITCH_DB, e.getCause());\r
+                       }catch (Exception e2) {\r
+                               // getCause()に失敗した時用\r
+                               logger.error(MSG_WARN_SWITCH_DB, e);\r
+                       }\r
+                       try { con.close(); } catch (SQLException se) {}\r
+                       con = pool.getAnotherConnection(this);\r
+                       try{\r
+                               // コネクションに対して行った操作を再実行する。\r
+                               con.setAutoCommit(isAutoCommit);\r
+                               con.setCatalog(catalog);\r
+                               con.setHoldability(holdability);\r
+                               con.setReadOnly(isReadOnly);\r
+                               con.setTransactionIsolation(transactionIsolation);\r
+                               con.setTypeMap(typeMap);\r
+\r
+                               // 過去に作成したStatementへ再更新処理を依頼する。\r
+                               for(int i=0; i<statementList.size(); i++){\r
+                                       ClusterStatement cst = statementList.get(i);\r
+                                       CalledMethod method = statementMap.get(cst);\r
+                                       Statement st = (Statement)method.invoke(con);           // Statementを再生成\r
+                                       cst.reupdateStatement(st);\r
+                               }\r
+\r
+                               // エラーの起きたメソッドの再実行\r
+                               result = calledMethod.invoke(con);\r
+                       }catch (Exception e2) {\r
+                               // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。\r
+                               throw new SQLException(e2.getMessage());\r
+                       }\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+\r
+       /**\r
+        * 再実行キューからの取り外し。\r
+        * Statement#close()でこれを呼ぶ必要がある。\r
+        */\r
+       public void remove(Statement st){\r
+               statementList.remove(st);\r
+               statementMap.remove(st);\r
+       }\r
+       /**\r
+        * 再実行キューからの取り外し。\r
+        * PrepareStatement#close()でこれを呼ぶ必要がある。\r
+        */\r
+//     public void remove(PreparedStatement st){\r
+//             prepareMap.remove(st);\r
+//     }\r
+\r
+       /**\r
+        * 接続先切替。\r
+        * ClusterStatementから呼ばれる。エラーを通知してきたStatementに対しては\r
+        * autoCommitの状態にかかわらずネイティブなStatementを返す。\r
+        *\r
+        * 保存してあるすべてのStatementに対して、過去に実行した\r
+        * sqlを再実行する。\r
+        */\r
+       public void notifyError(ClusterStatement src) throws SQLException{\r
+               // 既存のconを破棄してみる。\r
+               try{ con.rollback(); con.close(); }catch (SQLException e) {}\r
+\r
+               try{\r
+                       con = pool.getAnotherConnection(this);\r
+                       // コネクションに対して行った操作を再実行する。\r
+                       con.setAutoCommit(isAutoCommit);\r
+                       con.setTransactionIsolation(transactionIsolation);\r
+                       con.setCatalog(catalog);\r
+                       // Oracle9iが対応していないので削除\r
+                       //con.setHoldability(holdability);\r
+                       con.setReadOnly(isReadOnly);\r
+                       con.setTypeMap(typeMap);\r
+\r
+                       // 過去に作成したStatementへ再更新処理を依頼する。\r
+                       for(int i=0; i<statementList.size(); i++){\r
+                               ClusterStatement cst = statementList.get(i);\r
+                               if(src==cst){                   // エラーの通知元にはstatementListに無くてもStatementを渡す。\r
+                                       continue;\r
+                               }\r
+                               CalledMethod method = statementMap.get(cst);\r
+                               Statement st = (Statement)method.invoke(con);           // Statementを再生成\r
+                               cst.reupdateStatement(st);\r
+                       }\r
+\r
+                       // エラーの通知元にはstatementListに無くてもStatementを渡す。\r
+                       CalledMethod method = statementMap.get(src);\r
+                       Statement st = (Statement)method.invoke(con);           // Statementを再生成\r
+                       src.reupdateStatement(st);\r
+\r
+               }catch (SQLException e) {\r
+                       throw e;\r
+               }catch (Exception e) {\r
+                       // それ以外のエラーが出た場合はSQLExceptionとしてスローする。\r
+                       throw new SQLException(e.getMessage());\r
+               }\r
+\r
+       }\r
+\r
+       /**\r
+        * 接続先切替。\r
+        * ClusterPreparedStatementから呼ばれる。\r
+        * ClusterPrStatementのインスタンスは消滅せずに、内部で持っている\r
+        * Statementへの参照を切り替えるだけなので、ネイティブなStatementを返す。\r
+        */\r
+//     public PreparedStatement getAnotherPreparedStatement(PreparedStatement pst) throws SQLException{\r
+//             // 既存のconを破棄してみる。\r
+//             try{ con.close(); }catch (SQLException e) {}\r
+//\r
+//             con = pool.getAnotherConnection(this);\r
+//\r
+//             // 前にPreparedStatementを作ったときの引数を取得。\r
+//             Object[] objs = (Object[])prepareMap.get(pst);\r
+//             Class<?>[] cls = null;\r
+//             if(objs!=null){         // objsがnull(=引数無し)の時はclsもnullで良い。prepareStatementではあり得ないはず。\r
+//                     cls = new Class[objs.length];\r
+//                     for(int i=0; i<objs.length; i++){\r
+//                             cls[i] = objs[i].getClass();\r
+//                     }\r
+//             }\r
+//\r
+//             // 新しいPreparedStatementの取得。\r
+//             // 失敗したらSQLExceptionでスローする。\r
+//             PreparedStatement st = null;\r
+//             try{\r
+//                     Method method = con.getClass().getMethod("prepareStatement",cls);\r
+//                     st = (PreparedStatement)method.invoke(con, objs);\r
+//             }catch (Exception e) {\r
+//                     throw new  SQLException(MSG_ERR_RECREATE+e.getMessage());\r
+//             }\r
+//             return st;\r
+//     }\r
+//\r
+       /**\r
+        * @see java.sql.Connection#createStatement()\r
+        */\r
+       public Statement createStatement() throws SQLException {\r
+               CalledMethod method = new CalledMethod("createStatement", null, null);\r
+\r
+               Statement st = (Statement)clusterCall(method);\r
+               ClusterStatement cst = new ClusterStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement(int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       new Integer(resultSetType),\r
+                       new Integer(resultSetConcurrency)\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               CalledMethod method = new CalledMethod("createStatement", args, types);\r
+\r
+               Statement st = (Statement)clusterCall(method);\r
+               ClusterStatement cst = new ClusterStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * Holdability指定付きStatement生成。\r
+        * ただしOracleは無条件で例外をスローする。\r
+        * @see java.sql.Connection#createStatement(int, int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       new Integer(resultSetType),\r
+                       new Integer(resultSetConcurrency),\r
+                       new Integer(resultSetHoldability)\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       Integer.TYPE,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               CalledMethod method = new CalledMethod("createStatement", args, types);\r
+\r
+               Statement st = (Statement)clusterCall(method);\r
+               ClusterStatement cst = new ClusterStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String)\r
+        */\r
+       public CallableStatement prepareCall(String sql) throws SQLException {\r
+               ClusterCallableStatement cst = new ClusterCallableStatement(this, con.prepareCall(sql));\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               ClusterCallableStatement cst = new ClusterCallableStatement(this, con.prepareCall(sql,resultSetType,resultSetConcurrency));\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               ClusterCallableStatement cst = new ClusterCallableStatement(this, con.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability));\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String)\r
+        */\r
+       public PreparedStatement prepareStatement(String sql) throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       sql\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       String.class\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int autoGeneratedKeys)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       sql,\r
+                       new Integer(autoGeneratedKeys)\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       String.class,\r
+                       Integer.TYPE\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       sql,\r
+                       new Integer(resultSetType),\r
+                       new Integer(resultSetConcurrency)\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       String.class,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{\r
+                       sql,\r
+                       new Integer(resultSetType),\r
+                       new Integer(resultSetConcurrency),\r
+                       new Integer(resultSetHoldability)\r
+               };\r
+               Class<?>[] types = new Class<?>[]{\r
+                       String.class,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE,\r
+                       Integer.TYPE\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{sql, columnIndexes};\r
+               Class<?>[] types = new Class<?>[]{\r
+                               String.class,\r
+                               int[].class\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               Object[] args = new Object[]{sql,columnNames};\r
+               Class<?>[] types = new Class<?>[]{\r
+                       String.class,\r
+                       String[].class\r
+               };\r
+               CalledMethod method = new CalledMethod("prepareStatement", args, types);\r
+\r
+               PreparedStatement st = (PreparedStatement)clusterCall(method);\r
+               ClusterPreparedStatement cst = new ClusterPreparedStatement(this, st);\r
+               if(!getAutoCommit()){                           // 自動コミットじゃない場合だけ\r
+                       statementList.add(cst);         // 再実行に備えてとっておく。\r
+                       statementMap.put(cst, method);\r
+               }\r
+               return cst;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getHoldability()\r
+        */\r
+       public int getHoldability() throws SQLException {\r
+               return holdability;\r
+//             return ((Integer)clusterCall("getHoldability", null, null)).intValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTransactionIsolation()\r
+        */\r
+       public int getTransactionIsolation() throws SQLException {\r
+               return transactionIsolation;\r
+//             return ((Integer)clusterCall("getTransactionIsolation", null, null)).intValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               clusterCall("clearWarnings", null, null);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               clusterCall("close", null, null);\r
+               // コネクションを閉じてしまったので以前のメソッドは再実行する必要なし。\r
+               statementList.clear();\r
+               statementMap.clear();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#commit()\r
+        */\r
+       public void commit() throws SQLException {\r
+               clusterCall("commit", null, null);\r
+               // 過去の更新処理は再実行する必要なし。\r
+               statementList.clear();\r
+               statementMap.clear();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#rollback()\r
+        */\r
+       public void rollback() throws SQLException {\r
+               clusterCall("rollback", null, null);\r
+               // 過去の更新処理は再実行する必要なし。\r
+               statementList.clear();\r
+               statementMap.clear();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getAutoCommit()\r
+        */\r
+       public boolean getAutoCommit() throws SQLException {\r
+               return isAutoCommit;\r
+//             return ((Boolean)clusterCall("getAutoCommit", null, null)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return ((Boolean)clusterCall("isClosed", null, null)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isReadOnly()\r
+        */\r
+       public boolean isReadOnly() throws SQLException {\r
+               return isReadOnly;\r
+//             return ((Boolean)clusterCall("isReadOnly", null, null)).booleanValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setHoldability(int)\r
+        */\r
+       public void setHoldability(int holdability) throws SQLException {\r
+               clusterCall("setHoldability", new Object[]{new Integer(holdability)},\r
+                               new Class<?>[]{Integer.TYPE});\r
+               this.holdability = holdability;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTransactionIsolation(int)\r
+        */\r
+       public void setTransactionIsolation(int level) throws SQLException {\r
+               clusterCall("setTransactionIsolation", new Object[]{new Integer(level)},\r
+                               new Class<?>[]{Integer.TYPE});\r
+               transactionIsolation = level;\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setAutoCommit(boolean)\r
+        */\r
+       public void setAutoCommit(boolean autoCommit) throws SQLException {\r
+               clusterCall("setAutoCommit", new Object[]{new Boolean(autoCommit)},\r
+                               new Class<?>[]{Boolean.TYPE});\r
+               isAutoCommit = autoCommit;\r
+\r
+               // この時点でコミットが行われるので、過去の更新処理はクリアする。\r
+               statementList.clear();\r
+               statementMap.clear();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setReadOnly(boolean)\r
+        */\r
+       public void setReadOnly(boolean readOnly) throws SQLException {\r
+               clusterCall("setReadOnly", new Object[]{new Boolean(readOnly)},\r
+                               new Class<?>[]{Boolean.TYPE});\r
+               isReadOnly = readOnly;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getCatalog()\r
+        */\r
+       public String getCatalog() throws SQLException {\r
+               return catalog;\r
+//             return (String)clusterCall("getCatalog", null, null);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setCatalog(java.lang.String)\r
+        */\r
+       public void setCatalog(String setCatalog) throws SQLException {\r
+               clusterCall("setCatalog", new Object[]{setCatalog},\r
+                               new Class<?>[]{String.class});\r
+               this.catalog = setCatalog;\r
+       }\r
+\r
+       /**\r
+        * Oracle10gののojdbc14に合わせてsynchronizedにする。\r
+        * @see java.sql.Connection#getMetaData()\r
+        */\r
+       public synchronized DatabaseMetaData getMetaData() throws SQLException {\r
+               return (DatabaseMetaData)clusterCall("getMetaData", null, null);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return (SQLWarning)clusterCall("getWarnings", null, null);\r
+       }\r
+\r
+       /**\r
+        * 名前無しセーブポイントの作成。\r
+        * クラスタ接続ではセーブポイントの管理は行わない。\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setSavepoint()\r
+        */\r
+       public Savepoint setSavepoint() throws SQLException {\r
+               throw new UnsupportedOperationException();\r
+               // con.setSavepoint();\r
+       }\r
+\r
+       /**\r
+        * セーブポイント破棄。\r
+        * クラスタ接続ではセーブポイントの管理は行わない。\r
+        * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)\r
+        */\r
+       public void releaseSavepoint(Savepoint savepoint) throws SQLException {\r
+               throw new UnsupportedOperationException();\r
+               //con.releaseSavepoint(savepoint);\r
+       }\r
+\r
+       /**\r
+        * 指定のセーブポイントまでのロールバック。\r
+        * クラスタ接続ではセーブポイントの管理は行わない。\r
+        * @see java.sql.Connection#rollback(java.sql.Savepoint)\r
+        */\r
+       public void rollback(Savepoint savepoint) throws SQLException {\r
+               throw new UnsupportedOperationException();\r
+               //con.rollback(savepoint);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTypeMap()\r
+        */\r
+       public Map<String, Class<?>> getTypeMap() throws SQLException {\r
+               return typeMap;\r
+//             return (Map)clusterCall("getTypeMap", null, null);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTypeMap(java.util.Map)\r
+        */\r
+       public void setTypeMap(Map<String, Class<?>> map) throws SQLException {\r
+               clusterCall("setTypeMap", new Object[]{map},\r
+                               new Class<?>[]{Map.class});\r
+               this.typeMap = map;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#nativeSQL(java.lang.String)\r
+        */\r
+       public String nativeSQL(String sql) throws SQLException {\r
+               return (String)clusterCall("nativeSQL", new Object[]{sql},\r
+                               new Class<?>[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * 名前無しセーブポイントの作成。\r
+        * クラスタ接続ではセーブポイントの管理は行わない。\r
+        * @see java.sql.Connection#setSavepoint(java.lang.String)\r
+        */\r
+       public Savepoint setSavepoint(String name) throws SQLException {\r
+               throw new UnsupportedOperationException();\r
+               // return con.setSavepoint(name);\r
+       }\r
+\r
+       // ---\r
+       // 以下未実装\r
+       // ---\r
+\r
+       public Array createArrayOf(String arg0, Object[] arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public Blob createBlob() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public Clob createClob() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public NClob createNClob() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public SQLXML createSQLXML() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public Struct createStruct(String arg0, Object[] arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public Properties getClientInfo() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public String getClientInfo(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       public boolean isValid(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return false;\r
+       }\r
+\r
+       public void setClientInfo(Properties arg0) throws SQLClientInfoException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       public void setClientInfo(String arg0, String arg1)\r
+                       throws SQLClientInfoException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return false;\r
+       }\r
+\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterConnectionPool.java b/src/com/lavans/luz2/sql/cluster/ClusterConnectionPool.java
new file mode 100644 (file)
index 0000000..ba005c8
--- /dev/null
@@ -0,0 +1,204 @@
+/* $Id: ClusterConnectionPool.java 222 2010-09-06 19:20:24Z dobashi $\r
+ * create: 2004/10/22\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.sql.Connection;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+import java.util.Random;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.ConnectionPool;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindConnectionImpl;\r
+import com.lavans.luz2.sql.pool.PooledConnection;\r
+import com.lavans.luz2.sql.stats.StatsConnection;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterConnectionPool extends ConnectionPool {\r
+       /** 接続先がない場合のエラーメッセージ */\r
+       private static final String MSG_ERR_NOCONNECT="有効な接続先がありません。";\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterConnectionPool.class);\r
+\r
+       /** 接続先URL一覧 */\r
+       private List<String> urlList = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        **/\r
+       public ClusterConnectionPool(String driver, String url,String user,String pass){\r
+               super(driver,url,user,pass);\r
+       }\r
+\r
+       /** 乱数生成用 */\r
+       private static Random rnd = new Random();\r
+\r
+       /** 接続先コネクションとurlのマッピング。 */\r
+       private Map<Connection, String> urlMap = null;\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       public List<String> getUrlList() {\r
+               return urlList;\r
+       }\r
+\r
+       /**\r
+        * @param list\r
+        */\r
+       public void setUrlList(List<String> list) {\r
+               urlList = list;\r
+               urlMap = new HashMap<Connection, String>(list.size());\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see com.lavans.util.jdbc.ConnectionPool#createConnection()\r
+        */\r
+       @Override\r
+       protected PooledConnection createConnection() throws SQLException {\r
+               // 最大数チェック\r
+               if((getPoolList().size() + getUseList().size()) >= getMaxConnections()){\r
+                       throw new SQLException(MSG_ERR_TOOMANYCONNECTIONS, SQLSTATE_CONNECTION_EXCEPTION, ERR_CONNECTION_OVERFLOW);\r
+               }\r
+               Connection conn = createNativeConnection();\r
+\r
+               conn = new ClusterConnection(conn,this);\r
+               logger.debug(conn.getMetaData().getURL());\r
+               urlMap.put(conn,conn.getMetaData().getURL());   // コネクションと新しいurlのマッピングを行う。\r
+\r
+               // StatsConnection,LoggingConnectionともにLoggableインターフェースの\r
+               // 実装とした。LoggableなConnectionの作成順序は入れ替え可能。\r
+               // Loggableを実装しないラッパークラスを作る場合はこれらの前にnewすること。\r
+\r
+               // 統計情報を収集するなら\r
+               if(isStatistics()){\r
+                       conn = new StatsConnection(conn);\r
+               }\r
+\r
+               // BindConnection型を返すので、BindConnectionでラップするのは\r
+               // 一番最後でないといけない。\r
+               BindConnection bcon = new BindConnectionImpl(conn);\r
+\r
+               // さらにConnection#close()で物理的に閉じずにDBManagerに\r
+               // 返却するためPooledConnectionでラップする。\r
+               // ConnectionPoolではなくDBManagerを通すのは\r
+               // 統計情報取得時に貸し出し管理を行うため。\r
+               PooledConnection pcon = new PooledConnection(this,bcon);\r
+\r
+               return pcon;\r
+       }\r
+\r
+       /**\r
+        * Native接続作成。Clusterの中から選択して接続テストを行い、\r
+        * 失敗したら他の接続先にする。\r
+        * @see createNativeConnection(String)\r
+        * @return\r
+        */\r
+       private Connection createNativeConnection() throws SQLException{\r
+               // ワーク用にURLリストをコピーして有効なurlを探索。\r
+               return createNativeConnection(new ArrayList<String>(urlList));\r
+       }\r
+\r
+       /**\r
+        * Native接続作成。Clusterの中から選択して接続テストを行い、\r
+        * 失敗したら他の接続先にする。DBに障害があった時に特定の\r
+        * urlをあらかじめ排除するため、接続先一覧を指定できるようにする。\r
+        * @return\r
+        */\r
+       private Connection createNativeConnection(List<String> workList) throws SQLException{\r
+               // from java.sql.DriverManager\r
+               Properties info = new Properties();\r
+               if (getUser() != null) {\r
+                   info.put("user", getUser());\r
+               }\r
+               if (getPass() != null) {\r
+                   info.put("password", getPass());\r
+               }\r
+\r
+               // 接続に失敗した場合はそのurlをワークリストから外して、\r
+               // 再度ランダムにurlを選択し直す。\r
+               while(workList.size()>0){\r
+                       String url = getRandomSelectUrl(workList);\r
+                       try{\r
+                               Connection conn = getDriver().connect(url, info);\r
+                               if(checkConnection(conn)){                              // 接続に成功したら\r
+                                       return conn;\r
+                               }\r
+                               // 接続に失敗したら今のurlを除外して、無くなるまで繰り返す。\r
+                               workList.remove(url);\r
+                       }catch (SQLException e) {                               // getConnectionに失敗した場合も\r
+                               workList.remove(url);                           // 今のurlを除外して、無くなるまで繰り返す。\r
+                       }\r
+               }\r
+\r
+               // 有効なConnectionが見つからないままworkListが0になってしまったらエラー\r
+               throw new SQLException(MSG_ERR_NOCONNECT);\r
+       }\r
+\r
+       /**\r
+        * Clusterの接続先からランダムに選択する。\r
+        * @return 選択されたJDBC Driver URL\r
+        */\r
+       private String getRandomSelectUrl(List<String> list){\r
+               int i = (int)Math.ceil(rnd.nextInt(list.size()));\r
+               logger.info("★ "+ i +"番目が選択された。"+list.get(i));\r
+               return list.get(i);\r
+       }\r
+\r
+       /**\r
+        * 別の接続先を取得する。\r
+        * このメソッドが呼ばれるのはClusterConnectionが接続している先のDBに\r
+        * 障害があったとき。したがって、エラーが発生していないurlの中から\r
+        * 有効なurlを探索し、Connectionを生成して返してやる。\r
+        * BindやLogginはClusterConnectionの上にラップされているので、\r
+        * ここでは意識する必要はない。\r
+        * @return\r
+        */\r
+       public Connection getAnotherConnection(ClusterConnection target) throws SQLException{\r
+               String url = urlMap.remove(target);\r
+               List<String> workList = new ArrayList<String>(urlList); // urlListをコピーして\r
+               workList.remove(url);                                           // 障害が起きたurlを除外する。\r
+               Connection conn = createNativeConnection(workList);\r
+\r
+               logger.debug(conn.getMetaData().getURL());\r
+               urlMap.put(target,conn.getMetaData().getURL()); // コネクションと新しいurlのマッピングを行う。\r
+\r
+               return conn;\r
+       }\r
+\r
+       /**\r
+        * コネクションの取得。\r
+        * コネクション管理はスーパークラスであるConnectionPoolで行うが、\r
+        * クラスタコネクションの場合だけは初期化処理(過去の更新履歴を削除)する。\r
+        *\r
+        * 初期化の呼び出しを行う適切な場所が思いつかなかったので、\r
+        * ここでrollback()することにした。setAutoCommit(false)で\r
+        * 使われるときは別に呼ばなくても構わないのだが、setAutoCommit(true)で\r
+        * 使われるときにClusterConnection#set○○系の処理がキューに溜まっていってしまうので、\r
+        * コネクション取得時にmethodListがクリアされるようにした。\r
+        *\r
+        * @see com.lavans.luz.sql.ConnectionPool#getConnection()\r
+        */\r
+       @Override\r
+       public PooledConnection getConnection() throws SQLException {\r
+               PooledConnection con = super.getConnection();\r
+               con.rollback();\r
+               return con;\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterPreparedStatement.java b/src/com/lavans/luz2/sql/cluster/ClusterPreparedStatement.java
new file mode 100644 (file)
index 0000000..64d0984
--- /dev/null
@@ -0,0 +1,735 @@
+/* $Id: ClusterPreparedStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/25\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.ParameterMetaData;\r
+import java.sql.PreparedStatement;\r
+import java.sql.Ref;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Statement;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.List;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * PrepareStatementをクラスタ対応化するクラス。\r
+ * setXX()でセットされたパラメータを保持し、DB切り替えで再実行する際には\r
+ * 再度setXX()を行う。\r
+ *\r
+ * executeUpdate()等の更新処理が複数回実行された後、\r
+ * Commitする前にDB切替が起きた場合、すべての更新処理が再実行される。\r
+ * 従って、トランザクション内で一つのStatementを持ち回って更新処理を\r
+ * 行う処理はフェイルオーバーできる。\r
+ *\r
+ * sequenceを使って連番管理している場合は2カウントアップされる?(要確認)。\r
+ *\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterPreparedStatement\r
+       extends ClusterStatement\r
+       implements PreparedStatement {\r
+\r
+       /** 処理移譲先。 */\r
+       private PreparedStatement st=null;\r
+\r
+       /** コネクション。障害時に別のStaementを作るよう依頼する。 */\r
+       private ClusterConnection con = null;\r
+\r
+       /**\r
+        * 保存しておくメソッドのリスト。\r
+        * 障害が発生した場合、ClusterPreparedStatementに対する操作を操作が行われた\r
+        * 順序どおりに再実行する必要がある。\r
+        */\r
+       private List<CalledMethod> methodList = null;\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterPreparedStatement.class);\r
+\r
+       /**\r
+        * @param con\r
+        * @param st\r
+        */\r
+       public ClusterPreparedStatement(ClusterConnection con, PreparedStatement st) {\r
+               super(con, st);\r
+               this.con = con;\r
+               this.st = st;\r
+               methodList = new ArrayList<CalledMethod>();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#close()\r
+        */\r
+       @Override\r
+       public void close() throws SQLException {\r
+               methodList.clear();\r
+               super.close();\r
+       }\r
+\r
+\r
+       /**\r
+        * DB切替時、新たに取得したStatementに対して\r
+        * 更新処理を再実行する。\r
+        * @param\r
+        */\r
+       @Override\r
+       public void reupdateStatement(Statement st) throws SQLException{\r
+               try { this.st.close(); } catch (SQLException se) {}\r
+               this.st = (PreparedStatement)st;\r
+\r
+               super.reupdateStatement(st);    // ベースクラスでも再実行\r
+               logger.debug( "reexecute count:"+ methodList.size());\r
+               for(int i=0; i<methodList.size(); i++){\r
+                       CalledMethod calledMethod = methodList.get(i);\r
+                       try{\r
+                               logger.debug(calledMethod.toString());\r
+                               calledMethod.invoke(st);        // 戻り値は無視して良い\r
+                       }catch (Exception e) {\r
+                               logger.error(MSG_ERR_REUPDATE, e);\r
+                               throw new SQLException(MSG_ERR_REUPDATE);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        * @param methodName\r
+        * @param args\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(String methodName, Object[] args, Class<?>[] parameterTypes) throws SQLException{\r
+               Object result = null;\r
+\r
+               CalledMethod calledMethod = new CalledMethod(methodName, args, parameterTypes);\r
+               logger.debug(calledMethod.toString());\r
+\r
+               try{\r
+                       result = calledMethod.invoke(st);\r
+               }catch (Exception e) {\r
+                       logger.warn(MSG_WARN_SWITCH_DB, e);\r
+                       con.notifyError(this);\r
+                       try{\r
+                               result = calledMethod.invoke(st);\r
+                       }catch (Exception e2) {\r
+                               // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。\r
+                               throw new SQLException(e2.getMessage());\r
+                       }\r
+               }\r
+               methodList.add(calledMethod);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * ResultSet再生成処理。\r
+        * ResultSetで障害が起きたときに、ResultSetから呼ばれる。\r
+        * @see com.lavans.util.jdbc.cluster.ClusterStatementInterface#getAnotherResultSet()\r
+        */\r
+       @Override\r
+       public ResultSet getAnotherResultSet() throws SQLException {\r
+               // resultSet内で障害を検知したので、再度コネクションを張り直す。\r
+               try { st.close(); } catch (SQLException se) {}\r
+               con.notifyError(this);\r
+               ResultSet rs = st.executeQuery();               // ResultSetを生成するのはexecuteQuery()だけ。\r
+\r
+               return rs;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#executeQuery()\r
+        */\r
+       public ResultSet executeQuery() throws SQLException {\r
+               ResultSet result = (ResultSet)clusterCall("executeQuery", null, null);\r
+               // executeQueryでもinsert文は実行できるので保存する必要があることに注意。\r
+\r
+               return new ClusterResultSet(this,result);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#executeUpdate()\r
+        */\r
+       public int executeUpdate() throws SQLException {\r
+               return ((Integer)clusterCall("executeUpdate", null, null)).intValue();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#execute()\r
+        */\r
+       public boolean execute() throws SQLException {\r
+               return ((Boolean)clusterCall("execute", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#addBatch()\r
+        */\r
+       public void addBatch() throws SQLException {\r
+               clusterCall("addBatch", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#clearParameters()\r
+        */\r
+       public void clearParameters() throws SQLException {\r
+               clusterCall("clearParameters", null, null);\r
+               // methodListをクリアしてもいいのでは?\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#setByte(int, byte)\r
+        */\r
+       public void setByte(int parameterIndex, byte x) throws SQLException {\r
+               clusterCall(\r
+                       "setByte",\r
+                       new Object[]{new Integer(parameterIndex), new Byte(x)},\r
+                       new Class[]{Integer.TYPE, Byte.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDouble(int, double)\r
+        */\r
+       public void setDouble(int parameterIndex, double x) throws SQLException {\r
+               clusterCall(\r
+                       "setDouble",\r
+                       new Object[]{new Integer(parameterIndex), new Double(x)},\r
+                       new Class[]{Integer.TYPE, Double.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setFloat(int, float)\r
+        */\r
+       public void setFloat(int parameterIndex, float x) throws SQLException {\r
+               clusterCall(\r
+                   "setFloat",\r
+                       new Object[]{new Integer(parameterIndex), new Float(x)},\r
+                       new Class[]{Integer.TYPE, Float.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setInt(int, int)\r
+        */\r
+       public void setInt(int parameterIndex, int x) throws SQLException {\r
+               clusterCall(\r
+                   "setInt",\r
+                   new Object[]{new Integer(parameterIndex), new Integer(x)},\r
+                   new Class[]{Integer.TYPE, Integer.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setNull(int, int)\r
+        */\r
+       public void setNull(int parameterIndex, int sqlType) throws SQLException {\r
+               clusterCall(\r
+                   "setNull",\r
+                   new Object[]{new Integer(parameterIndex), new Integer(sqlType)},\r
+                   new Class[]{Integer.TYPE, Integer.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setLong(int, long)\r
+        */\r
+       public void setLong(int parameterIndex, long x) throws SQLException {\r
+               clusterCall(\r
+                   "setLong",\r
+                   new Object[]{new Integer(parameterIndex), new Long(x)},\r
+                       new Class[]{Integer.TYPE, Long.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setShort(int, short)\r
+        */\r
+       public void setShort(int parameterIndex, short x) throws SQLException {\r
+               clusterCall(\r
+                       "setShort", new Object[]{new Integer(parameterIndex), new Short(x)},\r
+                               new Class[]{Integer.TYPE, Short.TYPE});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBoolean(int, boolean)\r
+        */\r
+       public void setBoolean(int parameterIndex, boolean x) throws SQLException {\r
+               clusterCall("setBoolean", new Object[]{new Integer(parameterIndex), new Boolean(x)},\r
+                               new Class[]{Integer.TYPE, Boolean.TYPE});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBytes(int, byte[])\r
+        */\r
+       public void setBytes(int parameterIndex, byte[] x) throws SQLException {\r
+               clusterCall("setBytes", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, byte[].class});\r
+       }\r
+\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("setAsciiStream", new Object[]{new Integer(parameterIndex), x, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("setBinaryStream", new Object[]{new Integer(parameterIndex), x, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#setUnicodeStream(int, java.io.InputStream, int)\r
+        * @deprecated\r
+        */\r
+       public  void setUnicodeStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("setUnicodeStream", new Object[]{new Integer(parameterIndex), x, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(\r
+               int parameterIndex,\r
+               Reader reader,\r
+               int length)\r
+               throws SQLException {\r
+               clusterCall("setCharacterStream", new Object[]{new Integer(parameterIndex), reader, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, Reader.class, Integer.TYPE});\r
+       }\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)\r
+        */\r
+       public void setObject(int parameterIndex, Object x) throws SQLException {\r
+               clusterCall(\r
+                       "setObject",\r
+                       new Object[]{new Integer(parameterIndex), x},\r
+                       new Class[]{Integer.TYPE, Object.class}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)\r
+        */\r
+       public void setObject(int parameterIndex, Object x, int targetSqlType)\r
+               throws SQLException {\r
+               clusterCall(\r
+                       "setObject",\r
+                       new Object[]{new Integer(parameterIndex), x, new Integer(targetSqlType)},\r
+                       new Class[]{Integer.TYPE, Object.class, Integer.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(\r
+               int parameterIndex,\r
+               Object x,\r
+               int targetSqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               clusterCall(\r
+                       "setObject",\r
+                       new Object[]{new Integer(parameterIndex), x, new Integer(targetSqlType), new Integer(scale)},\r
+                       new Class[]{Integer.TYPE, Object.class, Integer.TYPE, Integer.TYPE}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)\r
+        */\r
+       public void setNull(int paramIndex, int sqlType, String typeName)\r
+               throws SQLException {\r
+               clusterCall("setNull", new Object[]{new Integer(paramIndex), new Integer(sqlType), typeName},\r
+                               new Class[]{Integer.TYPE, Integer.TYPE, String.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setString(int, java.lang.String)\r
+        */\r
+       public void setString(int parameterIndex, String x) throws SQLException {\r
+               clusterCall(\r
+                       "setString",\r
+                       new Object[]{new Integer(parameterIndex), x},\r
+                       new Class[]{Integer.TYPE, String.class}\r
+               );\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)\r
+        */\r
+       public void setBigDecimal(int parameterIndex, BigDecimal x)\r
+               throws SQLException {\r
+               clusterCall("setBigDecimal", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, BigDecimal.class});\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setURL(int, java.net.URL)\r
+        */\r
+       public void setURL(int parameterIndex, URL x) throws SQLException {\r
+               clusterCall("setURL", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, URL.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)\r
+        */\r
+       public void setArray(int i, Array x) throws SQLException {\r
+               clusterCall("setArray", new Object[]{new Integer(i), x},\r
+                               new Class[]{Integer.TYPE, Array.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)\r
+        */\r
+       public void setBlob(int i, Blob x) throws SQLException {\r
+               clusterCall("setBlob", new Object[]{new Integer(i), x},\r
+                               new Class[]{Integer.TYPE, Blob.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)\r
+        */\r
+       public void setClob(int i, Clob x) throws SQLException {\r
+               clusterCall("setClob", new Object[]{new Integer(i), x},\r
+                               new Class[]{Integer.TYPE, Clob.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)\r
+        */\r
+       public void setDate(int parameterIndex, Date x) throws SQLException {\r
+               clusterCall("setDate", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, Date.class});\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#getParameterMetaData()\r
+        */\r
+       public ParameterMetaData getParameterMetaData() throws SQLException {\r
+               return (ParameterMetaData)clusterCall("getParameterMetaData", null, null);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)\r
+        */\r
+       public void setRef(int i, Ref x) throws SQLException {\r
+               clusterCall("setRef", new Object[]{new Integer(i), x},\r
+                               new Class[]{Integer.TYPE, Ref.class});\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#getMetaData()\r
+        */\r
+       public ResultSetMetaData getMetaData() throws SQLException {\r
+               return (ResultSetMetaData)clusterCall("getMetaData", null, null);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)\r
+        */\r
+       public void setTime(int parameterIndex, Time x) throws SQLException {\r
+               clusterCall("setTime", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, Time.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x)\r
+               throws SQLException {\r
+               clusterCall("setTimestamp", new Object[]{new Integer(parameterIndex), x},\r
+                               new Class[]{Integer.TYPE, Timestamp.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(int parameterIndex, Date x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setDate", new Object[]{new Integer(parameterIndex), x, cal},\r
+                               new Class[]{Integer.TYPE, Date.class, Calendar.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(int parameterIndex, Time x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setTime", new Object[]{new Integer(parameterIndex), x, cal},\r
+                               new Class[]{Integer.TYPE, Time.class, Calendar.class});\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)\r
+               throws SQLException {\r
+               clusterCall("setTimestamp", new Object[]{new Integer(parameterIndex), x, cal},\r
+                               new Class[]{Integer.TYPE, Timestamp.class, Calendar.class});\r
+       }\r
+\r
+       // ---\r
+       // 以下未実装\r
+       // ---\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream, long length)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)\r
+        */\r
+       public void setNClob(int parameterIndex, NClob value) throws SQLException {\r
+               st.setNClob(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setNClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNString(int, java.lang.String)\r
+        */\r
+       public void setNString(int parameterIndex, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId)\r
+        */\r
+       public void setRowId(int parameterIndex, RowId x) throws SQLException {\r
+               st.setRowId(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(int parameterIndex, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterIndex, xmlObject);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterResultSet.java b/src/com/lavans/luz2/sql/cluster/ClusterResultSet.java
new file mode 100644 (file)
index 0000000..e89d40c
--- /dev/null
@@ -0,0 +1,1501 @@
+/* $Id: ClusterResultSet.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/28\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.SQLXML;\r
+import java.sql.Statement;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * クラスタ接続対応ResultSet。\r
+ * getString(),getInt()等のデータを取得する処理の最中に\r
+ * Exceptionが発生した場合に、DB接続先の切り替えを行う。\r
+ *\r
+ * 一つのStatementから複数のResultSetを生成している場合、\r
+ * ResultSet内でDB切替が起きると最後に生成したResultSetを\r
+ * 再生成する。従って、利用する側では先に取得したResultSetに\r
+ * 対する処理をすべて終わらせてclose()してから次の\r
+ * ResultSetを取得するようにすること。複数のResultSetを\r
+ * 取得するより、Statementを複数生成するようにした方が\r
+ * 望ましい。\r
+ *\r
+ * △\r
+ * st = con.createStatement();\r
+ * rs1 = st.executeQuery(sql1);\r
+ * rs2 = st.executeQuery(sql2);\r
+ * ○\r
+ * st1 = con.createStatement();\r
+ * st2 = con.createStatement();\r
+ * rs1 = st1.executeQuery(sql1);\r
+ * rs2 = st2.executeQuery(sql2);\r
+ *\r
+ *\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterResultSet implements ResultSet {\r
+       /** Messageクラスに移動? */\r
+       protected static final String MSG_WARN_SWITCH_DB="ResultSet内で障害が出たので接続先を切り替えます。";\r
+       protected static final String MSG_ERR_RECREATE="ResultSetの再生成に失敗。";\r
+\r
+       /** 処理移譲先 */\r
+       private ResultSet rs = null;\r
+\r
+       /**\r
+        * 自分を生成したStatement。\r
+        * ClusterStatement/ClusterPreparedStatement/ClusterCollableStatementのどれか。\r
+        */\r
+       private ClusterStatementInterface st = null;\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterResultSet.class);\r
+\r
+       /**\r
+        * 保存しておくメソッドのリスト。\r
+        * 障害が発生した場合、ResultSetに対する操作を操作が行われた\r
+        * 順序どおりに再実行する必要がある。\r
+        *\r
+        * ただし、first(),beforeFirst(),last(),afterLast()が呼び出された場合は、\r
+        * それ以前に実行されたカーソル移動系メソッドは無視してよいので、\r
+        * methodListから削除する処理を追加したい。\r
+        */\r
+       private List<CalledMethod> methodList = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param rs\r
+        */\r
+       public ClusterResultSet(ClusterStatementInterface st, ResultSet rs){\r
+               this.st = st;\r
+               this.rs = rs;\r
+               methodList = new ArrayList<CalledMethod>();\r
+       }\r
+\r
+       /**\r
+        * とっておいたResultSetへのアクセスを再設定(障害時切替用)。\r
+        * @param rs 新しいResultSet\r
+        */\r
+       private void setParameters(ResultSet rs) throws SQLException{\r
+               for(int i=0; i<methodList.size(); i++){\r
+                       CalledMethod calledMethod = methodList.get(i);\r
+                       try{\r
+                               calledMethod.invoke(rs);        // 戻り値は無視して良い\r
+                       }catch (Exception e) {\r
+                               logger.error(MSG_ERR_RECREATE, e);\r
+                               throw new SQLException(MSG_ERR_RECREATE);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        * @param methodName\r
+        * @param args\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(String methodName, Object[] args, Class<?>[] parameterTypes) throws SQLException{\r
+               Object result = null;\r
+               CalledMethod calledMethod = new CalledMethod(methodName, args, parameterTypes);\r
+               try{\r
+                       result = calledMethod.invoke(rs);\r
+               }catch (Exception e) {\r
+                       logger.debug(MSG_WARN_SWITCH_DB+e.getMessage());\r
+                       try { rs.close(); } catch (SQLException se) {}\r
+                       rs = st.getAnotherResultSet();\r
+                       try{\r
+                               setParameters(rs);\r
+                               result = calledMethod.invoke(rs);\r
+                       }catch (Exception e2) {\r
+                               // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。\r
+                               throw new SQLException(e2.getMessage());\r
+                       }\r
+               }\r
+               methodList.add(calledMethod);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getConcurrency()\r
+        */\r
+       public int getConcurrency() throws SQLException {\r
+               return ((Integer)clusterCall("getConcurrency", null, null)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getFetchDirection()\r
+        */\r
+       public int getFetchDirection() throws SQLException {\r
+               return ((Integer)clusterCall("getFetchDirection", null, null)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getFetchSize()\r
+        */\r
+       public int getFetchSize() throws SQLException {\r
+               return ((Integer)clusterCall("getFetchSize", null, null)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getRow()\r
+        */\r
+       public int getRow() throws SQLException {\r
+               return ((Integer)clusterCall("getRow", null, null)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getType()\r
+        */\r
+       public int getType() throws SQLException {\r
+               return ((Integer)clusterCall("getType", null, null)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#afterLast()\r
+        */\r
+       public void afterLast() throws SQLException {\r
+               clusterCall("afterLast", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#beforeFirst()\r
+        */\r
+       public void beforeFirst() throws SQLException {\r
+               clusterCall("beforeFirst", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#cancelRowUpdates()\r
+        */\r
+       public void cancelRowUpdates() throws SQLException {\r
+               clusterCall("cancelRowUpdates", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               clusterCall("clearWarnings", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               clusterCall("close", null, null);\r
+               methodList.clear();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#deleteRow()\r
+        */\r
+       public void deleteRow() throws SQLException {\r
+               clusterCall("deleteRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#insertRow()\r
+        */\r
+       public void insertRow() throws SQLException {\r
+               clusterCall("insertRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#moveToCurrentRow()\r
+        */\r
+       public void moveToCurrentRow() throws SQLException {\r
+               clusterCall("moveToCurrentRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#moveToInsertRow()\r
+        */\r
+       public void moveToInsertRow() throws SQLException {\r
+               clusterCall("moveToInsertRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#refreshRow()\r
+        */\r
+       public void refreshRow() throws SQLException {\r
+               clusterCall("refreshRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateRow()\r
+        */\r
+       public void updateRow() throws SQLException {\r
+               clusterCall("updateRow", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#first()\r
+        */\r
+       public boolean first() throws SQLException {\r
+               return ((Boolean)clusterCall("first", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#isAfterLast()\r
+        */\r
+       public boolean isAfterLast() throws SQLException {\r
+               return ((Boolean)clusterCall("isAfterLast", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#isBeforeFirst()\r
+        */\r
+       public boolean isBeforeFirst() throws SQLException {\r
+               return ((Boolean)clusterCall("isBeforeFirst", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#isFirst()\r
+        */\r
+       public boolean isFirst() throws SQLException {\r
+               return ((Boolean)clusterCall("isFirst", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#isLast()\r
+        */\r
+       public boolean isLast() throws SQLException {\r
+               return ((Boolean)clusterCall("isLast", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#last()\r
+        */\r
+       public boolean last() throws SQLException {\r
+               // Method#invoke()でBooleanに自動ラップされている。\r
+               return ((Boolean)clusterCall("last", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * カーソルを現在の位置から 1 行下に移動します。\r
+        * @see java.sql.ResultSet#next()\r
+        */\r
+       public boolean next() throws SQLException {\r
+               // Method#invoke()でBooleanに自動ラップされている。\r
+               return ((Boolean)clusterCall("next", null, null)).booleanValue();\r
+       }\r
+\r
+\r
+       /**\r
+        * カーソルを現在の位置から 1 行上に移動します。\r
+        * @see java.sql.ResultSet#previous()\r
+        */\r
+       public boolean previous() throws SQLException {\r
+               // Method#invoke()でBooleanに自動ラップされている。\r
+               return ((Boolean)clusterCall("previos", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#rowDeleted()\r
+        */\r
+       public boolean rowDeleted() throws SQLException {\r
+               // Method#invoke()でBooleanに自動ラップされている。\r
+               return ((Boolean)clusterCall("rowDeleted", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#rowInserted()\r
+        */\r
+       public boolean rowInserted() throws SQLException {\r
+               return ((Boolean)clusterCall("rowInserted", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#rowUpdated()\r
+        */\r
+       public boolean rowUpdated() throws SQLException {\r
+               return ((Boolean)clusterCall("rowUpdated", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#wasNull()\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return ((Boolean)clusterCall("wasNull", null, null)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getByte(int)\r
+        */\r
+       public byte getByte(int columnIndex) throws SQLException {\r
+               // Method#invoke()でByteに自動ラップされている。\r
+               return ((Byte)clusterCall("getByte", new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).byteValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDouble(int)\r
+        */\r
+       public double getDouble(int columnIndex) throws SQLException {\r
+               return ((Double)clusterCall("getDouble", new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).doubleValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getFloat(int)\r
+        */\r
+       public float getFloat(int columnIndex) throws SQLException {\r
+               return ((Float)clusterCall("getFloat", new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).floatValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getInt(int)\r
+        */\r
+       public int getInt(int columnIndex) throws SQLException {\r
+               return ((Integer)clusterCall("getInt",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getLong(int)\r
+        */\r
+       public long getLong(int columnIndex) throws SQLException {\r
+               return ((Long)clusterCall("getLong",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).longValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getShort(int)\r
+        */\r
+       public short getShort(int columnIndex) throws SQLException {\r
+               return ((Short)clusterCall("getShort",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).shortValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#setFetchDirection(int)\r
+        */\r
+       public void setFetchDirection(int direction) throws SQLException {\r
+               clusterCall("setFetchDirection",new Object[]{new Integer(direction)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#setFetchSize(int)\r
+        */\r
+       public void setFetchSize(int rows) throws SQLException {\r
+               clusterCall("getDouble",new Object[]{new Integer(rows)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        *\r
+        * @see java.sql.ResultSet#updateNull(int)\r
+        */\r
+       public void updateNull(int columnIndex) throws SQLException {\r
+               clusterCall("getDouble",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#absolute(int)\r
+        */\r
+       public boolean absolute(int row) throws SQLException {\r
+               return ((Boolean)clusterCall("absolute",new Object[]{new Integer(row)}, new Class[]{Integer.TYPE})).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBoolean(int)\r
+        */\r
+       public boolean getBoolean(int columnIndex) throws SQLException {\r
+               return ((Boolean)clusterCall("getBoolean",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE})).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#relative(int)\r
+        */\r
+       public boolean relative(int rows) throws SQLException {\r
+               return ((Boolean)clusterCall("relative",new Object[]{new Integer(rows)}, new Class[]{Integer.TYPE})).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBytes(int)\r
+        */\r
+       public byte[] getBytes(int columnIndex) throws SQLException {\r
+               return (byte[])clusterCall("getBytes",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateByte(int, byte)\r
+        */\r
+       public void updateByte(int columnIndex, byte x) throws SQLException {\r
+               clusterCall("updateByte",new Object[]{new Integer(columnIndex), new Byte[x]}, new Class[]{Integer.TYPE, Byte.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateDouble(int, double)\r
+        */\r
+       public void updateDouble(int columnIndex, double x) throws SQLException {\r
+               clusterCall("updateDouble",new Object[]{new Integer(columnIndex), new Double(x)}, new Class[]{Integer.TYPE, Double.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateFloat(int, float)\r
+        */\r
+       public void updateFloat(int columnIndex, float x) throws SQLException {\r
+               clusterCall("updateFloat",new Object[]{new Integer(columnIndex), new Float(x)}, new Class[]{Integer.TYPE, Float.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateInt(int, int)\r
+        */\r
+       public void updateInt(int columnIndex, int x) throws SQLException {\r
+               clusterCall("updateInt",new Object[]{new Integer(columnIndex), new Integer(x)}, new Class[]{Integer.TYPE, Integer.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateLong(int, long)\r
+        */\r
+       public void updateLong(int columnIndex, long x) throws SQLException {\r
+               clusterCall("updateLong",new Object[]{new Integer(columnIndex), new Long(x)}, new Class[]{Integer.TYPE, Long.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateShort(int, short)\r
+        */\r
+       public void updateShort(int columnIndex, short x) throws SQLException {\r
+               clusterCall("updateShort",new Object[]{new Integer(columnIndex), new Short(x)}, new Class[]{Integer.TYPE, Short.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBoolean(int, boolean)\r
+        */\r
+       public void updateBoolean(int columnIndex, boolean x) throws SQLException {\r
+               clusterCall("updateBoolean",new Object[]{new Integer(columnIndex), new Boolean(x)}, new Class[]{Integer.TYPE, Boolean.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBytes(int, byte[])\r
+        */\r
+       public void updateBytes(int columnIndex, byte[] x) throws SQLException {\r
+               clusterCall("updateBytes",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, byte[].class});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getAsciiStream(int)\r
+        */\r
+       public InputStream getAsciiStream(int columnIndex) throws SQLException {\r
+               return (InputStream)clusterCall("getAsciiStream",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBinaryStream(int)\r
+        */\r
+       public InputStream getBinaryStream(int columnIndex) throws SQLException {\r
+               return (InputStream)clusterCall("getBinaryStream",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @deprecated\r
+        * @see java.sql.ResultSet#getUnicodeStream(int)\r
+        */\r
+       public InputStream getUnicodeStream(int columnIndex) throws SQLException {\r
+               return (InputStream)clusterCall("getUnicodeStream",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, int)\r
+        */\r
+       public void updateAsciiStream(int columnIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("updateAsciiStream",new Object[]{new Integer(columnIndex), x, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, int)\r
+        */\r
+       public void updateBinaryStream(int columnIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("updateBinaryStream",new Object[]{new Integer(columnIndex), x, new Integer(length)},\r
+                               new Class[]{Integer.TYPE, InputStream.class, Integer.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getCharacterStream(int)\r
+        */\r
+       public Reader getCharacterStream(int columnIndex) throws SQLException {\r
+               return (Reader)clusterCall("getCharacterStream",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, int)\r
+        */\r
+       public void updateCharacterStream(int columnIndex, Reader x, int length)\r
+               throws SQLException {\r
+               clusterCall("updateCharacterStream",new Object[]{new Integer(columnIndex), x, new Integer(length)}, new Class[]{Integer.TYPE, Reader.class, Integer.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getObject(int)\r
+        */\r
+       public Object getObject(int columnIndex) throws SQLException {\r
+               return clusterCall("getObject",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateObject(int, java.lang.Object)\r
+        */\r
+       public void updateObject(int columnIndex, Object x) throws SQLException {\r
+               clusterCall("updateObject",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Object.class});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateObject(int, java.lang.Object, int)\r
+        */\r
+       public void updateObject(int columnIndex, Object x, int scale)\r
+               throws SQLException {\r
+               clusterCall("updateObject",new Object[]{new Integer(columnIndex), x, new Integer(scale)},\r
+                               new Class[]{Integer.TYPE, Object.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getCursorName()\r
+        */\r
+       public String getCursorName() throws SQLException {\r
+               return (String)clusterCall("getCursorName", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getString(int)\r
+        */\r
+       public String getString(int columnIndex) throws SQLException {\r
+               return (String)clusterCall("getString",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateString(int, java.lang.String)\r
+        */\r
+       public void updateString(int columnIndex, String x) throws SQLException {\r
+               clusterCall("updateString",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getByte(java.lang.String)\r
+        */\r
+       public byte getByte(String columnName) throws SQLException {\r
+               return ((Byte)clusterCall("getByte",new Object[]{columnName}, new Class[]{String.class})).byteValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDouble(java.lang.String)\r
+        */\r
+       public double getDouble(String columnName) throws SQLException {\r
+               return ((Double)clusterCall("getDouble",new Object[]{columnName}, new Class[]{String.class})).doubleValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getFloat(java.lang.String)\r
+        */\r
+       public float getFloat(String columnName) throws SQLException {\r
+               return ((Float)clusterCall("getFloat",new Object[]{columnName}, new Class[]{String.class})).floatValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#findColumn(java.lang.String)\r
+        */\r
+       public int findColumn(String columnName) throws SQLException {\r
+               return ((Integer)clusterCall("findColumn",new Object[]{columnName}, new Class[]{String.class})).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getInt(java.lang.String)\r
+        */\r
+       public int getInt(String columnName) throws SQLException {\r
+               return ((Integer)clusterCall("getInt",new Object[]{columnName}, new Class[]{String.class})).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getLong(java.lang.String)\r
+        */\r
+       public long getLong(String columnName) throws SQLException {\r
+               return ((Long)clusterCall("getLong",new Object[]{columnName}, new Class[]{String.class})).longValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getShort(java.lang.String)\r
+        */\r
+       public short getShort(String columnName) throws SQLException {\r
+               return ((Short)clusterCall("getShort",new Object[]{columnName}, new Class[]{String.class})).shortValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateNull(java.lang.String)\r
+        */\r
+       public void updateNull(String columnName) throws SQLException {\r
+               clusterCall("updateNull",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBoolean(java.lang.String)\r
+        */\r
+       public boolean getBoolean(String columnName) throws SQLException {\r
+               return ((Boolean)clusterCall("getBoolean",new Object[]{columnName}, new Class[]{String.class})).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBytes(java.lang.String)\r
+        */\r
+       public byte[] getBytes(String columnName) throws SQLException {\r
+               return (byte[])clusterCall("getBytes",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateByte(java.lang.String, byte)\r
+        */\r
+       public void updateByte(String columnName, byte x) throws SQLException {\r
+               clusterCall("updateByte",new Object[]{columnName, new Byte(x)}, new Class[]{String.class, Byte.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateDouble(java.lang.String, double)\r
+        */\r
+       public void updateDouble(String columnName, double x) throws SQLException {\r
+               clusterCall("updateDouble",new Object[]{columnName, new Double(x)}, new Class[]{String.class, Double.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateFloat(java.lang.String, float)\r
+        */\r
+       public void updateFloat(String columnName, float x) throws SQLException {\r
+               clusterCall("updateFloat",new Object[]{columnName, new Float(x)}, new Class[]{String.class, Float.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateInt(java.lang.String, int)\r
+        */\r
+       public void updateInt(String columnName, int x) throws SQLException {\r
+               clusterCall("updateInt",new Object[]{columnName, new Integer(x)}, new Class[]{String.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateLong(java.lang.String, long)\r
+        */\r
+       public void updateLong(String columnName, long x) throws SQLException {\r
+               clusterCall("updateLong",new Object[]{columnName, new Long(x)}, new Class[]{String.class, Long.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateShort(java.lang.String, short)\r
+        */\r
+       public void updateShort(String columnName, short x) throws SQLException {\r
+               clusterCall("updateShort",new Object[]{columnName, new Short(x)}, new Class[]{String.class, Short.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBoolean(java.lang.String, boolean)\r
+        */\r
+       public void updateBoolean(String columnName, boolean x)\r
+               throws SQLException {\r
+               clusterCall("updateBoolean",new Object[]{columnName, new Boolean(x)}, new Class[]{String.class, Boolean.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBytes(java.lang.String, byte[])\r
+        */\r
+       public void updateBytes(String columnName, byte[] x) throws SQLException {\r
+               clusterCall("updateBytes",new Object[]{columnName, x}, new Class[]{String.class, byte[].class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBigDecimal(int)\r
+        */\r
+       public BigDecimal getBigDecimal(int columnIndex) throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @deprecated\r
+        * @see java.sql.ResultSet#getBigDecimal(int, int)\r
+        */\r
+       public BigDecimal getBigDecimal(int columnIndex, int scale)\r
+               throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal",new Object[]{new Integer(columnIndex), new Integer(scale)}, new Class[]{Integer.TYPE, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBigDecimal(int, java.math.BigDecimal)\r
+        */\r
+       public void updateBigDecimal(int columnIndex, BigDecimal x)\r
+               throws SQLException {\r
+               clusterCall("updateBytes",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, BigDecimal.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getURL(int)\r
+        */\r
+       public URL getURL(int columnIndex) throws SQLException {\r
+               return (URL)clusterCall("getURL",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getArray(int)\r
+        */\r
+       public Array getArray(int i) throws SQLException {\r
+               return (Array)clusterCall("getArray",new Object[]{new Integer(i)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateArray(int, java.sql.Array)\r
+        */\r
+       public void updateArray(int columnIndex, Array x) throws SQLException {\r
+               clusterCall("updateArray",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Array.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBlob(int)\r
+        */\r
+       public Blob getBlob(int i) throws SQLException {\r
+               return (Blob)clusterCall("getBlob",new Object[]{new Integer(i)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBlob(int, java.sql.Blob)\r
+        */\r
+       public void updateBlob(int columnIndex, Blob x) throws SQLException {\r
+               clusterCall("updateBlob",new Object[]{new Integer(columnIndex), x}, new Class[]{Blob.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getClob(int)\r
+        */\r
+       public Clob getClob(int i) throws SQLException {\r
+               return (Clob)clusterCall("getClob",new Object[]{new Integer(i)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateClob(int, java.sql.Clob)\r
+        */\r
+       public void updateClob(int columnIndex, Clob x) throws SQLException {\r
+               clusterCall("updateClob",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Clob.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDate(int)\r
+        */\r
+       public Date getDate(int columnIndex) throws SQLException {\r
+               return (Date)clusterCall("getDate",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateDate(int, java.sql.Date)\r
+        */\r
+       public void updateDate(int columnIndex, Date x) throws SQLException {\r
+               clusterCall("updateDate",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Date.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getRef(int)\r
+        */\r
+       public Ref getRef(int i) throws SQLException {\r
+               return (Ref)clusterCall("getRef",new Object[]{new Integer(i)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateRef(int, java.sql.Ref)\r
+        */\r
+       public void updateRef(int columnIndex, Ref x) throws SQLException {\r
+               clusterCall("updateRef",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Ref.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getMetaData()\r
+        */\r
+       public ResultSetMetaData getMetaData() throws SQLException {\r
+               return (ResultSetMetaData)clusterCall("getMetaData", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return (SQLWarning)clusterCall("getWarnings", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getStatement()\r
+        */\r
+       public Statement getStatement() throws SQLException {\r
+               return (Statement)clusterCall("getStatement", null, null);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTime(int)\r
+        */\r
+       public Time getTime(int columnIndex) throws SQLException {\r
+               return (Time)clusterCall("getTime",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateTime(int, java.sql.Time)\r
+        */\r
+       public void updateTime(int columnIndex, Time x) throws SQLException {\r
+               clusterCall("updateTime",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE, Time.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTimestamp(int)\r
+        */\r
+       public Timestamp getTimestamp(int columnIndex) throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp",new Object[]{new Integer(columnIndex)}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateTimestamp(int, java.sql.Timestamp)\r
+        */\r
+       public void updateTimestamp(int columnIndex, Timestamp x)\r
+               throws SQLException {\r
+               clusterCall("updateTimestamp",new Object[]{new Integer(columnIndex), x}, new Class[]{Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getAsciiStream(java.lang.String)\r
+        */\r
+       public InputStream getAsciiStream(String columnName) throws SQLException {\r
+               return (InputStream)clusterCall("getAsciiStream",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBinaryStream(java.lang.String)\r
+        */\r
+       public InputStream getBinaryStream(String columnName) throws SQLException {\r
+               return (InputStream)clusterCall("getBinaryStream",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @deprecated\r
+        * @see java.sql.ResultSet#getUnicodeStream(java.lang.String)\r
+        */\r
+       public InputStream getUnicodeStream(String columnName)\r
+               throws SQLException {\r
+               return (InputStream)clusterCall("getUnicodeStream",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void updateAsciiStream(String columnName, InputStream x, int length)\r
+               throws SQLException {\r
+               clusterCall("updateAsciiStream",new Object[]{columnName, x, new Integer(length)}, new Class[]{String.class, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void updateBinaryStream(\r
+               String columnName,\r
+               InputStream x,\r
+               int length)\r
+               throws SQLException {\r
+               clusterCall("updateBinaryStream",new Object[]{columnName, x, new Integer(length)}, new Class[]{String.class, InputStream.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getCharacterStream(String columnName) throws SQLException {\r
+               return (Reader)clusterCall("getCharacterStream",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, int)\r
+        */\r
+       public void updateCharacterStream(\r
+               String columnName,\r
+               Reader reader,\r
+               int length)\r
+               throws SQLException {\r
+               clusterCall("updateCharacterStream",new Object[]{columnName, reader, new Integer(length)}, new Class[]{String.class, Reader.class, Integer.TYPE});\r
+\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getObject(java.lang.String)\r
+        */\r
+       public Object getObject(String columnName) throws SQLException {\r
+               return clusterCall("getObject",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object)\r
+        */\r
+       public void updateObject(String columnName, Object x) throws SQLException {\r
+               clusterCall("updateObject",new Object[]{columnName, x}, new Class[]{String.class, Object.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateObject(java.lang.String, java.lang.Object, int)\r
+        */\r
+       public void updateObject(String columnName, Object x, int scale)\r
+               throws SQLException {\r
+               clusterCall("updateObject",new Object[]{columnName, x, new Integer(scale)}, new Class[]{String.class, Object.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @throws SQLException\r
+        * @see java.sql.ResultSet#getObject(int, java.util.Map)\r
+        */\r
+       //@Override\r
+       public Object getObject(int i, Map<String, Class<?>> map) throws SQLException{\r
+               return clusterCall("getObject",new Object[]{new Integer(i), map}, new Class[]{Integer.TYPE, Map.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getString(java.lang.String)\r
+        */\r
+       public String getString(String columnName) throws SQLException {\r
+               return (String)clusterCall("getString",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateString(java.lang.String, java.lang.String)\r
+        */\r
+       public void updateString(String columnName, String x) throws SQLException {\r
+               clusterCall("updateString",new Object[]{columnName, x}, new Class[]{String.class, String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBigDecimal(java.lang.String)\r
+        */\r
+       public BigDecimal getBigDecimal(String columnName) throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @deprecated\r
+        * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int)\r
+        */\r
+       public BigDecimal getBigDecimal(String columnName, int scale)\r
+               throws SQLException {\r
+               return (BigDecimal)clusterCall("getBigDecimal",new Object[]{columnName, new Integer(scale)}, new Class[]{String.class, Integer.TYPE});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBigDecimal(java.lang.String, java.math.BigDecimal)\r
+        */\r
+       public void updateBigDecimal(String columnName, BigDecimal x)\r
+               throws SQLException {\r
+               clusterCall("updateBigDecimal",new Object[]{columnName, x}, new Class[]{String.class, BigDecimal.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getURL(java.lang.String)\r
+        */\r
+       public URL getURL(String columnName) throws SQLException {\r
+               return (URL)clusterCall("getURL",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getArray(java.lang.String)\r
+        */\r
+       public Array getArray(String columnName) throws SQLException {\r
+               return (Array)clusterCall("getArray",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateArray(java.lang.String, java.sql.Array)\r
+        */\r
+       public void updateArray(String columnName, Array x) throws SQLException {\r
+               clusterCall("updateArray",new Object[]{columnName, x}, new Class[]{String.class, Array.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getBlob(java.lang.String)\r
+        */\r
+       public Blob getBlob(String columnName) throws SQLException {\r
+               return (Blob)clusterCall("getBlob",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void updateBlob(String columnName, Blob x) throws SQLException {\r
+               clusterCall("updateBlob",new Object[]{columnName, x}, new Class[]{String.class, Blob.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getClob(java.lang.String)\r
+        */\r
+       public Clob getClob(String columnName) throws SQLException {\r
+               return (Clob)clusterCall("getClob",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateClob(java.lang.String, java.sql.Clob)\r
+        */\r
+       public void updateClob(String columnName, Clob x) throws SQLException {\r
+               clusterCall("updateClob",new Object[]{columnName, x}, new Class[]{String.class, Clob.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDate(java.lang.String)\r
+        */\r
+       public Date getDate(String columnName) throws SQLException {\r
+               return (Date)clusterCall("getDate",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateDate(java.lang.String, java.sql.Date)\r
+        */\r
+       public void updateDate(String columnName, Date x) throws SQLException {\r
+               clusterCall("updateDate",new Object[]{columnName, x}, new Class[]{String.class, Date.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDate(int, java.util.Calendar)\r
+        */\r
+       public Date getDate(int columnIndex, Calendar cal) throws SQLException {\r
+               return (Date)clusterCall("getDate",new Object[]{new Integer(columnIndex), cal}, new Class[]{String.class, Calendar.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getRef(java.lang.String)\r
+        */\r
+       public Ref getRef(String columnName) throws SQLException {\r
+               return (Ref)clusterCall("getRef",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateRef(java.lang.String, java.sql.Ref)\r
+        */\r
+       public void updateRef(String columnName, Ref x) throws SQLException {\r
+               clusterCall("updateRef",new Object[]{columnName, x}, new Class[]{String.class, Ref.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTime(java.lang.String)\r
+        */\r
+       public Time getTime(String columnName) throws SQLException {\r
+               return (Time)clusterCall("getTime",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateTime(java.lang.String, java.sql.Time)\r
+        */\r
+       public void updateTime(String columnName, Time x) throws SQLException {\r
+               clusterCall("updateTime",new Object[]{columnName, x}, new Class[]{String.class, Time.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTime(int, java.util.Calendar)\r
+        */\r
+       public Time getTime(int columnIndex, Calendar cal) throws SQLException {\r
+               return (Time)clusterCall("getTime",new Object[]{new Integer(columnIndex), cal}, new Class[]{String.class, Calendar.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTimestamp(java.lang.String)\r
+        */\r
+       public Timestamp getTimestamp(String columnName) throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp",new Object[]{columnName}, new Class[]{String.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#updateTimestamp(java.lang.String, java.sql.Timestamp)\r
+        */\r
+       public void updateTimestamp(String columnName, Timestamp x)\r
+               throws SQLException {\r
+               clusterCall("updateTimestamp",new Object[]{columnName, x}, new Class[]{String.class, Timestamp.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTimestamp(int, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(int columnIndex, Calendar cal)\r
+               throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp",new Object[]{new Integer(columnIndex), cal}, new Class[]{Integer.TYPE, Calendar.class});\r
+       }\r
+\r
+       /**\r
+        * @throws SQLException\r
+        * @see java.sql.ResultSet#getObject(java.lang.String, java.util.Map)\r
+        */\r
+       //@Override\r
+       public Object getObject(String columnName, Map<String, Class<?>> map) throws SQLException{\r
+               return clusterCall("getObject",new Object[]{columnName, map}, new Class[]{String.class, Map.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Date getDate(String columnName, Calendar cal) throws SQLException {\r
+               return (Date)clusterCall("getDate",new Object[]{columnName, cal}, new Class[]{String.class, Calendar.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTime(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Time getTime(String columnName, Calendar cal) throws SQLException {\r
+               return (Time)clusterCall("getTime",new Object[]{columnName, cal}, new Class[]{String.class, Calendar.class});\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.ResultSet#getTimestamp(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(String columnName, Calendar cal)\r
+               throws SQLException {\r
+               return (Timestamp)clusterCall("getTimestamp",new Object[]{columnName, cal}, new Class[]{String.class, Calendar.class});\r
+       }\r
+\r
+       // ----\r
+       // 以下未実装\r
+       // ----\r
+\r
+       //@Override\r
+       public Reader getNCharacterStream(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public Reader getNCharacterStream(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public NClob getNClob(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public NClob getNClob(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public String getNString(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public String getNString(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public RowId getRowId(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public RowId getRowId(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public SQLXML getSQLXML(int arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public SQLXML getSQLXML(String arg0) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public boolean isClosed() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return false;\r
+       }\r
+\r
+       //@Override\r
+       public void updateAsciiStream(int arg0, InputStream arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateAsciiStream(String arg0, InputStream arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateAsciiStream(int arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateAsciiStream(String arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBinaryStream(int arg0, InputStream arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBinaryStream(String arg0, InputStream arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBinaryStream(int arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBinaryStream(String arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBlob(int arg0, InputStream arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBlob(String arg0, InputStream arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBlob(int arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateBlob(String arg0, InputStream arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateCharacterStream(int arg0, Reader arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateCharacterStream(String arg0, Reader arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateCharacterStream(int arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateCharacterStream(String arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateClob(int arg0, Reader arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateClob(String arg0, Reader arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateClob(int arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateClob(String arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNCharacterStream(int arg0, Reader arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNCharacterStream(String arg0, Reader arg1)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNCharacterStream(int arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNCharacterStream(String arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(int arg0, NClob arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(String arg0, NClob arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(int arg0, Reader arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(String arg0, Reader arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(int arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNClob(String arg0, Reader arg1, long arg2)\r
+                       throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNString(int arg0, String arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateNString(String arg0, String arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateRowId(int arg0, RowId arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateRowId(String arg0, RowId arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+\r
+       }\r
+\r
+       //@Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return false;\r
+       }\r
+\r
+       //@Override\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return null;\r
+       }\r
+\r
+       //@Override\r
+       public int getHoldability() throws SQLException {\r
+               // TODO 自動生成されたメソッド・スタブ\r
+               return 0;\r
+       }\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterStatement.java b/src/com/lavans/luz2/sql/cluster/ClusterStatement.java
new file mode 100644 (file)
index 0000000..63a9235
--- /dev/null
@@ -0,0 +1,464 @@
+/* $Id: ClusterStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/09/15\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.Statement;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class ClusterStatement implements Statement, ClusterStatementInterface{\r
+       /** Messageクラスに移動? */\r
+       protected static final String MSG_ERR_REUPDATE="Statementの再生成に失敗。";\r
+       protected static final String MSG_WARN_SWITCH_DB="障害が出たので接続先を切り替えます。";\r
+\r
+       /** 処理移譲先。 */\r
+       private Statement st=null;\r
+\r
+       /** コネクション。障害時に別のStaementを作るよう依頼する。 */\r
+       private ClusterConnection con = null;\r
+\r
+       /**\r
+        * 保存しておくメソッドのリスト。\r
+        * 障害が発生した場合、ClusterPreparedStatementに対する操作を操作が行われた\r
+        * 順序どおりに再実行する必要がある。\r
+        */\r
+       private List<CalledMethod> methodList = null;\r
+\r
+       /** 実行されたsql文。障害時にResultSetを再生成するのに必要。 */\r
+       private String sql = null;\r
+\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(ClusterStatement.class);\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param st\r
+        */\r
+       public ClusterStatement(ClusterConnection con, Statement st){\r
+               this.con = con;\r
+               this.st = st;\r
+               methodList = new ArrayList<CalledMethod>();\r
+       }\r
+\r
+       /**\r
+        * DB切替時、新たに取得したStatementに対して\r
+        * 更新処理を再実行する。\r
+        * @param\r
+        */\r
+       public void reupdateStatement(Statement st) throws SQLException{\r
+               try { this.st.close(); } catch (SQLException se) {}\r
+               this.st = st;\r
+\r
+               for(int i=0; i<methodList.size(); i++){\r
+                       CalledMethod calledMethod = methodList.get(i);\r
+                       try{\r
+                               calledMethod.invoke(st);        // 戻り値は無視して良い\r
+                       }catch (Exception e) {\r
+                               logger.error("reupdate failed",e);\r
+                               throw new SQLException(MSG_ERR_REUPDATE);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * クラスタリング対応のメソッド実行処理。\r
+        * @param methodName\r
+        * @param args\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Object clusterCall(String methodName, Object[] args, Class<?>[] parameterTypes, boolean saveMethod) throws SQLException{\r
+               Object result = null;\r
+               CalledMethod calledMethod = new CalledMethod(methodName, args, parameterTypes);\r
+\r
+               logger.debug(calledMethod.toString());\r
+\r
+               try{\r
+                       result = calledMethod.invoke(st);\r
+               }catch (Exception e) {\r
+                       logger.warn(MSG_WARN_SWITCH_DB, e);\r
+                       // try { st.close(); } catch (SQLException se) {}\r
+                       con.notifyError(this);  // エラーを通知。ここでstは新しいものになっているはず。\r
+                       try{\r
+                               // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。\r
+                               result = calledMethod.invoke(st);\r
+                       }catch (InvocationTargetException e2) {\r
+                               // 例外がSQLExceptionならそのままthrow\r
+                               Throwable t = e2.getTargetException();\r
+                               if(t instanceof SQLException){\r
+                                       throw (SQLException)t;\r
+                               }\r
+                               // それ以外ならwrapしてthrow\r
+                               SQLException sqle = new SQLException();\r
+                               sqle.initCause(e2.getTargetException());\r
+                               throw sqle;\r
+                       }catch (Exception e2) {\r
+                               SQLException sqle = new SQLException();\r
+                               sqle.initCause(e2);\r
+                               throw sqle;\r
+                       }\r
+               }\r
+               if(saveMethod){\r
+                       methodList.add(calledMethod);\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeQuery(java.lang.String)\r
+        */\r
+       public ResultSet getAnotherResultSet() throws SQLException {\r
+               logger.debug("Redo st.executeQuery and get ResultSet.\n"+ sql);\r
+\r
+               // resultSet内で障害を検知したので、再度コネクションを張り直す。\r
+               con.notifyError(this);  // エラーを通知。ここでstは新しいものになっているはず。\r
+               ResultSet rs = st.executeQuery(sql);\r
+\r
+               return rs;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeQuery(java.lang.String)\r
+        */\r
+       public ResultSet executeQuery(String sql) throws SQLException {\r
+               ResultSet rs = (ResultSet)clusterCall("executeQuery", new Object[]{sql}, new Class[]{String.class}, true);\r
+\r
+               return new ClusterResultSet(this,rs);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String)\r
+        */\r
+       public int executeUpdate(String sql) throws SQLException {\r
+               return ((Integer)clusterCall("executeUpdate", new Object[]{sql}, new Class[]{String.class}, true)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int)\r
+        */\r
+       public int executeUpdate(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               return ((Integer)clusterCall("executeUpdate", new Object[]{sql, new Integer(autoGeneratedKeys)},\r
+                               new Class[]{String.class, Integer.TYPE}, true)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int[])\r
+        */\r
+       public int executeUpdate(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               return ((Integer)clusterCall("executeUpdate", new Object[]{sql, columnIndexes},\r
+                               new Class[]{String.class, int[].class}, true)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])\r
+        */\r
+       public int executeUpdate(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               return ((Integer)clusterCall("executeUpdate", new Object[]{sql, columnNames},\r
+                                new Class[]{String.class, String[].class}, true)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int)\r
+        */\r
+       public boolean execute(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               return ((Boolean)clusterCall("execute", new Object[]{sql, new Integer(autoGeneratedKeys)},\r
+                                new Class[]{String.class, Integer.TYPE}, true)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String)\r
+        */\r
+       public boolean execute(String sql) throws SQLException {\r
+               return ((Boolean)clusterCall("execute", new Object[]{sql},\r
+                                new Class[]{String.class}, true)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int[])\r
+        */\r
+       public boolean execute(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+                       return ((Boolean)clusterCall("execute", new Object[]{sql, columnIndexes},\r
+                                        new Class[]{String.class, int[].class}, true)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])\r
+        */\r
+       public boolean execute(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               return ((Boolean)clusterCall("execute", new Object[]{sql, columnNames},\r
+                                new Class[]{String.class, String[].class}, true)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getFetchDirection()\r
+        */\r
+       public int getFetchDirection() throws SQLException {\r
+               return ((Integer)clusterCall("getFetchDirection", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getFetchSize()\r
+        */\r
+       public int getFetchSize() throws SQLException {\r
+               return ((Integer)clusterCall("getFetchSize", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getMaxFieldSize()\r
+        */\r
+       public int getMaxFieldSize() throws SQLException {\r
+               return ((Integer)clusterCall("getMaxFieldSize", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getMaxRows()\r
+        */\r
+       public int getMaxRows() throws SQLException {\r
+               return ((Integer)clusterCall("getMaxRows", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getQueryTimeout()\r
+        */\r
+       public int getQueryTimeout() throws SQLException {\r
+               return ((Integer)clusterCall("getQueryTimeout", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getResultSetConcurrency()\r
+        */\r
+       public int getResultSetConcurrency() throws SQLException {\r
+               return ((Integer)clusterCall("getResultSetConcurrency", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getResultSetHoldability()\r
+        */\r
+       public int getResultSetHoldability() throws SQLException {\r
+               return ((Integer)clusterCall("getResultSetConcurrency", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getResultSetType()\r
+        */\r
+       public int getResultSetType() throws SQLException {\r
+               return ((Integer)clusterCall("getResultSetType", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getUpdateCount()\r
+        */\r
+       public int getUpdateCount() throws SQLException {\r
+               return ((Integer)clusterCall("getUpdateCount", null, null, false)).intValue();\r
+       }\r
+\r
+       /**\r
+        *\r
+        * @see java.sql.Statement#cancel()\r
+        */\r
+       public void cancel() throws SQLException {\r
+               clusterCall("cancel", null, null, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#clearBatch()\r
+        */\r
+       public void clearBatch() throws SQLException {\r
+               clusterCall("clearBatch", null, null, true);\r
+               st.clearBatch();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               clusterCall("clearWarnings", null, null, true);\r
+               st.clearWarnings();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               clusterCall("close", null, null, true);\r
+               st.close();\r
+               con.remove(this);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getMoreResults()\r
+        */\r
+       public boolean getMoreResults() throws SQLException {\r
+               return ((Boolean)clusterCall("getMoreResults", null, null, false)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeBatch()\r
+        */\r
+       public int[] executeBatch() throws SQLException {\r
+               return (int[])clusterCall("executeBatch", null, null, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setFetchDirection(int)\r
+        */\r
+       public void setFetchDirection(int direction) throws SQLException {\r
+               clusterCall("setFetchDirection", new Object[]{new Integer(direction)}, new Class[]{Integer.TYPE}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setFetchSize(int)\r
+        */\r
+       public void setFetchSize(int rows) throws SQLException {\r
+               clusterCall("setFetchSize", new Object[]{new Integer(rows)}, new Class[]{Integer.TYPE}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setMaxFieldSize(int)\r
+        */\r
+       public void setMaxFieldSize(int max) throws SQLException {\r
+               clusterCall("setMaxFieldSize", new Object[]{new Integer(max)}, new Class[]{Integer.TYPE}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setMaxRows(int)\r
+        */\r
+       public void setMaxRows(int max) throws SQLException {\r
+               clusterCall("setMaxRows", new Object[]{new Integer(max)}, new Class[]{Integer.TYPE}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setQueryTimeout(int)\r
+        */\r
+       public void setQueryTimeout(int seconds) throws SQLException {\r
+               clusterCall("setQueryTimeout", new Object[]{new Integer(seconds)}, new Class[]{Integer.TYPE}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getMoreResults(int)\r
+        */\r
+       public boolean getMoreResults(int current) throws SQLException {\r
+               return ((Boolean)clusterCall("getMoreResults",  new Object[]{new Integer(current)}, new Class[]{Integer.TYPE}, false)).booleanValue();\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setEscapeProcessing(boolean)\r
+        */\r
+       public void setEscapeProcessing(boolean enable) throws SQLException {\r
+               clusterCall("setFetchDirection", new Object[]{new Boolean(enable)}, new Class[]{Boolean.TYPE}, true);\r
+       }\r
+\r
+\r
+       /**\r
+        * @see java.sql.Statement#addBatch(java.lang.String)\r
+        */\r
+       public void addBatch(String sql) throws SQLException {\r
+               clusterCall("addBatch", new Object[]{sql}, new Class[]{String.class}, true);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#setCursorName(java.lang.String)\r
+        */\r
+       public void setCursorName(String name) throws SQLException {\r
+               clusterCall("setCursorName", new Object[]{name}, new Class[]{String.class}, true);\r
+       }\r
+\r
+\r
+       /**\r
+        * @see java.sql.Statement#getConnection()\r
+        */\r
+       public Connection getConnection() throws SQLException {\r
+               return con;\r
+//             return (Connection)clusterCall("getConnection",  null, false);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getGeneratedKeys()\r
+        */\r
+       public ResultSet getGeneratedKeys() throws SQLException {\r
+               return (ResultSet)clusterCall("getGeneratedKeys", null, null, false);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getResultSet()\r
+        */\r
+       public ResultSet getResultSet() throws SQLException {\r
+               return (ResultSet)clusterCall("getResultSet", null, null, false);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return (SQLWarning)clusterCall("getWarnings", null, null, false);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return st.isClosed();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isPoolable()\r
+        */\r
+       public boolean isPoolable() throws SQLException {\r
+               return st.isPoolable();\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param poolable\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#setPoolable(boolean)\r
+        */\r
+       public void setPoolable(boolean poolable) throws SQLException {\r
+               st.setPoolable(poolable);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/cluster/ClusterStatementInterface.java b/src/com/lavans/luz2/sql/cluster/ClusterStatementInterface.java
new file mode 100644 (file)
index 0000000..936f49f
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id: ClusterStatementInterface.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/28\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.cluster;\r
+\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.Statement;\r
+\r
+/**\r
+ * Cluster関係のStatementサブクラスが実装しなければならないインターフェース。\r
+ * DB切替の際にResultSetを再発行するので、各サブクラスでこれをオーバーライドして\r
+ * 再度ResultSetを生成できるようにしておかなければならない。\r
+ * \r
+ * 本インターフェースの名前をClusterStatementにして、実装クラスをClusterStatementImpl\r
+ * にした方が良いか?\r
+ * \r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public interface ClusterStatementInterface {\r
+       ResultSet getAnotherResultSet() throws SQLException;\r
+       public void reupdateStatement(Statement st) throws SQLException;\r
+}\r
diff --git a/src/com/lavans/luz2/sql/dao/CommonDao.java b/src/com/lavans/luz2/sql/dao/CommonDao.java
new file mode 100644 (file)
index 0000000..216c421
--- /dev/null
@@ -0,0 +1,241 @@
+package com.lavans.luz2.sql.dao;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.ClassUtils;\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.sql.DBManager;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+import com.lavans.luz2.util.PageInfo;\r
+import com.lavans.luz2.util.Pager;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ *\r
+ * @param <T>\r
+ */\r
+public class CommonDao{\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(CommonDao.class);\r
+       /** default connection name */\r
+       private static final String DEFALUT_CONNECTION = "default";\r
+       //, seq;\r
+       /**\r
+        * Constructor.\r
+        */\r
+       public  CommonDao(){\r
+       }\r
+\r
+       /**\r
+        * Executes the given SQL statement, which returns ResultSet object. This method convert ResultSet to List<Map<String, Object>>\r
+        *\r
+        * @return converted data.\r
+        */\r
+       public List<Map<String, Object>> executeQuery(String sql) throws SQLException {\r
+               return executeQuery(sql, null, DEFALUT_CONNECTION);\r
+       }\r
+       public List<Map<String, Object>> executeQuery(String sql, Map<String, Object> params) throws SQLException {\r
+               return executeQuery(sql, params, DEFALUT_CONNECTION);\r
+       }\r
+       public List<Map<String, Object>> executeQuery(String sql, Map<String, Object> params, String connectionName) throws SQLException {\r
+               logger.debug(sql);\r
+               List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       ResultSet rs = st.executeQuery();\r
+                       result = rsToMapList(rs);\r
+                       logger.debug("result count = "+ result.size());\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * ResultSetからList<Map<String, Object>>に変換\r
+        * @param rs\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private List<Map<String, Object>> rsToMapList(ResultSet rs) throws SQLException{\r
+               List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();\r
+               while (rs.next()) {\r
+                       Map<String, Object> record = new LinkedHashMap<String, Object>();\r
+                       ResultSetMetaData metaData = rs.getMetaData();\r
+                       for(int i=1; i<metaData.getColumnCount()+1; i++){\r
+                               record.put(metaData.getColumnName(i), rs.getObject(i));\r
+                       }\r
+                       result.add(record);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        *  Executes the given SQL statement, which returns effective rows(INSERT/DELETE/UPDATE) or returns nothing(DDL);\r
+        */\r
+       public int executeUpdate(String sql, Map<String, Object> params) throws SQLException {\r
+               return executeUpdate(sql, params, DEFALUT_CONNECTION);\r
+       }\r
+       public int executeUpdate(String sql, Map<String, Object> params, String connectionName) throws SQLException {\r
+               logger.debug(sql);\r
+               int result = -1;\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       result = st.executeUpdate();\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        *\r
+        *\r
+        * @return\r
+        * @throws SQLException\r
+        * @throws InvocationTargetException\r
+        * @throws NoSuchMethodException\r
+        * @throws IllegalAccessException\r
+        * @throws InstantiationException\r
+        */\r
+       public <T> List<T> list(Class<T> clazz, String sql, Map<String, Object> params) throws SQLException {\r
+               return list(clazz, sql, params, DEFALUT_CONNECTION);\r
+       }\r
+       public <T> List<T> list(Class<T> clazz, String sql, Map<String, Object> params, String connectionName) throws SQLException {\r
+               if(StringUtils.isEmpty(sql)){\r
+                       throw new SQLException("sql is empty["+ sql +"]");\r
+               }\r
+\r
+               // execute sql\r
+               List<Map<String, Object>> list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               List<T> resultList = new ArrayList<T>();\r
+               for(Map<String, Object> dataMap: list){\r
+                       resultList.add(mapToEntity(dataMap, clazz));\r
+               }\r
+               return resultList;\r
+       }\r
+\r
+       /**\r
+        * list for pager.\r
+        * You have to insert ":offset" and ":limit" like this:\r
+        * "SELECT * FROM MEMBER OFFSET :offset LIMIT :limit".\r
+        *\r
+        * @param <T>\r
+        * @param countSql      SQL string for count all.\r
+        * @param pageInfo\r
+        * @param sql           SQL string for select.\r
+        * @param params\r
+        * @return\r
+        * @throws SQLException\r
+        * @throws InvocationTargetException\r
+        * @throws NoSuchMethodException\r
+        * @throws IllegalAccessException\r
+        * @throws InstantiationException\r
+        */\r
+       public <T> Pager<T> list(Class<T> clazz, String countSql, PageInfo pageInfo, String sql, Map<String, Object> params) throws SQLException{\r
+               return list(clazz, countSql, pageInfo, sql, params, DEFALUT_CONNECTION);\r
+       }\r
+       public <T> Pager<T> list(Class<T> clazz, String countSql, PageInfo pageInfo, String sql, Map<String, Object> params, String connectionName) throws SQLException {\r
+               // execute count sql\r
+               List<Map<String, Object>> list = executeQuery(sql);\r
+               int count = (Integer)list.get(0).values().toArray()[0];\r
+\r
+               // make select sql\r
+               int start = pageInfo.getPage() * pageInfo.getRows();\r
+               sql.replace(":offset", String.valueOf(start));\r
+               sql.replace(":limit",  String.valueOf(pageInfo.getRows()));\r
+               // これでもいける?\r
+//             params.put(":offset", start);\r
+//             params.put(":limit", pageInfo.getRows());\r
+\r
+               // execute sql\r
+               list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               Pager<T> pager = new Pager<T>(pageInfo);\r
+               pager.setTotalCount(count);\r
+               for(Map<String, Object> dataMap: list){\r
+                       pager.add(mapToEntity(dataMap, clazz));\r
+               }\r
+               return pager;\r
+       }\r
+\r
+       /**\r
+        * SQLから呼び出した汎用Map<String, Object>からEntityに変換\r
+        * try to set all columns to entity with java.lang.reflection\r
+        *\r
+        * @param <T>\r
+        * @param record\r
+        * @param clazz\r
+        * @return\r
+        * @throws InstantiationException\r
+        * @throws IllegalAccessException\r
+        * @throws NoSuchMethodException\r
+        * @throws InvocationTargetException\r
+        */\r
+       private <T> T mapToEntity(Map<String, Object> record, Class<T> clazz) throws SQLException{\r
+               T entity;\r
+               try {\r
+                       entity = clazz.newInstance();\r
+                       // for each map member, set value to entity\r
+                       for(Map.Entry<String, Object> column: record.entrySet()){\r
+                               // "MEMBER_ID_SEQ" -> "member_id_seq" -> "memberIdSeq"(Camel) -> "MemberIdSeq"(Capitalize) -> "setMemberIdSeq"(add "set")\r
+                               String setterName = "set"+StringUtils.capitalize(StringUtils.toCamelCase(column.getKey().toLowerCase()));\r
+                               Class<?> valueClass = column.getValue().getClass();\r
+\r
+//                             logger.debug(setterName +"("+valueClass.getSimpleName() +")");\r
+\r
+                               // プリミティブなら引数の方を変更する\r
+                               Class<?> primitiveType = ClassUtils.wrapperToPrimitive(valueClass);\r
+                               if(primitiveType!=null){\r
+                                       valueClass = primitiveType;\r
+                               }\r
+\r
+                               // SQLTimestamp型はjava.util.Date型で処理する\r
+                               if(valueClass.getName().equals(java.sql.Timestamp.class.getName())){\r
+                                       valueClass = java.util.Date.class;\r
+                               }\r
+\r
+                               // セッターの実行\r
+                               Method setterMethod = clazz.getMethod(setterName, valueClass);\r
+                               setterMethod.invoke(entity, column.getValue());\r
+                       }\r
+               } catch (Exception e) {\r
+                       throw new SQLException(e);\r
+               }\r
+               return entity;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/logging/Loggable.java b/src/com/lavans/luz2/sql/logging/Loggable.java
new file mode 100644 (file)
index 0000000..e65ed93
--- /dev/null
@@ -0,0 +1,19 @@
+/* $Id: Loggable.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/10/21\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.logging;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public interface Loggable {\r
+       /**\r
+        * ログ採取用に別の文字列を使用する場合に設定する。\r
+        * 実行するsqlとログを採るsqlが異なるクラスは本インターフェースを\r
+        * 実装し、別途ログsqlを設定できるようにする。\r
+        * @param string\r
+        */\r
+       public void setLogsql(String string);\r
+}\r
diff --git a/src/com/lavans/luz2/sql/logging/LoggingStatement.java b/src/com/lavans/luz2/sql/logging/LoggingStatement.java
new file mode 100644 (file)
index 0000000..f97f4bb
--- /dev/null
@@ -0,0 +1,383 @@
+/*\r
+ * $Id: LoggingStatement.java 413 2011-07-28 23:05:11Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.logging;\r
+\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.Statement;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.util.MethodUtil;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class LoggingStatement implements Statement {\r
+       /** 処理移譲先。 */\r
+       private Statement st=null;\r
+\r
+       /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */\r
+       private static final String CLASSNAME=LoggingStatement.class.getName();\r
+\r
+       /** ロガー */\r
+       private static Log logger = LogFactory.getLog(LoggingStatement.class);\r
+\r
+       /** ログ出力先変更。 */\r
+//     public void setLogger(Log value){\r
+//             logger = value;\r
+//     }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param st\r
+        */\r
+       public LoggingStatement(Statement st){\r
+               this.st = st;\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * BindStatementを"implements PreparedStatement"ではなく\r
+        * "extends LoggerPreparedStatement"にするための回避策として、\r
+        * 引数無しのコンストラクタをprotectedで用意する。\r
+        */\r
+//     protected LoggingStatement(){\r
+//     }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeQuery(java.lang.String)\r
+        */\r
+       public ResultSet executeQuery(String sql) throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.executeQuery(sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String)\r
+        */\r
+       public int executeUpdate(String sql) throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.executeUpdate(sql);\r
+       }\r
+\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int)\r
+        */\r
+       public int executeUpdate(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.executeUpdate(sql,autoGeneratedKeys);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int[])\r
+        */\r
+       public int executeUpdate(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.executeUpdate(sql,columnIndexes);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])\r
+        */\r
+       public int executeUpdate(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.executeUpdate(sql,columnNames);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int)\r
+        */\r
+       public boolean execute(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.execute(sql,autoGeneratedKeys);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String)\r
+        */\r
+       public boolean execute(String sql) throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.execute(sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int[])\r
+        */\r
+       public boolean execute(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.execute(sql,columnIndexes);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])\r
+        */\r
+       public boolean execute(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);\r
+               return st.execute(sql,columnNames);\r
+       }\r
+\r
+\r
+\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getFetchDirection()\r
+        */\r
+       public int getFetchDirection() throws SQLException {\r
+               return st.getFetchDirection();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getFetchSize()\r
+        */\r
+       public int getFetchSize() throws SQLException {\r
+               return st.getFetchSize();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMaxFieldSize()\r
+        */\r
+       public int getMaxFieldSize() throws SQLException {\r
+               return st.getMaxFieldSize();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMaxRows()\r
+        */\r
+       public int getMaxRows() throws SQLException {\r
+               return st.getMaxRows();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getQueryTimeout()\r
+        */\r
+       public int getQueryTimeout() throws SQLException {\r
+               return st.getQueryTimeout();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetConcurrency()\r
+        */\r
+       public int getResultSetConcurrency() throws SQLException {\r
+               return st.getResultSetConcurrency();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetHoldability()\r
+        */\r
+       public int getResultSetHoldability() throws SQLException {\r
+               return st.getResultSetHoldability();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetType()\r
+        */\r
+       public int getResultSetType() throws SQLException {\r
+               return st.getResultSetType();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getUpdateCount()\r
+        */\r
+       public int getUpdateCount() throws SQLException {\r
+               return st.getUpdateCount();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#cancel()\r
+        */\r
+       public void cancel() throws SQLException {\r
+               st.cancel();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#clearBatch()\r
+        */\r
+       public void clearBatch() throws SQLException {\r
+               st.clearBatch();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               st.clearWarnings();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               st.close();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMoreResults()\r
+        */\r
+       public boolean getMoreResults() throws SQLException {\r
+               return st.getMoreResults();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#executeBatch()\r
+        */\r
+       public int[] executeBatch() throws SQLException {\r
+               return st.executeBatch();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setFetchDirection(int)\r
+        */\r
+       public void setFetchDirection(int direction) throws SQLException {\r
+               st.setFetchDirection(direction);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setFetchSize(int)\r
+        */\r
+       public void setFetchSize(int rows) throws SQLException {\r
+               st.setFetchSize(rows);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setMaxFieldSize(int)\r
+        */\r
+       public void setMaxFieldSize(int max) throws SQLException {\r
+               st.setMaxFieldSize(max);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setMaxRows(int)\r
+        */\r
+       public void setMaxRows(int max) throws SQLException {\r
+               st.setMaxRows(max);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setQueryTimeout(int)\r
+        */\r
+       public void setQueryTimeout(int seconds) throws SQLException {\r
+               st.setQueryTimeout(seconds);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMoreResults(int)\r
+        */\r
+       public boolean getMoreResults(int current) throws SQLException {\r
+               return st.getMoreResults(current);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setEscapeProcessing(boolean)\r
+        */\r
+       public void setEscapeProcessing(boolean enable) throws SQLException {\r
+               st.setEscapeProcessing(enable);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#addBatch(java.lang.String)\r
+        */\r
+       public void addBatch(String sql) throws SQLException {\r
+               st.addBatch(sql);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setCursorName(java.lang.String)\r
+        */\r
+       public void setCursorName(String name) throws SQLException {\r
+               st.setCursorName(name);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getConnection()\r
+        */\r
+       public Connection getConnection() throws SQLException {\r
+               return st.getConnection();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getGeneratedKeys()\r
+        */\r
+       public ResultSet getGeneratedKeys() throws SQLException {\r
+               return st.getGeneratedKeys();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSet()\r
+        */\r
+       public ResultSet getResultSet() throws SQLException {\r
+               return st.getResultSet();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return st.getWarnings();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return st.isClosed();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isPoolable()\r
+        */\r
+       public boolean isPoolable() throws SQLException {\r
+               return st.isPoolable();\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param poolable\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#setPoolable(boolean)\r
+        */\r
+       public void setPoolable(boolean poolable) throws SQLException {\r
+               st.setPoolable(poolable);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledBindCallableStatement.java b/src/com/lavans/luz2/sql/pool/PooledBindCallableStatement.java
new file mode 100644 (file)
index 0000000..697a80d
--- /dev/null
@@ -0,0 +1,1058 @@
+/* $Id: PooledBindCallableStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+import java.util.Map;\r
+\r
+import com.lavans.luz2.sql.bind.BindCallableStatement;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledBindCallableStatement extends PooledBindPreparedStatement implements BindCallableStatement{\r
+       private BindCallableStatement st = null;\r
+\r
+       public PooledBindCallableStatement(PooledConnection con, BindCallableStatement bst){\r
+               super(con, bst);\r
+               this.st = bst;\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getArray(int)\r
+        */\r
+       public Array getArray(int i) throws SQLException {\r
+               return st.getArray(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getArray(java.lang.String)\r
+        */\r
+       public Array getArray(String parameterName) throws SQLException {\r
+               return st.getArray(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param scale\r
+        * @return\r
+        * @throws SQLException\r
+        * @deprecated\r
+        * @see java.sql.CallableStatement#getBigDecimal(int, int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {\r
+               return st.getBigDecimal(parameterIndex, scale);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBigDecimal(int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {\r
+               return st.getBigDecimal(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBigDecimal(java.lang.String)\r
+        */\r
+       public BigDecimal getBigDecimal(String parameterName) throws SQLException {\r
+               return st.getBigDecimal(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBlob(int)\r
+        */\r
+       public Blob getBlob(int i) throws SQLException {\r
+               return st.getBlob(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBlob(java.lang.String)\r
+        */\r
+       public Blob getBlob(String parameterName) throws SQLException {\r
+               return st.getBlob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBoolean(int)\r
+        */\r
+       public boolean getBoolean(int parameterIndex) throws SQLException {\r
+               return st.getBoolean(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBoolean(java.lang.String)\r
+        */\r
+       public boolean getBoolean(String parameterName) throws SQLException {\r
+               return st.getBoolean(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getByte(int)\r
+        */\r
+       public byte getByte(int parameterIndex) throws SQLException {\r
+               return st.getByte(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getByte(java.lang.String)\r
+        */\r
+       public byte getByte(String parameterName) throws SQLException {\r
+               return st.getByte(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBytes(int)\r
+        */\r
+       public byte[] getBytes(int parameterIndex) throws SQLException {\r
+               return st.getBytes(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getBytes(java.lang.String)\r
+        */\r
+       public byte[] getBytes(String parameterName) throws SQLException {\r
+               return st.getBytes(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getClob(int)\r
+        */\r
+       public Clob getClob(int i) throws SQLException {\r
+               return st.getClob(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getClob(java.lang.String)\r
+        */\r
+       public Clob getClob(String parameterName) throws SQLException {\r
+               return st.getClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)\r
+        */\r
+       public Date getDate(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getDate(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(int)\r
+        */\r
+       public Date getDate(int parameterIndex) throws SQLException {\r
+               return st.getDate(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Date getDate(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getDate(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String)\r
+        */\r
+       public Date getDate(String parameterName) throws SQLException {\r
+               return st.getDate(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDouble(int)\r
+        */\r
+       public double getDouble(int parameterIndex) throws SQLException {\r
+               return st.getDouble(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getDouble(java.lang.String)\r
+        */\r
+       public double getDouble(String parameterName) throws SQLException {\r
+               return st.getDouble(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getFloat(int)\r
+        */\r
+       public float getFloat(int parameterIndex) throws SQLException {\r
+               return st.getFloat(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getFloat(java.lang.String)\r
+        */\r
+       public float getFloat(String parameterName) throws SQLException {\r
+               return st.getFloat(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getInt(int)\r
+        */\r
+       public int getInt(int parameterIndex) throws SQLException {\r
+               return st.getInt(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getInt(java.lang.String)\r
+        */\r
+       public int getInt(String parameterName) throws SQLException {\r
+               return st.getInt(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getLong(int)\r
+        */\r
+       public long getLong(int parameterIndex) throws SQLException {\r
+               return st.getLong(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getLong(java.lang.String)\r
+        */\r
+       public long getLong(String parameterName) throws SQLException {\r
+               return st.getLong(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @param map\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(int, java.util.Map)\r
+        */\r
+       public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {\r
+               return st.getObject(i, map);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(int)\r
+        */\r
+       public Object getObject(int parameterIndex) throws SQLException {\r
+               return st.getObject(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param map\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String, java.util.Map)\r
+        */\r
+       public Object getObject(String parameterName, Map<String, Class<?>> map) throws SQLException {\r
+               return st.getObject(parameterName, map);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String)\r
+        */\r
+       public Object getObject(String parameterName) throws SQLException {\r
+               return st.getObject(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRef(int)\r
+        */\r
+       public Ref getRef(int i) throws SQLException {\r
+               return st.getRef(i);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRef(java.lang.String)\r
+        */\r
+       public Ref getRef(String parameterName) throws SQLException {\r
+               return st.getRef(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getShort(int)\r
+        */\r
+       public short getShort(int parameterIndex) throws SQLException {\r
+               return st.getShort(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getShort(java.lang.String)\r
+        */\r
+       public short getShort(String parameterName) throws SQLException {\r
+               return st.getShort(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getString(int)\r
+        */\r
+       public String getString(int parameterIndex) throws SQLException {\r
+               return st.getString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getString(java.lang.String)\r
+        */\r
+       public String getString(String parameterName) throws SQLException {\r
+               return st.getString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)\r
+        */\r
+       public Time getTime(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getTime(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(int)\r
+        */\r
+       public Time getTime(int parameterIndex) throws SQLException {\r
+               return st.getTime(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Time getTime(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getTime(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String)\r
+        */\r
+       public Time getTime(String parameterName) throws SQLException {\r
+               return st.getTime(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getTimestamp(parameterIndex, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(int)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex) throws SQLException {\r
+               return st.getTimestamp(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param cal\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException {\r
+               return st.getTimestamp(parameterName, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName) throws SQLException {\r
+               return st.getTimestamp(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getURL(int)\r
+        */\r
+       public URL getURL(int parameterIndex) throws SQLException {\r
+               return st.getURL(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getURL(java.lang.String)\r
+        */\r
+       public URL getURL(String parameterName) throws SQLException {\r
+               return st.getURL(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param sqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {\r
+               st.registerOutParameter(parameterIndex, sqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param paramIndex\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException {\r
+               st.registerOutParameter(paramIndex, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {\r
+               st.registerOutParameter(parameterIndex, sqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType) throws SQLException {\r
+               st.registerOutParameter(parameterName, sqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {\r
+               st.setDate(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param sqlType\r
+        * @param typeName\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {\r
+               st.setNull(parameterName, sqlType, typeName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param targetSqlType\r
+        * @param scale\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {\r
+               st.setObject(parameterName, x, targetSqlType, scale);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param targetSqlType\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {\r
+               st.setObject(parameterName, x, targetSqlType);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {\r
+               st.setTime(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param cal\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {\r
+               st.setTimestamp(parameterName, x, cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param val\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)\r
+        */\r
+       public void setURL(String parameterName, URL val) throws SQLException {\r
+               st.setURL(parameterName, val);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#wasNull()\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return st.wasNull();\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(int)\r
+        */\r
+       public Reader getCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getCharacterStream(String parameterName) throws SQLException {\r
+               return st.getCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(int)\r
+        */\r
+       public Reader getNCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getNCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getNCharacterStream(String parameterName) throws SQLException {\r
+               return st.getNCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(int)\r
+        */\r
+       public NClob getNClob(int parameterIndex) throws SQLException {\r
+               return st.getNClob(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(java.lang.String)\r
+        */\r
+       public NClob getNClob(String parameterName) throws SQLException {\r
+               return st.getNClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(int)\r
+        */\r
+       public String getNString(int parameterIndex) throws SQLException {\r
+               return st.getNString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(java.lang.String)\r
+        */\r
+       public String getNString(String parameterName) throws SQLException {\r
+               return st.getNString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(int)\r
+        */\r
+       public RowId getRowId(int parameterIndex) throws SQLException {\r
+               return st.getRowId(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(java.lang.String)\r
+        */\r
+       public RowId getRowId(String parameterName) throws SQLException {\r
+               return st.getRowId(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(int)\r
+        */\r
+       public SQLXML getSQLXML(int parameterIndex) throws SQLException {\r
+               return st.getSQLXML(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(java.lang.String)\r
+        */\r
+       public SQLXML getSQLXML(String parameterName) throws SQLException {\r
+               return st.getSQLXML(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream,\r
+                       long length) throws SQLException {\r
+               st.setBlob(parameterName, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterName, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.sql.Clob)\r
+        */\r
+       public void setClob(String parameterName, Clob x) throws SQLException {\r
+               st.setClob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterName, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.sql.NClob)\r
+        */\r
+       public void setNClob(String parameterName, NClob value) throws SQLException {\r
+               st.setNClob(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setNString(String parameterName, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setRowId(java.lang.String, java.sql.RowId)\r
+        */\r
+       public void setRowId(String parameterName, RowId x) throws SQLException {\r
+               st.setRowId(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setSQLXML(java.lang.String, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(String parameterName, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterName, xmlObject);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledBindPreparedStatement.java b/src/com/lavans/luz2/sql/pool/PooledBindPreparedStatement.java
new file mode 100644 (file)
index 0000000..674d46b
--- /dev/null
@@ -0,0 +1,168 @@
+/* $Id: PooledBindPreparedStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.math.BigDecimal;\r
+import java.sql.Blob;\r
+import java.sql.Date;\r
+import java.sql.SQLException;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Map;\r
+\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledBindPreparedStatement extends PooledPreparedStatement implements BindPreparedStatement{\r
+       private BindPreparedStatement bst = null;\r
+\r
+       public PooledBindPreparedStatement(PooledConnection con, BindPreparedStatement bst){\r
+               super(con, bst);\r
+               this.bst = bst;\r
+       }\r
+       \r
+       /**\r
+        * パラメータ一括設定\r
+        * @see com.lavans.luz2.sql.bind.BindPreparedStatement#setBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void setParams(Map<String, Object> params) throws SQLException {\r
+               bst.setParams(params);\r
+       }\r
+\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBoolean(String key, boolean x) throws SQLException {\r
+               bst.setBoolean(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setByte(String key, byte x) throws SQLException {\r
+               bst.setByte(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBytes(String key, byte[] x) throws SQLException {\r
+               bst.setBytes(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setDate(String key, Date x) throws SQLException {\r
+               bst.setDate(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setDouble(String key, double x) throws SQLException {\r
+               bst.setDouble(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setFloat(String key, float x) throws SQLException {\r
+               bst.setFloat(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setInt(String key, int x) throws SQLException {\r
+               bst.setInt(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setLong(String key, long x) throws SQLException {\r
+               bst.setLong(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param sqlType\r
+        * @throws SQLException\r
+        */\r
+       public void setNull(String key, int sqlType) throws SQLException {\r
+               bst.setNull(key, sqlType);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setShort(String key, short x) throws SQLException {\r
+               bst.setShort(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setString(String key, String x) throws SQLException {\r
+               bst.setString(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setTime(String key, Time x) throws SQLException {\r
+               bst.setTime(key, x);\r
+       }\r
+       /**\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setTimestamp(String key, Timestamp x) throws SQLException {\r
+               bst.setTimestamp(key, x);\r
+       }\r
+       \r
+       /**\r
+        * パラメータ名での設定(java.math.BigDecimal)。\r
+        * @param key\r
+        * @param x\r
+        * @throws SQLException\r
+        */\r
+       public void setBigDecimal(String key, BigDecimal x) throws SQLException {\r
+               bst.setBigDecimal(key, x);\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Blob)。\r
+        * @see com.lavans.luz2.sql.bind.BindPreparedStatement#setBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void setBlob(String key, Blob x) throws SQLException {\r
+               bst.setBlob(key, x);\r
+       }\r
+\r
+       /**\r
+        * パラメータ名での設定(java.sql.Object)。\r
+        * @see com.lavans.luz2.sql.bind.BindPreparedStatement#setBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void setObject(String key, Object x) throws SQLException {\r
+               bst.setObject(key, x);\r
+               // TODO 自動生成されたメソッド・スタブ\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledCallableStatement.java b/src/com/lavans/luz2/sql/pool/PooledCallableStatement.java
new file mode 100644 (file)
index 0000000..47f1841
--- /dev/null
@@ -0,0 +1,1075 @@
+/* $Id: PooledCallableStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledCallableStatement extends PooledPreparedStatement implements\r
+               CallableStatement {\r
+       private CallableStatement st = null;\r
+\r
+       public PooledCallableStatement(PooledConnection con, CallableStatement st){\r
+               super(con, st);\r
+               this.st = st;\r
+       }\r
+\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Timestamp getTimestamp(int arg0) throws SQLException {\r
+               return st.getTimestamp(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public String getString(String arg0) throws SQLException {\r
+               return st.getString(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean getBoolean(String arg0) throws SQLException {\r
+               return st.getBoolean(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Object getObject(int arg0) throws SQLException {\r
+               return st.getObject(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Object getObject(String arg0, Map<String, Class<?>> arg1) throws SQLException {\r
+               return st.getObject(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Time getTime(int arg0) throws SQLException {\r
+               return st.getTime(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public URL getURL(int arg0) throws SQLException {\r
+               return st.getURL(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException {\r
+               return st.getTimestamp(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Blob getBlob(String arg0) throws SQLException {\r
+               return st.getBlob(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public byte[] getBytes(int arg0) throws SQLException {\r
+               return st.getBytes(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setString(String arg0, String arg1) throws SQLException {\r
+               st.setString(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Clob getClob(int arg0) throws SQLException {\r
+               return st.getClob(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Date getDate(int arg0, Calendar arg1) throws SQLException {\r
+               return st.getDate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setAsciiStream(String arg0, InputStream arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setAsciiStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public byte[] getBytes(String arg0) throws SQLException {\r
+               return st.getBytes(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setURL(String arg0, URL arg1) throws SQLException {\r
+               st.setURL(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @param arg3\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(String arg0, Object arg1, int arg2, int arg3)\r
+                       throws SQLException {\r
+               st.setObject(arg0, arg1, arg2, arg3);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public String getString(int arg0) throws SQLException {\r
+               return st.getString(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Blob getBlob(int arg0) throws SQLException {\r
+               return st.getBlob(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Timestamp getTimestamp(String arg0, Calendar arg1)\r
+                       throws SQLException {\r
+               return st.getTimestamp(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Time getTime(int arg0, Calendar arg1) throws SQLException {\r
+               return st.getTime(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public long getLong(String arg0) throws SQLException {\r
+               return st.getLong(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setFloat(String arg0, float arg1) throws SQLException {\r
+               st.setFloat(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        * @deprecated\r
+        */\r
+       public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException {\r
+               return st.getBigDecimal(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public float getFloat(int arg0) throws SQLException {\r
+               return st.getFloat(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(int arg0, int arg1, int arg2)\r
+                       throws SQLException {\r
+               st.registerOutParameter(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Timestamp getTimestamp(String arg0) throws SQLException {\r
+               return st.getTimestamp(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Ref getRef(String arg0) throws SQLException {\r
+               return st.getRef(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public double getDouble(String arg0) throws SQLException {\r
+               return st.getDouble(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getInt(String arg0) throws SQLException {\r
+               return st.getInt(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Array getArray(String arg0) throws SQLException {\r
+               return st.getArray(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Date getDate(String arg0) throws SQLException {\r
+               return st.getDate(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Time getTime(String arg0) throws SQLException {\r
+               return st.getTime(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public URL getURL(String arg0) throws SQLException {\r
+               return st.getURL(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public short getShort(String arg0) throws SQLException {\r
+               return st.getShort(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(String arg0, Object arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setObject(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setNull(String arg0, int arg1, String arg2) throws SQLException {\r
+               st.setNull(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setNull(String arg0, int arg1) throws SQLException {\r
+               st.setNull(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setLong(String arg0, long arg1) throws SQLException {\r
+               st.setLong(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBoolean(String arg0, boolean arg1) throws SQLException {\r
+               st.setBoolean(arg0, arg1);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return st.wasNull();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(String arg0, Object arg1) throws SQLException {\r
+               st.setObject(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public BigDecimal getBigDecimal(String arg0) throws SQLException {\r
+               return st.getBigDecimal(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDouble(String arg0, double arg1) throws SQLException {\r
+               st.setDouble(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTime(String arg0, Time arg1) throws SQLException {\r
+               st.setTime(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Object getObject(int arg0, Map<String, Class<?>> arg1) throws SQLException {\r
+               return st.getObject(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBytes(String arg0, byte[] arg1) throws SQLException {\r
+               st.setBytes(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(String arg0, int arg1) throws SQLException {\r
+               st.registerOutParameter(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTime(String arg0, Time arg1, Calendar arg2)\r
+                       throws SQLException {\r
+               st.setTime(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setShort(String arg0, short arg1) throws SQLException {\r
+               st.setShort(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBinaryStream(String arg0, InputStream arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setBinaryStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDate(String arg0, Date arg1, Calendar arg2)\r
+                       throws SQLException {\r
+               st.setDate(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Date getDate(int arg0) throws SQLException {\r
+               return st.getDate(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBigDecimal(String arg0, BigDecimal arg1) throws SQLException {\r
+               st.setBigDecimal(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(int arg0, int arg1, String arg2)\r
+                       throws SQLException {\r
+               st.registerOutParameter(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Array getArray(int arg0) throws SQLException {\r
+               return st.getArray(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Ref getRef(int arg0) throws SQLException {\r
+               return st.getRef(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(String arg0, int arg1, String arg2)\r
+                       throws SQLException {\r
+               st.registerOutParameter(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public long getLong(int arg0) throws SQLException {\r
+               return st.getLong(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setInt(String arg0, int arg1) throws SQLException {\r
+               st.setInt(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public byte getByte(int arg0) throws SQLException {\r
+               return st.getByte(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(int arg0, int arg1) throws SQLException {\r
+               st.registerOutParameter(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void registerOutParameter(String arg0, int arg1, int arg2)\r
+                       throws SQLException {\r
+               st.registerOutParameter(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Object getObject(String arg0) throws SQLException {\r
+               return st.getObject(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getInt(int arg0) throws SQLException {\r
+               return st.getInt(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Time getTime(String arg0, Calendar arg1) throws SQLException {\r
+               return st.getTime(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public short getShort(int arg0) throws SQLException {\r
+               return st.getShort(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public BigDecimal getBigDecimal(int arg0) throws SQLException {\r
+               return st.getBigDecimal(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean getBoolean(int arg0) throws SQLException {\r
+               return st.getBoolean(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setByte(String arg0, byte arg1) throws SQLException {\r
+               st.setByte(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public float getFloat(String arg0) throws SQLException {\r
+               return st.getFloat(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Date getDate(String arg0, Calendar arg1) throws SQLException {\r
+               return st.getDate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setCharacterStream(String arg0, Reader arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setCharacterStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTimestamp(String arg0, Timestamp arg1) throws SQLException {\r
+               st.setTimestamp(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Clob getClob(String arg0) throws SQLException {\r
+               return st.getClob(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public double getDouble(int arg0) throws SQLException {\r
+               return st.getDouble(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTimestamp(String arg0, Timestamp arg1, Calendar arg2)\r
+                       throws SQLException {\r
+               st.setTimestamp(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public byte getByte(String arg0) throws SQLException {\r
+               return st.getByte(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDate(String arg0, Date arg1) throws SQLException {\r
+               st.setDate(arg0, arg1);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(int)\r
+        */\r
+       public Reader getCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getCharacterStream(String parameterName) throws SQLException {\r
+               return st.getCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(int)\r
+        */\r
+       public Reader getNCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getNCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getNCharacterStream(String parameterName) throws SQLException {\r
+               return st.getNCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(int)\r
+        */\r
+       public NClob getNClob(int parameterIndex) throws SQLException {\r
+               return st.getNClob(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(java.lang.String)\r
+        */\r
+       public NClob getNClob(String parameterName) throws SQLException {\r
+               return st.getNClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(int)\r
+        */\r
+       public String getNString(int parameterIndex) throws SQLException {\r
+               return st.getNString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(java.lang.String)\r
+        */\r
+       public String getNString(String parameterName) throws SQLException {\r
+               return st.getNString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(int)\r
+        */\r
+       public RowId getRowId(int parameterIndex) throws SQLException {\r
+               return st.getRowId(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(java.lang.String)\r
+        */\r
+       public RowId getRowId(String parameterName) throws SQLException {\r
+               return st.getRowId(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(int)\r
+        */\r
+       public SQLXML getSQLXML(int parameterIndex) throws SQLException {\r
+               return st.getSQLXML(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(java.lang.String)\r
+        */\r
+       public SQLXML getSQLXML(String parameterName) throws SQLException {\r
+               return st.getSQLXML(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void setBlob(String parameterName, Blob x) throws SQLException {\r
+               st.setBlob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream,\r
+                       long length) throws SQLException {\r
+               st.setBlob(parameterName, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterName, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.sql.Clob)\r
+        */\r
+       public void setClob(String parameterName, Clob x) throws SQLException {\r
+               st.setClob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterName, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.sql.NClob)\r
+        */\r
+       public void setNClob(String parameterName, NClob value) throws SQLException {\r
+               st.setNClob(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setNString(String parameterName, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setRowId(java.lang.String, java.sql.RowId)\r
+        */\r
+       public void setRowId(String parameterName, RowId x) throws SQLException {\r
+               st.setRowId(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setSQLXML(java.lang.String, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(String parameterName, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterName, xmlObject);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledConnection.java b/src/com/lavans/luz2/sql/pool/PooledConnection.java
new file mode 100644 (file)
index 0000000..52bc668
--- /dev/null
@@ -0,0 +1,596 @@
+/* $Id: PooledConnection.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2005/01/27\r
+ * (c)2005 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.NClob;\r
+import java.sql.PreparedStatement;\r
+import java.sql.SQLClientInfoException;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.SQLXML;\r
+import java.sql.Savepoint;\r
+import java.sql.Statement;\r
+import java.sql.Struct;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.ConnectionPool;\r
+import com.lavans.luz2.sql.DBManager;\r
+import com.lavans.luz2.sql.bind.BindCallableStatement;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+\r
+\r
+/**\r
+ * DBManager.releaseConnection(con)を呼ばなくても、con.close()すると\r
+ * コネクションを返却するように振る舞うためのラッパークラス。\r
+ *\r
+ * 各種Statementを作成するときは、PooledStatementでラップする。\r
+ * PooledStatement#close()では本クラスのremoveStatement()を呼び出すので、\r
+ * Connection#close()が呼ばれずに何度もcreateStatement()/st.close()を\r
+ * 繰り返すような場合に本クラスのstatementList()が肥大していくのを防ぐ。\r
+ * DriverWrapper経由で呼び出された場合など、lavansutilの外側で\r
+ * さらにConnectionPoolするような場合に必要である。\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledConnection implements BindConnection {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(PooledConnection.class);\r
+\r
+       private BindConnection con=null;\r
+       private ConnectionPool pool = null;\r
+\r
+       /** close()時にすべてのStatementを自動的に閉じる。 */\r
+       private List<PooledStatement> statementList = Collections.synchronizedList(new ArrayList<PooledStatement>());\r
+\r
+\r
+       public BindConnection getRealConnection(){\r
+               return con;\r
+       }\r
+\r
+       /**\r
+        *\r
+        */\r
+       public PooledConnection(ConnectionPool pool, BindConnection bcon) {\r
+               this.pool = pool;\r
+               this.con = bcon;\r
+       }\r
+\r
+       /**\r
+        * 子Statementで明示的にclose()をかけた時に、こちらで\r
+        * 保存しておいたリストから削除する。\r
+        * @param st\r
+        * @return\r
+        */\r
+       public boolean removeStatement(PooledStatement st){\r
+               logger.debug("before:"+ statementList.size());\r
+               boolean result = statementList.remove(st);\r
+               logger.debug("after:"+ statementList.size());\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * BindConnectionImpleに処理委譲。\r
+        * @see com.lavans.util.jdbc.bind.BindConnectionImpl#bindPrepareStatement(java.lang.String)\r
+        */\r
+       public BindPreparedStatement bindPrepareStatement(String sql)\r
+                       throws SQLException {\r
+               BindPreparedStatement bst = con.bindPrepareStatement(sql);\r
+               PooledBindPreparedStatement pst = new PooledBindPreparedStatement(this,bst);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+\r
+       /**\r
+        * BindConnectionImpleに処理委譲。\r
+        * @see com.lavans.util.jdbc.bind.BindConnectionImpl#bindPrepareStatement(java.lang.String)\r
+        */\r
+       public BindCallableStatement bindPrepareCall(String sql)\r
+                       throws SQLException {\r
+               BindCallableStatement bst = con.bindPrepareCall(sql);\r
+               PooledBindCallableStatement pst = new PooledBindCallableStatement(this,bst);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+\r
+       /**\r
+        * DBManagerを通じてコネクションプールに返却。\r
+        */\r
+       public void close() throws SQLException{\r
+               DBManager.releaseConnection(this,pool);\r
+               // DBManager#releaseConnection()->ConnectionPool#releaseConnection()の中で\r
+               // clearStatementList()を呼び出すのでここで呼ぶ必要はない。\r
+               // ConnectionPoolクラスでpoolListに移し終わっているので、呼んではいけない。\r
+       }\r
+\r
+       /**\r
+        * 保存しておいたstatementのクリア。\r
+        *\r
+        */\r
+       public void clearStatementList(){\r
+               // close()をかけると本クラスのremoveStatementを呼ぶ。\r
+               while(statementList.size()>0){\r
+                       logger.warn("statementList.size()>0 st.close()の呼び忘れが考えられる", new Exception());\r
+                       Statement st = statementList.remove(0);\r
+                       if(!(st instanceof PooledStatement)){\r
+                               logger.error("PooledでないStatementを保持");\r
+                       }else{\r
+                               PooledStatement pst = (PooledStatement)st;\r
+                               logger.warn("this:"+this.toString() +" st.parent:"+pst.parent.toString());\r
+                       }\r
+                       try {\r
+                               st.close();\r
+                       } catch (Exception e) {\r
+                       }\r
+               }\r
+               statementList.clear();\r
+       }\r
+\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               con.clearWarnings();\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void commit() throws SQLException {\r
+               con.commit();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Statement createStatement() throws SQLException {\r
+               Statement st = con.createStatement();\r
+               PooledStatement pst = new PooledStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Statement createStatement(int arg0, int arg1) throws SQLException {\r
+               Statement st = con.createStatement(arg0, arg1);\r
+               PooledStatement pst = new PooledStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Statement createStatement(int arg0, int arg1, int arg2)\r
+                       throws SQLException {\r
+               Statement st = con.createStatement(arg0, arg1, arg2);\r
+               PooledStatement pst = new PooledStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean getAutoCommit() throws SQLException {\r
+               return con.getAutoCommit();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public String getCatalog() throws SQLException {\r
+               return con.getCatalog();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getHoldability() throws SQLException {\r
+               return con.getHoldability();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public DatabaseMetaData getMetaData() throws SQLException {\r
+               return con.getMetaData();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getTransactionIsolation() throws SQLException {\r
+               return con.getTransactionIsolation();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Map<String, Class<?>> getTypeMap() throws SQLException {\r
+               return con.getTypeMap();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return con.getWarnings();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return con.isClosed();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean isReadOnly() throws SQLException {\r
+               return con.isReadOnly();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public String nativeSQL(String arg0) throws SQLException {\r
+               return con.nativeSQL(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public CallableStatement prepareCall(String arg0) throws SQLException {\r
+               CallableStatement st = con.prepareCall(arg0);\r
+               PooledCallableStatement pst = new PooledCallableStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public CallableStatement prepareCall(String arg0, int arg1, int arg2)\r
+                       throws SQLException {\r
+               CallableStatement st = con.prepareCall(arg0, arg1, arg2);\r
+               PooledCallableStatement pst = new PooledCallableStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @param arg3\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public CallableStatement prepareCall(String arg0, int arg1, int arg2,\r
+                       int arg3) throws SQLException {\r
+               CallableStatement st = con.prepareCall(arg0, arg1, arg2, arg3);\r
+               PooledCallableStatement pst = new PooledCallableStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0) throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0, int arg1)\r
+                       throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0, arg1);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0, int arg1, int arg2)\r
+                       throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0, arg1, arg2);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @param arg3\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0, int arg1, int arg2,\r
+                       int arg3) throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0, arg1, arg2, arg3);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0, int[] arg1)\r
+                       throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0, arg1);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public PreparedStatement prepareStatement(String arg0, String[] arg1)\r
+                       throws SQLException {\r
+               PreparedStatement st = con.prepareStatement(arg0, arg1);\r
+               PooledPreparedStatement pst = new PooledPreparedStatement(this,st);\r
+               statementList.add(pst);\r
+               return pst;\r
+\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void releaseSavepoint(Savepoint arg0) throws SQLException {\r
+               con.releaseSavepoint(arg0);\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void rollback() throws SQLException {\r
+               con.rollback();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void rollback(Savepoint arg0) throws SQLException {\r
+               con.rollback(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setAutoCommit(boolean arg0) throws SQLException {\r
+               con.setAutoCommit(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setCatalog(String arg0) throws SQLException {\r
+               con.setCatalog(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setHoldability(int arg0) throws SQLException {\r
+               con.setHoldability(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setReadOnly(boolean arg0) throws SQLException {\r
+               con.setReadOnly(arg0);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Savepoint setSavepoint() throws SQLException {\r
+               return con.setSavepoint();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Savepoint setSavepoint(String arg0) throws SQLException {\r
+               return con.setSavepoint(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTransactionIsolation(int arg0) throws SQLException {\r
+               con.setTransactionIsolation(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTypeMap(Map<String, Class<?>> arg0) throws SQLException {\r
+               con.setTypeMap(arg0);\r
+       }\r
+       /**\r
+        * @param typeName\r
+        * @param elements\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createArrayOf(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Array createArrayOf(String typeName, Object[] elements)\r
+                       throws SQLException {\r
+               return con.createArrayOf(typeName, elements);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createBlob()\r
+        */\r
+       public Blob createBlob() throws SQLException {\r
+               return con.createBlob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createClob()\r
+        */\r
+       public Clob createClob() throws SQLException {\r
+               return con.createClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createNClob()\r
+        */\r
+       public NClob createNClob() throws SQLException {\r
+               return con.createNClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createSQLXML()\r
+        */\r
+       public SQLXML createSQLXML() throws SQLException {\r
+               return con.createSQLXML();\r
+       }\r
+\r
+       /**\r
+        * @param typeName\r
+        * @param attributes\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createStruct(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Struct createStruct(String typeName, Object[] attributes)\r
+                       throws SQLException {\r
+               return con.createStruct(typeName, attributes);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo()\r
+        */\r
+       public Properties getClientInfo() throws SQLException {\r
+               return con.getClientInfo();\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo(java.lang.String)\r
+        */\r
+       public String getClientInfo(String name) throws SQLException {\r
+               return con.getClientInfo(name);\r
+       }\r
+\r
+       /**\r
+        * @param timeout\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#isValid(int)\r
+        */\r
+       public boolean isValid(int timeout) throws SQLException {\r
+               return con.isValid(timeout);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return con.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param properties\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.util.Properties)\r
+        */\r
+       public void setClientInfo(Properties properties)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(properties);\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @param value\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.lang.String, java.lang.String)\r
+        */\r
+       public void setClientInfo(String name, String value)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(name, value);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledPreparedStatement.java b/src/com/lavans/luz2/sql/pool/PooledPreparedStatement.java
new file mode 100644 (file)
index 0000000..3cb290c
--- /dev/null
@@ -0,0 +1,573 @@
+/* $Id: PooledPreparedStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.ParameterMetaData;\r
+import java.sql.PreparedStatement;\r
+import java.sql.Ref;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+\r
+/**\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledPreparedStatement extends PooledStatement implements\r
+               PreparedStatement {\r
+       private PreparedStatement st = null;\r
+\r
+       public PooledPreparedStatement(PooledConnection con, PreparedStatement st){\r
+               super(con, st);\r
+               this.st = st;\r
+       }\r
+\r
+\r
+\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTimestamp(int arg0, Timestamp arg1, Calendar arg2)\r
+                       throws SQLException {\r
+               st.setTimestamp(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setShort(int arg0, short arg1) throws SQLException {\r
+               st.setShort(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setLong(int arg0, long arg1) throws SQLException {\r
+               st.setLong(arg0, arg1);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ResultSet executeQuery() throws SQLException {\r
+               return st.executeQuery();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setString(int arg0, String arg1) throws SQLException {\r
+               st.setString(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @param arg3\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(int arg0, Object arg1, int arg2, int arg3)\r
+                       throws SQLException {\r
+               st.setObject(arg0, arg1, arg2, arg3);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDate(int arg0, Date arg1) throws SQLException {\r
+               st.setDate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setAsciiStream(int arg0, InputStream arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setAsciiStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setNull(int arg0, int arg1, String arg2) throws SQLException {\r
+               st.setNull(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int executeUpdate() throws SQLException {\r
+               return st.executeUpdate();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDate(int arg0, Date arg1, Calendar arg2) throws SQLException {\r
+               st.setDate(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void clearParameters() throws SQLException {\r
+               st.clearParameters();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setInt(int arg0, int arg1) throws SQLException {\r
+               st.setInt(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBytes(int arg0, byte[] arg1) throws SQLException {\r
+               st.setBytes(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setCharacterStream(int arg0, Reader arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setCharacterStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setRef(int arg0, Ref arg1) throws SQLException {\r
+               st.setRef(arg0, arg1);\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void addBatch() throws SQLException {\r
+               st.addBatch();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setDouble(int arg0, double arg1) throws SQLException {\r
+               st.setDouble(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setNull(int arg0, int arg1) throws SQLException {\r
+               st.setNull(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setURL(int arg0, URL arg1) throws SQLException {\r
+               st.setURL(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(int arg0, Object arg1, int arg2) throws SQLException {\r
+               st.setObject(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ParameterMetaData getParameterMetaData() throws SQLException {\r
+               return st.getParameterMetaData();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBinaryStream(int arg0, InputStream arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setBinaryStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ResultSetMetaData getMetaData() throws SQLException {\r
+               return st.getMetaData();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBoolean(int arg0, boolean arg1) throws SQLException {\r
+               st.setBoolean(arg0, arg1);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean execute() throws SQLException {\r
+               return st.execute();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBlob(int arg0, Blob arg1) throws SQLException {\r
+               st.setBlob(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setClob(int arg0, Clob arg1) throws SQLException {\r
+               st.setClob(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setBigDecimal(int arg0, BigDecimal arg1) throws SQLException {\r
+               st.setBigDecimal(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setFloat(int arg0, float arg1) throws SQLException {\r
+               st.setFloat(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTime(int arg0, Time arg1) throws SQLException {\r
+               st.setTime(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setByte(int arg0, byte arg1) throws SQLException {\r
+               st.setByte(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTime(int arg0, Time arg1, Calendar arg2) throws SQLException {\r
+               st.setTime(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @param arg2\r
+        * @throws java.sql.SQLException\r
+        * @deprecated\r
+        */\r
+       public void setUnicodeStream(int arg0, InputStream arg1, int arg2)\r
+                       throws SQLException {\r
+               st.setUnicodeStream(arg0, arg1, arg2);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setArray(int arg0, Array arg1) throws SQLException {\r
+               st.setArray(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setObject(int arg0, Object arg1) throws SQLException {\r
+               st.setObject(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setTimestamp(int arg0, Timestamp arg1) throws SQLException {\r
+               st.setTimestamp(arg0, arg1);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream, long length)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)\r
+        */\r
+       public void setNClob(int parameterIndex, NClob value) throws SQLException {\r
+               st.setNClob(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setNClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNString(int, java.lang.String)\r
+        */\r
+       public void setNString(int parameterIndex, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId)\r
+        */\r
+       public void setRowId(int parameterIndex, RowId x) throws SQLException {\r
+               st.setRowId(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(int parameterIndex, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterIndex, xmlObject);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/pool/PooledStatement.java b/src/com/lavans/luz2/sql/pool/PooledStatement.java
new file mode 100644 (file)
index 0000000..6f96a8e
--- /dev/null
@@ -0,0 +1,356 @@
+/* $Id: PooledStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * created: 2005/06/17\r
+ *\r
+ */\r
+package com.lavans.luz2.sql.pool;\r
+\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.Statement;\r
+\r
+/**\r
+ * 親のConnection#close()が呼ばれたときに、子のStatementを\r
+ * 自動的にclose()するためのラッパークラス。\r
+ *\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class PooledStatement implements Statement {\r
+       PooledConnection parent = null;\r
+       private Statement st = null;\r
+\r
+       public PooledStatement(PooledConnection con, Statement st){\r
+               parent = con;\r
+               this.st = st;\r
+       }\r
+\r
+       /**\r
+        * 明示的にclose()が呼ばれた場合は親に通知し、\r
+        * 親のListから削除してもらう。\r
+        *\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void close() throws SQLException {\r
+               parent.removeStatement(this);\r
+               st.close();\r
+       }\r
+\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void addBatch(String arg0) throws SQLException {\r
+               st.addBatch(arg0);\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void cancel() throws SQLException {\r
+               st.cancel();\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void clearBatch() throws SQLException {\r
+               st.clearBatch();\r
+       }\r
+       /**\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               st.clearWarnings();\r
+       }\r
+\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean execute(String arg0) throws SQLException {\r
+               return st.execute(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean execute(String arg0, int arg1) throws SQLException {\r
+               return st.execute(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean execute(String arg0, int[] arg1) throws SQLException {\r
+               return st.execute(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean execute(String arg0, String[] arg1) throws SQLException {\r
+               return st.execute(arg0, arg1);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int[] executeBatch() throws SQLException {\r
+               return st.executeBatch();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ResultSet executeQuery(String arg0) throws SQLException {\r
+               return st.executeQuery(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int executeUpdate(String arg0) throws SQLException {\r
+               return st.executeUpdate(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int executeUpdate(String arg0, int arg1) throws SQLException {\r
+               return st.executeUpdate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int executeUpdate(String arg0, int[] arg1) throws SQLException {\r
+               return st.executeUpdate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @param arg1\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int executeUpdate(String arg0, String[] arg1) throws SQLException {\r
+               return st.executeUpdate(arg0, arg1);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public Connection getConnection() throws SQLException {\r
+               return st.getConnection();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getFetchDirection() throws SQLException {\r
+               return st.getFetchDirection();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getFetchSize() throws SQLException {\r
+               return st.getFetchSize();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ResultSet getGeneratedKeys() throws SQLException {\r
+               return st.getGeneratedKeys();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getMaxFieldSize() throws SQLException {\r
+               return st.getMaxFieldSize();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getMaxRows() throws SQLException {\r
+               return st.getMaxRows();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean getMoreResults() throws SQLException {\r
+               return st.getMoreResults();\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public boolean getMoreResults(int arg0) throws SQLException {\r
+               return st.getMoreResults(arg0);\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getQueryTimeout() throws SQLException {\r
+               return st.getQueryTimeout();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public ResultSet getResultSet() throws SQLException {\r
+               return st.getResultSet();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getResultSetConcurrency() throws SQLException {\r
+               return st.getResultSetConcurrency();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getResultSetHoldability() throws SQLException {\r
+               return st.getResultSetHoldability();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getResultSetType() throws SQLException {\r
+               return st.getResultSetType();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public int getUpdateCount() throws SQLException {\r
+               return st.getUpdateCount();\r
+       }\r
+       /**\r
+        * @return\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return st.getWarnings();\r
+       }\r
+\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setCursorName(String arg0) throws SQLException {\r
+               st.setCursorName(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setEscapeProcessing(boolean arg0) throws SQLException {\r
+               st.setEscapeProcessing(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setFetchDirection(int arg0) throws SQLException {\r
+               st.setFetchDirection(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setFetchSize(int arg0) throws SQLException {\r
+               st.setFetchSize(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setMaxFieldSize(int arg0) throws SQLException {\r
+               st.setMaxFieldSize(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setMaxRows(int arg0) throws SQLException {\r
+               st.setMaxRows(arg0);\r
+       }\r
+       /**\r
+        * @param arg0\r
+        * @throws java.sql.SQLException\r
+        */\r
+       public void setQueryTimeout(int arg0) throws SQLException {\r
+               st.setQueryTimeout(arg0);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return st.isClosed();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isPoolable()\r
+        */\r
+       public boolean isPoolable() throws SQLException {\r
+               return st.isPoolable();\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param poolable\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#setPoolable(boolean)\r
+        */\r
+       public void setPoolable(boolean poolable) throws SQLException {\r
+               st.setPoolable(poolable);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/stats/Statistics.java b/src/com/lavans/luz2/sql/stats/Statistics.java
new file mode 100644 (file)
index 0000000..7cc86f2
--- /dev/null
@@ -0,0 +1,428 @@
+/* $Id: Statistics.java 413 2011-07-28 23:05:11Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.Comparator;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.util.MethodUtil;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class Statistics{\r
+       public static final String SORT ="sort";\r
+       public static final String SORT_METHOD="method";\r
+       public static final String SORT_SQL="sql";\r
+       public static final String SORT_TOTAL="total";\r
+       public static final String SORT_AVERAGE="ave";\r
+\r
+\r
+       private static Log logger = LogFactory.getLog(Statistics.class);\r
+       /**\r
+        * SQLとTimeDataを対にして保存するMap.\r
+        */\r
+       private Map<String, StatsRecord> sqlMap = null;\r
+\r
+       /**\r
+        * Singletonのインスタンス。\r
+        */\r
+       private static Statistics instance= new Statistics();\r
+\r
+       /**\r
+        * 接続状況保管用Map。\r
+        */\r
+       private Map<String, int[]> countConnMap = null;\r
+       /**\r
+        * トランザクション中\r
+        */\r
+       private Map<String, int[]> countConnTranMap = null;\r
+       private Map<String, int[]> countTranMap = null;\r
+\r
+       /**\r
+        * 接続数カウント用配列の定義。\r
+        * count[COUNT_GET]に取得回数が、count[COUNT_RELEASE]に返却回数が入る。\r
+        */\r
+       private static final int COUNT_GET=0;\r
+       private static final int COUNT_RELEASE=1;\r
+       private static final String CLASSNAME=Statistics.class.getName();\r
+       private static final int COUNT_STARTTRAN=0;\r
+       private static final int COUNT_COMMIT=1;\r
+       private static final int COUNT_ROLLBACK=2;\r
+       private static final int COUNT_STARTTRAN_TRAN=3; // トランザクション中に再度startTransactionが呼ばれた\r
+       private static final int COUNT_COMMIT_NOTRAN=4;\r
+       private static final int COUNT_ROLLBACK_NOTRAN=5;\r
+\r
+       private Statistics(){\r
+               sqlMap = new ConcurrentHashMap<String, StatsRecord>();\r
+               countConnMap = new ConcurrentHashMap<String, int[]>();\r
+               countConnTranMap = new ConcurrentHashMap<String, int[]>();\r
+               countTranMap = new ConcurrentHashMap<String, int[]>();\r
+       }\r
+\r
+       public static Statistics getInstance(){\r
+               return instance;\r
+       }\r
+\r
+       /**\r
+        * 統計データ追加。\r
+        * @param sql\r
+        * @param costTime\r
+        */\r
+       public void addData(String sql, long costTime, String classname){\r
+               StatsRecord record = sqlMap.get(sql);\r
+               if(record==null){\r
+                       record = new StatsRecord();\r
+                       sqlMap.put(sql,record);\r
+                       record.setSql(sql);\r
+               }\r
+               record.callCountUp();\r
+               record.addTotalCostTime(costTime);\r
+               // executeを呼び出したクラス#メソッド名を取得\r
+               String method = MethodUtil.getMethodName(classname);\r
+               record.addMethodNames(method);\r
+\r
+               //logger.info("実行時間:"+ costTime+"msec "+ sql);\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfo(String sort){\r
+               List<StatsRecord> result = null;\r
+               if(sort.equals(SORT_METHOD)){\r
+                       result = getStatInfoByMethod();\r
+               }else if(sort.equals(SORT_SQL)){\r
+                       result = getStatInfoBySql();\r
+               }else if(sort.equals(SORT_TOTAL)){\r
+                       result = getStatInfoByTotal();\r
+               }else { // if(sort.equals(SORT_AVERAGE)){\r
+                       result = getStatInfoByAverage();\r
+\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByMethod(){\r
+               return getStatInfoByMethod(0,sqlMap.size());\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @param fromIndex\r
+        * @param toIndex\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByMethod(int fromIndex, int toIndex){\r
+               List<StatsRecord> list = new ArrayList<StatsRecord>(sqlMap.values());\r
+               Collections.sort(list, new Comparator<StatsRecord>(){\r
+                       public int compare(StatsRecord r1, StatsRecord r2){\r
+                               String s1 = (String)r1.getMethodNames().toArray()[0];\r
+                               String s2 = (String)r2.getMethodNames().toArray()[0];\r
+                               return s1.compareTo(s2);\r
+                       }\r
+               }\r
+               );\r
+\r
+               if(toIndex>list.size()){\r
+                       toIndex = list.size();\r
+               }\r
+\r
+               return list.subList(fromIndex, toIndex);\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoBySql(){\r
+               return getStatInfoBySql(0,sqlMap.size());\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @param fromIndex\r
+        * @param toIndex\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoBySql(int fromIndex, int toIndex){\r
+               List<StatsRecord> list = new ArrayList<StatsRecord>(sqlMap.values());\r
+               Collections.sort(list, new Comparator<StatsRecord>(){\r
+                       public int compare(StatsRecord r1, StatsRecord r2){\r
+                                       String s1 = r1.getSql();\r
+                                       String s2 = r2.getSql();\r
+                                       return s1.compareTo(s2);\r
+                       }\r
+               }\r
+               );\r
+\r
+               if(toIndex>list.size()){\r
+                       toIndex = list.size();\r
+               }\r
+\r
+               return list.subList(fromIndex, toIndex);\r
+       }\r
+\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByTotal(){\r
+               return getStatInfoByTotal(0,sqlMap.size());\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @param fromIndex\r
+        * @param toIndex\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByTotal(int fromIndex, int toIndex){\r
+               List<StatsRecord> list = new ArrayList<StatsRecord>(sqlMap.values());\r
+               Collections.sort(list, new Comparator<StatsRecord>(){\r
+                       public int compare(StatsRecord r1, StatsRecord r2){\r
+                               int result = -1;\r
+                               if(r1.getTotalCostTime() < r2.getTotalCostTime()){\r
+                                       result=1;\r
+                               }else if(r1.getTotalCostTime() == r2.getTotalCostTime()){\r
+                                       result=0;\r
+                               }\r
+                               return result;\r
+                       }\r
+               }\r
+               );\r
+\r
+               if(toIndex>list.size()){\r
+                       toIndex = list.size();\r
+               }\r
+\r
+               return list.subList(fromIndex, toIndex);\r
+       }\r
+\r
+       /**\r
+        * 合計実行時間別統計情報。\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByAverage(){\r
+               return getStatInfoByAverage(0,sqlMap.size());\r
+       }\r
+\r
+       /**\r
+        * 平均実行時間別統計情報。\r
+        * @param fromIndex\r
+        * @param toIndex\r
+        * @return\r
+        */\r
+       public List<StatsRecord> getStatInfoByAverage(int fromIndex, int toIndex){\r
+               List<StatsRecord> list = new ArrayList<StatsRecord>(sqlMap.values());\r
+               Collections.sort(list, new Comparator<StatsRecord>(){\r
+                       public int compare(StatsRecord r1, StatsRecord r2){\r
+                               int result = -1;\r
+                               if(r1.getAverage() < r2.getAverage()){\r
+                                       result=1;\r
+                               }else if(r1.getAverage() == r2.getAverage()){\r
+                                       result=0;\r
+                               }\r
+                               return result;\r
+                       }\r
+               }\r
+               );\r
+\r
+               if(toIndex>list.size()){\r
+                       toIndex = list.size();\r
+               }\r
+\r
+               return list.subList(fromIndex, toIndex);\r
+       }\r
+\r
+       /**\r
+        * コネクション貸し出し状況カウントアップ\r
+        *\r
+        */\r
+       public void getConnection(){\r
+               getConnectionTran(countConnMap, CLASSNAME);\r
+       }\r
+       public void getConnectionTran(){\r
+               getConnectionTran(countConnTranMap, CLASSNAME);\r
+       }\r
+       public void getConnection(String className){\r
+               getConnectionTran(countConnMap, className);\r
+       }\r
+       public void getConnectionTran(String className){\r
+               getConnectionTran(countConnTranMap, className);\r
+       }\r
+       private void getConnectionTran(Map<String, int[]> map, String className){\r
+               String method = MethodUtil.getMethodName(className).split(":")[0];      // 行番号は省く\r
+               synchronized (map) {\r
+                       int[] count = map.get(method);\r
+                       if(count==null){\r
+                               count = new int[2];\r
+                               count[COUNT_GET]=1;\r
+                               count[COUNT_RELEASE]=0;\r
+                               map.put(method,count);\r
+                       }else{\r
+                               count[COUNT_GET]++;\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * コネクション返却時の統計情報\r
+        *\r
+        */\r
+       public void releaseConnection(){\r
+               releaseConnection(countConnMap, CLASSNAME);\r
+       }\r
+       public void releaseConnectionTran(){\r
+               releaseConnection(countConnTranMap, CLASSNAME);\r
+       }\r
+       public void releaseConnection(String className){\r
+               releaseConnection(countConnMap, className);\r
+       }\r
+       public void releaseConnectionTran(String className){\r
+               releaseConnection(countConnTranMap, className);\r
+       }\r
+       private void releaseConnection(Map<String, int[]> map, String className){\r
+               String method = MethodUtil.getMethodName(className).split(":")[0];      // 行番号は省く\r
+               synchronized (map) {\r
+                       int[] count = map.get(method);\r
+                       if(count==null){\r
+                               logger.debug("貸し出してないメソッドから返却された。"+ method);\r
+                               count = new int[2];\r
+                               count[COUNT_GET]=0;\r
+                               count[COUNT_RELEASE]=1;\r
+                               map.put(method,count);\r
+                       }else{\r
+                               count[COUNT_RELEASE]++;\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * トランザクション管理\r
+        */\r
+       public void startTransaction(){\r
+               countTran(countTranMap, COUNT_STARTTRAN);\r
+       }\r
+       public void commit(){\r
+               countTran(countTranMap, COUNT_COMMIT);\r
+       }\r
+       public void rollback(){\r
+               countTran(countTranMap, COUNT_ROLLBACK);\r
+       }\r
+       public void startTransactionTran(){\r
+               countTran(countTranMap, COUNT_STARTTRAN_TRAN);\r
+       }\r
+       public void commitNoTran(){\r
+               countTran(countTranMap, COUNT_COMMIT_NOTRAN);\r
+       }\r
+       public void rollbackNoTran(){\r
+               countTran(countTranMap, COUNT_ROLLBACK_NOTRAN);\r
+       }\r
+       private void countTran(Map<String, int[]> map, int field){\r
+               String method = MethodUtil.getMethodName(CLASSNAME).split(":")[0];      // 行番号は省く\r
+               synchronized (map) {\r
+                       int[] count = map.get(method);\r
+                       if(count==null){\r
+                               logger.debug("新規:"+ method);\r
+                               count = new int[COUNT_ROLLBACK_NOTRAN+1];\r
+                               count[COUNT_STARTTRAN]=0;\r
+                               count[COUNT_COMMIT]=0;\r
+                               count[COUNT_ROLLBACK]=0;\r
+                               count[COUNT_STARTTRAN_TRAN]=0;\r
+                               count[COUNT_COMMIT_NOTRAN]=0;\r
+                               count[COUNT_ROLLBACK_NOTRAN]=0;\r
+                               map.put(method,count);\r
+                       }\r
+                       count[field]++;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * コネクション貸出状況。\r
+        * コネクション貸し出し中一覧を表示。\r
+        *\r
+        * @return String\r
+        */\r
+       public String viewConnectionPool(){\r
+               // 統計情報を取っていない場合\r
+               if(countConnMap.size()==0){\r
+                       return "no stats data.";\r
+               }\r
+\r
+               String result = viewConnectionPool(countConnMap);\r
+               result += "Transaction Connection\n";\r
+               result += viewConnectionPool(countConnTranMap);\r
+               result += "Transaction/Commit/Rollback\n";\r
+               result += viewTran(countTranMap);\r
+\r
+               return result;\r
+       }\r
+\r
+       private String viewConnectionPool(Map<String, int[]> map){\r
+               Collection<String> col = map.keySet();\r
+               List<String> list = new ArrayList<String>(col.size());\r
+               for(Iterator<String> ite=col.iterator(); ite.hasNext();){\r
+                       list.add(ite.next());\r
+               }\r
+               Collections.sort(list);\r
+\r
+               StringBuffer buf = new StringBuffer();\r
+               buf.append("Connection List\n");\r
+               for(int i=0; i<list.size(); i++){\r
+                       int[] count = map.get(list.get(i));\r
+                       buf.append(\r
+                         list.get(i)\r
+                         +"\t:"+ count[COUNT_GET]\r
+                         +"\t:"+ count[COUNT_RELEASE]\r
+                         +"\t:"+ (count[COUNT_GET]-count[COUNT_RELEASE]) +"\n");\r
+               }\r
+               return buf.toString();\r
+       }\r
+\r
+       private String viewTran(Map<String, int[]> map){\r
+               Collection<String> col = map.keySet();\r
+               List<String> list = new ArrayList<String>(col.size());\r
+               for(Iterator<String> ite=col.iterator(); ite.hasNext();){\r
+                       list.add(ite.next());\r
+               }\r
+               Collections.sort(list);\r
+\r
+               StringBuffer buf = new StringBuffer();\r
+               buf.append("Connection List\n");\r
+               for(int i=0; i<list.size(); i++){\r
+                       int[] count = map.get(list.get(i));\r
+                       buf.append(\r
+                         list.get(i)\r
+                         +"\t:"+ count[COUNT_STARTTRAN]\r
+                         +"\t:"+ count[COUNT_COMMIT]\r
+                         +"\t:"+ count[COUNT_ROLLBACK]\r
+                         +"\t("+ count[COUNT_STARTTRAN_TRAN]\r
+                         +"\t:"+ count[COUNT_COMMIT_NOTRAN]\r
+                         +"\t:"+ count[COUNT_ROLLBACK_NOTRAN]\r
+                         +")\t:"+ (count[COUNT_STARTTRAN]-(count[COUNT_COMMIT]+count[COUNT_ROLLBACK])) +"\n");\r
+               }\r
+               return buf.toString();\r
+       }\r
+}\r
+\r
+\r
diff --git a/src/com/lavans/luz2/sql/stats/StatsCallableStatement.java b/src/com/lavans/luz2/sql/stats/StatsCallableStatement.java
new file mode 100644 (file)
index 0000000..c04650a
--- /dev/null
@@ -0,0 +1,1027 @@
+/* $Id: StatsCallableStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/08/13\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.Ref;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class StatsCallableStatement extends StatsPreparedStatement implements CallableStatement{\r
+       /** 処理委譲先。 */\r
+       private CallableStatement st=null;\r
+\r
+       /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */\r
+//     private static final String CLASSNAME=StatsPreparedStatement.class.getName();\r
+\r
+       /**\r
+        * 統計採取クラス。\r
+        */\r
+//     private Statistics stat = Statistics.getInstance();\r
+\r
+       /**\r
+        * ログを採るSQL文。\r
+        */\r
+//     private String sql = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param st\r
+        * @param sql\r
+        */\r
+       public StatsCallableStatement(CallableStatement st, String sql) {\r
+               super(st, sql);\r
+               this.st = st;\r
+//             this.sql = sql;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getArray(int)\r
+        */\r
+       public Array getArray(int i) throws SQLException {\r
+               return st.getArray(i);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getArray(java.lang.String)\r
+        */\r
+       public Array getArray(String parameterName) throws SQLException {\r
+               return st.getArray(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.CallableStatement#getBigDecimal(int, int)\r
+        * @deprecated\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex, int scale)\r
+               throws SQLException {\r
+               return st.getBigDecimal(parameterIndex, scale);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBigDecimal(int)\r
+        */\r
+       public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {\r
+               return st.getBigDecimal(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBigDecimal(java.lang.String)\r
+        */\r
+       public BigDecimal getBigDecimal(String parameterName) throws SQLException {\r
+               return st.getBigDecimal(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBlob(int)\r
+        */\r
+       public Blob getBlob(int i) throws SQLException {\r
+               return getBlob(i);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBlob(java.lang.String)\r
+        */\r
+       public Blob getBlob(String parameterName) throws SQLException {\r
+               return st.getBlob(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBoolean(int)\r
+        */\r
+       public boolean getBoolean(int parameterIndex) throws SQLException {\r
+               return st.getBoolean(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBoolean(java.lang.String)\r
+        */\r
+       public boolean getBoolean(String parameterName) throws SQLException {\r
+               return st.getBoolean(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getByte(int)\r
+        */\r
+       public byte getByte(int parameterIndex) throws SQLException {\r
+               return st.getByte(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getByte(java.lang.String)\r
+        */\r
+       public byte getByte(String parameterName) throws SQLException {\r
+               return st.getByte(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBytes(int)\r
+        */\r
+       public byte[] getBytes(int parameterIndex) throws SQLException {\r
+               return st.getBytes(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getBytes(java.lang.String)\r
+        */\r
+       public byte[] getBytes(String parameterName) throws SQLException {\r
+               return st.getBytes(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getClob(int)\r
+        */\r
+       public Clob getClob(int i) throws SQLException {\r
+               return getClob(i);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getClob(java.lang.String)\r
+        */\r
+       public Clob getClob(String parameterName) throws SQLException {\r
+               return st.getClob(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)\r
+        */\r
+       public Date getDate(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getDate(parameterIndex,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(int)\r
+        */\r
+       public Date getDate(int parameterIndex) throws SQLException {\r
+               return st.getDate(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Date getDate(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return st.getDate(parameterName,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDate(java.lang.String)\r
+        */\r
+       public Date getDate(String parameterName) throws SQLException {\r
+               return st.getDate(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDouble(int)\r
+        */\r
+       public double getDouble(int parameterIndex) throws SQLException {\r
+               return st.getDouble(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getDouble(java.lang.String)\r
+        */\r
+       public double getDouble(String parameterName) throws SQLException {\r
+               return st.getDouble(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getFloat(int)\r
+        */\r
+       public float getFloat(int parameterIndex) throws SQLException {\r
+               return st.getFloat(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getFloat(java.lang.String)\r
+        */\r
+       public float getFloat(String parameterName) throws SQLException {\r
+               return st.getFloat(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getInt(int)\r
+        */\r
+       public int getInt(int parameterIndex) throws SQLException {\r
+               return st.getInt(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getInt(java.lang.String)\r
+        */\r
+       public int getInt(String parameterName) throws SQLException {\r
+               return st.getInt(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getLong(int)\r
+        */\r
+       public long getLong(int parameterIndex) throws SQLException {\r
+               return st.getLong(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getLong(java.lang.String)\r
+        */\r
+       public long getLong(String parameterName) throws SQLException {\r
+               return st.getLong(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(int, java.util.Map)\r
+        */\r
+       public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {\r
+               return st.getObject(i,map);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(int)\r
+        */\r
+       public Object getObject(int parameterIndex) throws SQLException {\r
+               return st.getObject(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String, java.util.Map)\r
+        */\r
+       public Object getObject(String parameterName, Map<String, Class<?>> map)\r
+               throws SQLException {\r
+               return st.getObject(parameterName,map);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getObject(java.lang.String)\r
+        */\r
+       public Object getObject(String parameterName) throws SQLException {\r
+               return st.getObject(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getRef(int)\r
+        */\r
+       public Ref getRef(int i) throws SQLException {\r
+               return st.getRef(i);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getRef(java.lang.String)\r
+        */\r
+       public Ref getRef(String parameterName) throws SQLException {\r
+               return st.getRef(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getShort(int)\r
+        */\r
+       public short getShort(int parameterIndex) throws SQLException {\r
+               return st.getShort(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getShort(java.lang.String)\r
+        */\r
+       public short getShort(String parameterName) throws SQLException {\r
+               return st.getShort(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getString(int)\r
+        */\r
+       public String getString(int parameterIndex) throws SQLException {\r
+               return st.getString(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getString(java.lang.String)\r
+        */\r
+       public String getString(String parameterName) throws SQLException {\r
+               return st.getString(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)\r
+        */\r
+       public Time getTime(int parameterIndex, Calendar cal) throws SQLException {\r
+               return st.getTime(parameterIndex,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(int)\r
+        */\r
+       public Time getTime(int parameterIndex) throws SQLException {\r
+               return st.getTime(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Time getTime(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return st.getTime(parameterName,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTime(java.lang.String)\r
+        */\r
+       public Time getTime(String parameterName) throws SQLException {\r
+               return st.getTime(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex, Calendar cal)\r
+               throws SQLException {\r
+               return st.getTimestamp(parameterIndex,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(int)\r
+        */\r
+       public Timestamp getTimestamp(int parameterIndex) throws SQLException {\r
+               return st.getTimestamp(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String, java.util.Calendar)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName, Calendar cal)\r
+               throws SQLException {\r
+               return st.getTimestamp(parameterName,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getTimestamp(java.lang.String)\r
+        */\r
+       public Timestamp getTimestamp(String parameterName) throws SQLException {\r
+               return st.getTimestamp(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getURL(int)\r
+        */\r
+       public URL getURL(int parameterIndex) throws SQLException {\r
+               return st.getURL(parameterIndex);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#getURL(java.lang.String)\r
+        */\r
+       public URL getURL(String parameterName) throws SQLException {\r
+               return st.getURL(parameterName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, int)\r
+        */\r
+       public void registerOutParameter(\r
+               int parameterIndex,\r
+               int sqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               st.registerOutParameter(parameterIndex,sqlType,scale);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(\r
+               int paramIndex,\r
+               int sqlType,\r
+               String typeName)\r
+               throws SQLException {\r
+               st.registerOutParameter(paramIndex,sqlType,typeName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(int, int)\r
+        */\r
+       public void registerOutParameter(int parameterIndex, int sqlType)\r
+               throws SQLException {\r
+               st.registerOutParameter(parameterIndex,sqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, int)\r
+        */\r
+       public void registerOutParameter(\r
+               String parameterName,\r
+               int sqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               st.registerOutParameter(parameterName,sqlType,scale);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void registerOutParameter(\r
+               String parameterName,\r
+               int sqlType,\r
+               String typeName)\r
+               throws SQLException {\r
+               st.registerOutParameter(parameterName,sqlType,typeName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#registerOutParameter(java.lang.String, int)\r
+        */\r
+       public void registerOutParameter(String parameterName, int sqlType)\r
+               throws SQLException {\r
+               st.registerOutParameter(parameterName,sqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, int length)\r
+               throws SQLException {\r
+               st.setAsciiStream(parameterName,x,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBigDecimal(java.lang.String, java.math.BigDecimal)\r
+        */\r
+       public void setBigDecimal(String parameterName, BigDecimal x)\r
+               throws SQLException {\r
+               st.setBigDecimal(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(\r
+               String parameterName,\r
+               InputStream x,\r
+               int length)\r
+               throws SQLException {\r
+               st.setBinaryStream(parameterName,x,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBoolean(java.lang.String, boolean)\r
+        */\r
+       public void setBoolean(String parameterName, boolean x)\r
+               throws SQLException {\r
+               st.setBoolean(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setByte(java.lang.String, byte)\r
+        */\r
+       public void setByte(String parameterName, byte x) throws SQLException {\r
+               st.setByte(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setBytes(java.lang.String, byte[])\r
+        */\r
+       public void setBytes(String parameterName, byte[] x) throws SQLException {\r
+               st.setBytes(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(\r
+               String parameterName,\r
+               Reader reader,\r
+               int length)\r
+               throws SQLException {\r
+               st.setCharacterStream(parameterName,reader,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(String parameterName, Date x, Calendar cal)\r
+               throws SQLException {\r
+               st.setDate(parameterName,x,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date)\r
+        */\r
+       public void setDate(String parameterName, Date x) throws SQLException {\r
+               st.setDate(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setDouble(java.lang.String, double)\r
+        */\r
+       public void setDouble(String parameterName, double x) throws SQLException {\r
+               st.setDouble(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setFloat(java.lang.String, float)\r
+        */\r
+       public void setFloat(String parameterName, float x) throws SQLException {\r
+               st.setFloat(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setInt(java.lang.String, int)\r
+        */\r
+       public void setInt(String parameterName, int x) throws SQLException {\r
+               st.setInt(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setLong(java.lang.String, long)\r
+        */\r
+       public void setLong(String parameterName, long x) throws SQLException {\r
+               st.setLong(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int, java.lang.String)\r
+        */\r
+       public void setNull(String parameterName, int sqlType, String typeName)\r
+               throws SQLException {\r
+               st.setNull(parameterName,sqlType,typeName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setNull(java.lang.String, int)\r
+        */\r
+       public void setNull(String parameterName, int sqlType)\r
+               throws SQLException {\r
+               st.setNull(parameterName,sqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(\r
+               String parameterName,\r
+               Object x,\r
+               int targetSqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               st.setObject(parameterName,x,targetSqlType,scale);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object, int)\r
+        */\r
+       public void setObject(String parameterName, Object x, int targetSqlType)\r
+               throws SQLException {\r
+               st.setObject(parameterName,x,targetSqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setObject(java.lang.String, java.lang.Object)\r
+        */\r
+       public void setObject(String parameterName, Object x) throws SQLException {\r
+               st.setObject(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setShort(java.lang.String, short)\r
+        */\r
+       public void setShort(String parameterName, short x) throws SQLException {\r
+               st.setShort(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setString(String parameterName, String x) throws SQLException {\r
+               st.setString(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(String parameterName, Time x, Calendar cal)\r
+               throws SQLException {\r
+               st.setTime(parameterName,x,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time)\r
+        */\r
+       public void setTime(String parameterName, Time x) throws SQLException {\r
+               st.setTime(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x, Calendar cal)\r
+               throws SQLException {\r
+               st.setTimestamp(parameterName,x,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setTimestamp(java.lang.String, java.sql.Timestamp)\r
+        */\r
+       public void setTimestamp(String parameterName, Timestamp x)\r
+               throws SQLException {\r
+               st.setTimestamp(parameterName,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)\r
+        */\r
+       public void setURL(String parameterName, URL val) throws SQLException {\r
+               st.setURL(parameterName,val);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.CallableStatement#wasNull()\r
+        */\r
+       public boolean wasNull() throws SQLException {\r
+               return st.wasNull();\r
+       }\r
+\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(int)\r
+        */\r
+       public Reader getCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getCharacterStream(String parameterName) throws SQLException {\r
+               return st.getCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(int)\r
+        */\r
+       public Reader getNCharacterStream(int parameterIndex) throws SQLException {\r
+               return st.getNCharacterStream(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)\r
+        */\r
+       public Reader getNCharacterStream(String parameterName) throws SQLException {\r
+               return st.getNCharacterStream(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(int)\r
+        */\r
+       public NClob getNClob(int parameterIndex) throws SQLException {\r
+               return st.getNClob(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNClob(java.lang.String)\r
+        */\r
+       public NClob getNClob(String parameterName) throws SQLException {\r
+               return st.getNClob(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(int)\r
+        */\r
+       public String getNString(int parameterIndex) throws SQLException {\r
+               return st.getNString(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getNString(java.lang.String)\r
+        */\r
+       public String getNString(String parameterName) throws SQLException {\r
+               return st.getNString(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(int)\r
+        */\r
+       public RowId getRowId(int parameterIndex) throws SQLException {\r
+               return st.getRowId(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getRowId(java.lang.String)\r
+        */\r
+       public RowId getRowId(String parameterName) throws SQLException {\r
+               return st.getRowId(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(int)\r
+        */\r
+       public SQLXML getSQLXML(int parameterIndex) throws SQLException {\r
+               return st.getSQLXML(parameterIndex);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#getSQLXML(java.lang.String)\r
+        */\r
+       public SQLXML getSQLXML(String parameterName) throws SQLException {\r
+               return st.getSQLXML(parameterName);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setAsciiStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBinaryStream(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(String parameterName, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.sql.Blob)\r
+        */\r
+       public void setBlob(String parameterName, Blob x) throws SQLException {\r
+               st.setBlob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream,\r
+                       long length) throws SQLException {\r
+               st.setBlob(parameterName, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setBlob(java.lang.String, java.io.InputStream)\r
+        */\r
+       public void setBlob(String parameterName, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterName, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.sql.Clob)\r
+        */\r
+       public void setClob(String parameterName, Clob x) throws SQLException {\r
+               st.setClob(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterName, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNCharacterStream(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(String parameterName, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.sql.NClob)\r
+        */\r
+       public void setNClob(String parameterName, NClob value) throws SQLException {\r
+               st.setNClob(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader, long)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNClob(java.lang.String, java.io.Reader)\r
+        */\r
+       public void setNClob(String parameterName, Reader reader)\r
+                       throws SQLException {\r
+               st.setNClob(parameterName, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setNString(java.lang.String, java.lang.String)\r
+        */\r
+       public void setNString(String parameterName, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterName, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setRowId(java.lang.String, java.sql.RowId)\r
+        */\r
+       public void setRowId(String parameterName, RowId x) throws SQLException {\r
+               st.setRowId(parameterName, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterName\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.CallableStatement#setSQLXML(java.lang.String, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(String parameterName, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterName, xmlObject);\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/stats/StatsConnection.java b/src/com/lavans/luz2/sql/stats/StatsConnection.java
new file mode 100644 (file)
index 0000000..d06f6f6
--- /dev/null
@@ -0,0 +1,457 @@
+/* $Id: StatsConnection.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.CallableStatement;\r
+import java.sql.Clob;\r
+import java.sql.Connection;\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.NClob;\r
+import java.sql.PreparedStatement;\r
+import java.sql.SQLClientInfoException;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.SQLXML;\r
+import java.sql.Savepoint;\r
+import java.sql.Statement;\r
+import java.sql.Struct;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class StatsConnection implements Connection {\r
+       /** 処理移譲先 */\r
+       private Connection con=null;\r
+       /**\r
+        * コンストラクタ。\r
+        */\r
+       public StatsConnection(Connection con){\r
+               this.con = con;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement()\r
+        */\r
+       public Statement createStatement() throws SQLException {\r
+               return new StatsStatement(con.createStatement());\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement(int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               return new StatsStatement(con.createStatement(resultSetType, resultSetConcurrency));\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#createStatement(int, int, int)\r
+        */\r
+       public Statement createStatement(\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               return new StatsStatement(con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String)\r
+        */\r
+       public CallableStatement prepareCall(String sql) throws SQLException {\r
+               return new StatsCallableStatement(con.prepareCall(sql),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               return new StatsCallableStatement(con.prepareCall(sql,resultSetType,resultSetConcurrency),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)\r
+        */\r
+       public CallableStatement prepareCall(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               return new StatsCallableStatement(con.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String)\r
+        */\r
+       public PreparedStatement prepareStatement(String sql) throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int autoGeneratedKeys)\r
+               throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql,autoGeneratedKeys),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency)\r
+               throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql,resultSetType, resultSetConcurrency),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int)\r
+        */\r
+       public PreparedStatement prepareStatement(\r
+               String sql,\r
+               int resultSetType,\r
+               int resultSetConcurrency,\r
+               int resultSetHoldability)\r
+               throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql,resultSetType, resultSetConcurrency, resultSetHoldability),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, int[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql,columnIndexes),sql);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])\r
+        */\r
+       public PreparedStatement prepareStatement(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               return new StatsPreparedStatement(con.prepareStatement(sql,columnNames),sql);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getHoldability()\r
+        */\r
+       public int getHoldability() throws SQLException {\r
+               return con.getHoldability();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTransactionIsolation()\r
+        */\r
+       public int getTransactionIsolation() throws SQLException {\r
+               return con.getTransactionIsolation();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               con.clearWarnings();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               con.close();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#commit()\r
+        */\r
+       public void commit() throws SQLException {\r
+               con.commit();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#rollback()\r
+        */\r
+       public void rollback() throws SQLException {\r
+               con.rollback();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getAutoCommit()\r
+        */\r
+       public boolean getAutoCommit() throws SQLException {\r
+               return con.getAutoCommit();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return con.isClosed();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#isReadOnly()\r
+        */\r
+       public boolean isReadOnly() throws SQLException {\r
+               return con.isReadOnly();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setHoldability(int)\r
+        */\r
+       public void setHoldability(int holdability) throws SQLException {\r
+               con.setHoldability(holdability);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTransactionIsolation(int)\r
+        */\r
+       public void setTransactionIsolation(int level) throws SQLException {\r
+               con.setTransactionIsolation(level);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setAutoCommit(boolean)\r
+        */\r
+       public void setAutoCommit(boolean autoCommit) throws SQLException {\r
+               con.setAutoCommit(autoCommit);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setReadOnly(boolean)\r
+        */\r
+       public void setReadOnly(boolean readOnly) throws SQLException {\r
+               con.setReadOnly(readOnly);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getCatalog()\r
+        */\r
+       public String getCatalog() throws SQLException {\r
+               return con.getCatalog();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setCatalog(java.lang.String)\r
+        */\r
+       public void setCatalog(String catalog) throws SQLException {\r
+               con.setCatalog(catalog);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getMetaData()\r
+        */\r
+       public DatabaseMetaData getMetaData() throws SQLException {\r
+               return con.getMetaData();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return con.getWarnings();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setSavepoint()\r
+        */\r
+       public Savepoint setSavepoint() throws SQLException {\r
+               return con.setSavepoint();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)\r
+        */\r
+       public void releaseSavepoint(Savepoint savepoint) throws SQLException {\r
+               con.releaseSavepoint(savepoint);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#rollback(java.sql.Savepoint)\r
+        */\r
+       public void rollback(Savepoint savepoint) throws SQLException {\r
+               con.rollback(savepoint);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#getTypeMap()\r
+        */\r
+       public Map<String, Class<?>> getTypeMap() throws SQLException {\r
+               return con.getTypeMap();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setTypeMap(java.util.Map)\r
+        */\r
+       public void setTypeMap(Map<String, Class<?>> map) throws SQLException {\r
+               con.setTypeMap(map);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#nativeSQL(java.lang.String)\r
+        */\r
+       public String nativeSQL(String sql) throws SQLException {\r
+               return con.nativeSQL(sql);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Connection#setSavepoint(java.lang.String)\r
+        */\r
+       public Savepoint setSavepoint(String name) throws SQLException {\r
+               return con.setSavepoint(name);\r
+       }\r
+\r
+       /**\r
+        * @param typeName\r
+        * @param elements\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createArrayOf(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Array createArrayOf(String typeName, Object[] elements)\r
+                       throws SQLException {\r
+               return con.createArrayOf(typeName, elements);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createBlob()\r
+        */\r
+       public Blob createBlob() throws SQLException {\r
+               return con.createBlob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createClob()\r
+        */\r
+       public Clob createClob() throws SQLException {\r
+               return con.createClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createNClob()\r
+        */\r
+       public NClob createNClob() throws SQLException {\r
+               return con.createNClob();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createSQLXML()\r
+        */\r
+       public SQLXML createSQLXML() throws SQLException {\r
+               return con.createSQLXML();\r
+       }\r
+\r
+       /**\r
+        * @param typeName\r
+        * @param attributes\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#createStruct(java.lang.String, java.lang.Object[])\r
+        */\r
+       public Struct createStruct(String typeName, Object[] attributes)\r
+                       throws SQLException {\r
+               return con.createStruct(typeName, attributes);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo()\r
+        */\r
+       public Properties getClientInfo() throws SQLException {\r
+               return con.getClientInfo();\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#getClientInfo(java.lang.String)\r
+        */\r
+       public String getClientInfo(String name) throws SQLException {\r
+               return con.getClientInfo(name);\r
+       }\r
+\r
+       /**\r
+        * @param timeout\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Connection#isValid(int)\r
+        */\r
+       public boolean isValid(int timeout) throws SQLException {\r
+               return con.isValid(timeout);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return con.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param properties\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.util.Properties)\r
+        */\r
+       public void setClientInfo(Properties properties)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(properties);\r
+       }\r
+\r
+       /**\r
+        * @param name\r
+        * @param value\r
+        * @throws SQLClientInfoException\r
+        * @see java.sql.Connection#setClientInfo(java.lang.String, java.lang.String)\r
+        */\r
+       public void setClientInfo(String name, String value)\r
+                       throws SQLClientInfoException {\r
+               con.setClientInfo(name, value);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/sql/stats/StatsPreparedStatement.java b/src/com/lavans/luz2/sql/stats/StatsPreparedStatement.java
new file mode 100644 (file)
index 0000000..9b11f71
--- /dev/null
@@ -0,0 +1,630 @@
+/* $Id: StatsPreparedStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.io.InputStream;\r
+import java.io.Reader;\r
+import java.math.BigDecimal;\r
+import java.net.URL;\r
+import java.sql.Array;\r
+import java.sql.Blob;\r
+import java.sql.Clob;\r
+import java.sql.Date;\r
+import java.sql.NClob;\r
+import java.sql.ParameterMetaData;\r
+import java.sql.PreparedStatement;\r
+import java.sql.Ref;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.RowId;\r
+import java.sql.SQLException;\r
+import java.sql.SQLXML;\r
+import java.sql.Time;\r
+import java.sql.Timestamp;\r
+import java.util.Calendar;\r
+\r
+import com.lavans.luz2.sql.logging.Loggable;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+/**\r
+ * @author Yuki\r
+ *\r
+ */\r
+public class StatsPreparedStatement\r
+       extends StatsStatement\r
+       implements PreparedStatement, Loggable {\r
+\r
+       /** 処理移譲先。 */\r
+       private PreparedStatement st=null;\r
+\r
+       /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */\r
+       private static String className=StatsPreparedStatement.class.getName();\r
+\r
+       /**\r
+        * 統計採取クラス。\r
+        */\r
+       private Statistics stat = Statistics.getInstance();\r
+\r
+       /**\r
+        * ログを採るSQL文。\r
+        */\r
+       private String logsql = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param st\r
+        */\r
+       public StatsPreparedStatement(PreparedStatement st, String sql) {\r
+               super(st);\r
+               this.st  = st;\r
+               this.logsql = sql;\r
+       }\r
+       \r
+       /**\r
+        * 呼び出し元クラス名の変更。\r
+        * デフォルトではcon.execute()を呼び出したクラス名。\r
+        * それよりも前のスタックのクラス名を表示したい場合は\r
+        * ここに指定する。指定したクラス名がスタックトレース上にない場合\r
+        * うまく取得できなくなるので注意。\r
+        * \r
+        * @param className\r
+        */\r
+       public static void setClassName(String className){\r
+               StatsPreparedStatement.className = className;\r
+       }\r
+       \r
+       /**\r
+        * ログ採取用に別の文字列を使用する場合に設定する。\r
+        * BindPreparedConnectionにおいて"?"に変換前のsqlを出力するのに使用。\r
+        * @param string\r
+        */\r
+       public void setLogsql(String string) {\r
+               logsql = string;\r
+\r
+               // 移譲先もLoggableな場合は移譲先にもlog用sqlを渡す。\r
+               if(st instanceof Loggable){\r
+                       ((Loggable)st).setLogsql(logsql);\r
+               }\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#executeQuery()\r
+        */\r
+       public ResultSet executeQuery() throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               ResultSet result = st.executeQuery();\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(logsql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#executeUpdate()\r
+        */\r
+       public int executeUpdate() throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               int result = st.executeUpdate();\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(logsql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#execute()\r
+        */\r
+       public boolean execute() throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               boolean result = st.execute();\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(logsql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+\r
+\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#addBatch()\r
+        */\r
+       public void addBatch() throws SQLException {\r
+               st.addBatch();\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#clearParameters()\r
+        */\r
+       public void clearParameters() throws SQLException {\r
+               st.clearParameters();\r
+\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setByte(int, byte)\r
+        */\r
+       public void setByte(int parameterIndex, byte x) throws SQLException {\r
+               st.setByte(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDouble(int, double)\r
+        */\r
+       public void setDouble(int parameterIndex, double x) throws SQLException {\r
+               st.setDouble(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setFloat(int, float)\r
+        */\r
+       public void setFloat(int parameterIndex, float x) throws SQLException {\r
+               st.setFloat(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setInt(int, int)\r
+        */\r
+       public void setInt(int parameterIndex, int x) throws SQLException {\r
+               st.setInt(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setNull(int, int)\r
+        */\r
+       public void setNull(int parameterIndex, int sqlType) throws SQLException {\r
+               st.setNull(parameterIndex,sqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setLong(int, long)\r
+        */\r
+       public void setLong(int parameterIndex, long x) throws SQLException {\r
+               st.setLong(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setShort(int, short)\r
+        */\r
+       public void setShort(int parameterIndex, short x) throws SQLException {\r
+               st.setShort(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBoolean(int, boolean)\r
+        */\r
+       public void setBoolean(int parameterIndex, boolean x) throws SQLException {\r
+               st.setBoolean(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBytes(int, byte[])\r
+        */\r
+       public void setBytes(int parameterIndex, byte[] x) throws SQLException {\r
+               st.setBytes(parameterIndex,x);\r
+       }\r
+\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, int)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               st.setAsciiStream(parameterIndex,x,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               st.setBinaryStream(parameterIndex,x,length);\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.PreparedStatement#setUnicodeStream(int, java.io.InputStream, int)\r
+        * @deprecated\r
+        */\r
+       public  void setUnicodeStream(int parameterIndex, InputStream x, int length)\r
+               throws SQLException {\r
+               st.setUnicodeStream(parameterIndex,x,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)\r
+        */\r
+       public void setCharacterStream(\r
+               int parameterIndex,\r
+               Reader reader,\r
+               int length)\r
+               throws SQLException {\r
+               st.setCharacterStream(parameterIndex,reader,length);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)\r
+        */\r
+       public void setObject(int parameterIndex, Object x) throws SQLException {\r
+               st.setObject(parameterIndex,x);\r
+\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)\r
+        */\r
+       public void setObject(int parameterIndex, Object x, int targetSqlType)\r
+               throws SQLException {\r
+               st.setObject(parameterIndex,x,targetSqlType);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int, int)\r
+        */\r
+       public void setObject(\r
+               int parameterIndex,\r
+               Object x,\r
+               int targetSqlType,\r
+               int scale)\r
+               throws SQLException {\r
+               st.setObject(parameterIndex,x,targetSqlType,scale);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)\r
+        */\r
+       public void setNull(int paramIndex, int sqlType, String typeName)\r
+               throws SQLException {\r
+               st.setNull(paramIndex,sqlType,typeName);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setString(int, java.lang.String)\r
+        */\r
+       public void setString(int parameterIndex, String x) throws SQLException {\r
+               st.setString(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)\r
+        */\r
+       public void setBigDecimal(int parameterIndex, BigDecimal x)\r
+               throws SQLException {\r
+               st.setBigDecimal(parameterIndex,x);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setURL(int, java.net.URL)\r
+        */\r
+       public void setURL(int parameterIndex, URL x) throws SQLException {\r
+               st.setURL(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)\r
+        */\r
+       public void setArray(int i, Array x) throws SQLException {\r
+               st.setArray(i,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)\r
+        */\r
+       public void setBlob(int i, Blob x) throws SQLException {\r
+               st.setBlob(i,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)\r
+        */\r
+       public void setClob(int i, Clob x) throws SQLException {\r
+               st.setClob(i,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)\r
+        */\r
+       public void setDate(int parameterIndex, Date x) throws SQLException {\r
+               st.setDate(parameterIndex,x);\r
+\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#getParameterMetaData()\r
+        */\r
+       public ParameterMetaData getParameterMetaData() throws SQLException {\r
+               return st.getParameterMetaData();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)\r
+        */\r
+       public void setRef(int i, Ref x) throws SQLException {\r
+               st.setRef(i,x);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#getMetaData()\r
+        */\r
+       public ResultSetMetaData getMetaData() throws SQLException {\r
+               return st.getMetaData();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)\r
+        */\r
+       public void setTime(int parameterIndex, Time x) throws SQLException {\r
+               st.setTime(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x)\r
+               throws SQLException {\r
+               st.setTimestamp(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setDate(int, java.sql.Date, java.util.Calendar)\r
+        */\r
+       public void setDate(int parameterIndex, Date x, Calendar cal)\r
+               throws SQLException {\r
+               st.setDate(parameterIndex,x);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTime(int, java.sql.Time, java.util.Calendar)\r
+        */\r
+       public void setTime(int parameterIndex, Time x, Calendar cal)\r
+               throws SQLException {\r
+               st.setTime(parameterIndex,x,cal);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar)\r
+        */\r
+       public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)\r
+               throws SQLException {\r
+               st.setTimestamp(parameterIndex,x,cal);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream)\r
+        */\r
+       public void setAsciiStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setAsciiStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x, long length)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream)\r
+        */\r
+       public void setBinaryStream(int parameterIndex, InputStream x)\r
+                       throws SQLException {\r
+               st.setBinaryStream(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream, long length)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param inputStream\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream)\r
+        */\r
+       public void setBlob(int parameterIndex, InputStream inputStream)\r
+                       throws SQLException {\r
+               st.setBlob(parameterIndex, inputStream);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader,\r
+                       long length) throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setCharacterStream(int parameterIndex, Reader reader)\r
+                       throws SQLException {\r
+               st.setCharacterStream(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setClob(int, java.io.Reader)\r
+        */\r
+       public void setClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value,\r
+                       long length) throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader)\r
+        */\r
+       public void setNCharacterStream(int parameterIndex, Reader value)\r
+                       throws SQLException {\r
+               st.setNCharacterStream(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)\r
+        */\r
+       public void setNClob(int parameterIndex, NClob value) throws SQLException {\r
+               st.setNClob(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @param length\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader, long length)\r
+                       throws SQLException {\r
+               st.setNClob(parameterIndex, reader, length);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param reader\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader)\r
+        */\r
+       public void setNClob(int parameterIndex, Reader reader) throws SQLException {\r
+               st.setNClob(parameterIndex, reader);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param value\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setNString(int, java.lang.String)\r
+        */\r
+       public void setNString(int parameterIndex, String value)\r
+                       throws SQLException {\r
+               st.setNString(parameterIndex, value);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param x\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId)\r
+        */\r
+       public void setRowId(int parameterIndex, RowId x) throws SQLException {\r
+               st.setRowId(parameterIndex, x);\r
+       }\r
+\r
+       /**\r
+        * @param parameterIndex\r
+        * @param xmlObject\r
+        * @throws SQLException\r
+        * @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML)\r
+        */\r
+       public void setSQLXML(int parameterIndex, SQLXML xmlObject)\r
+                       throws SQLException {\r
+               st.setSQLXML(parameterIndex, xmlObject);\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       @Override\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @Override\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+\r
+\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/stats/StatsRecord.java b/src/com/lavans/luz2/sql/stats/StatsRecord.java
new file mode 100644 (file)
index 0000000..1cf952b
--- /dev/null
@@ -0,0 +1,99 @@
+/* $Id: StatsRecord.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.util.Set;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class StatsRecord {\r
+       private String sql=null;\r
+       private int callCount = 0;\r
+       private long totalCostTime = 0;\r
+       private Set<String> methodNames = new TreeSet<String>();\r
+\r
+       public double getAverage(){\r
+               return totalCostTime / (double)callCount;\r
+       }\r
+       /**\r
+        * @return\r
+        */\r
+       public int getCallCount() {\r
+               return callCount;\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        */\r
+       public void setCallCount(int i) {\r
+               callCount = i;\r
+       }\r
+\r
+       /**\r
+        * @param i\r
+        */\r
+       public void callCountUp() {\r
+               callCount++;\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       public Set<String> getMethodNames() {\r
+               return methodNames;\r
+       }\r
+\r
+       /**\r
+        * @param set\r
+        */\r
+       public void setMethodNames(Set<String> set) {\r
+               methodNames = set;\r
+       }\r
+\r
+       /**\r
+        * @param set\r
+        */\r
+       public void addMethodNames(String s) {\r
+               methodNames.add(s);\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        */\r
+       public String getSql() {\r
+               return sql;\r
+       }\r
+\r
+       /**\r
+        * @param string\r
+        */\r
+       public void setSql(String string) {\r
+               sql = string;\r
+       }\r
+       /**\r
+        * @return\r
+        */\r
+       public long getTotalCostTime() {\r
+               return totalCostTime;\r
+       }\r
+\r
+       /**\r
+        * @param l\r
+        */\r
+       public void setTotalCostTime(long l) {\r
+               totalCostTime = l;\r
+       }\r
+\r
+       /**\r
+        * @param l\r
+        */\r
+       public void addTotalCostTime(long l) {\r
+               totalCostTime += l;\r
+       }\r
+\r
+}\r
diff --git a/src/com/lavans/luz2/sql/stats/StatsStatement.java b/src/com/lavans/luz2/sql/stats/StatsStatement.java
new file mode 100644 (file)
index 0000000..df87298
--- /dev/null
@@ -0,0 +1,419 @@
+/* $Id: StatsStatement.java 94 2008-12-18 11:07:17Z dobashi $\r
+ * create: 2004/07/27\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.sql.stats;\r
+\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+import java.sql.Statement;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class StatsStatement implements java.sql.Statement {\r
+       /** 処理移譲先。 */\r
+       private Statement st=null;\r
+\r
+       /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */\r
+       private static String className=StatsStatement.class.getName();\r
+\r
+       /**\r
+        * 統計採取クラス。\r
+        */\r
+       private Statistics stat = Statistics.getInstance();\r
+\r
+       /**\r
+        * ログを採るSQL文。\r
+        */\r
+       //private String sql = null;\r
+\r
+       /**\r
+        * コンストラクタ。\r
+        * @param st\r
+        */\r
+       public StatsStatement(Statement st){\r
+               this.st = st;\r
+       }\r
+\r
+       /**\r
+        * 呼び出し元クラス名の変更。\r
+        * デフォルトではcon.execute()を呼び出したクラス名。\r
+        * それよりも前のスタックのクラス名を表示したい場合は\r
+        * ここに指定する。指定したクラス名がスタックトレース上にない場合\r
+        * うまく取得できなくなるので注意。\r
+        * \r
+        * @param className\r
+        */\r
+       public static void setClassName(String className){\r
+               StatsStatement.className = className;\r
+       }\r
+       /**\r
+        * @see java.sql.Statement#executeQuery(java.lang.String)\r
+        */\r
+       public ResultSet executeQuery(String sql) throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               ResultSet result = st.executeQuery(sql);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String)\r
+        */\r
+       public int executeUpdate(String sql) throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               int result = st.executeUpdate(sql);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int)\r
+        */\r
+       public int executeUpdate(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               int result = st.executeUpdate(sql,autoGeneratedKeys);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, int[])\r
+        */\r
+       public int executeUpdate(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+                       long before = System.currentTimeMillis();\r
+                       int result = st.executeUpdate(sql,columnIndexes);\r
+                       long timecost = System.currentTimeMillis() - before;\r
+                       stat.addData(sql,timecost, className);\r
+\r
+                       return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])\r
+        */\r
+       public int executeUpdate(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               int result = st.executeUpdate(sql,columnNames);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int)\r
+        */\r
+       public boolean execute(String sql, int autoGeneratedKeys)\r
+               throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               boolean result = st.execute(sql,autoGeneratedKeys);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String)\r
+        */\r
+       public boolean execute(String sql) throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               boolean result = st.execute(sql);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, int[])\r
+        */\r
+       public boolean execute(String sql, int[] columnIndexes)\r
+               throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               boolean result = st.execute(sql,columnIndexes);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])\r
+        */\r
+       public boolean execute(String sql, String[] columnNames)\r
+               throws SQLException {\r
+               long before = System.currentTimeMillis();\r
+               boolean result = st.execute(sql,columnNames);\r
+               long timecost = System.currentTimeMillis() - before;\r
+               stat.addData(sql,timecost, className);\r
+\r
+               return result;\r
+       }\r
+\r
+\r
+\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getFetchDirection()\r
+        */\r
+       public int getFetchDirection() throws SQLException {\r
+               return st.getFetchDirection();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getFetchSize()\r
+        */\r
+       public int getFetchSize() throws SQLException {\r
+               return st.getFetchSize();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMaxFieldSize()\r
+        */\r
+       public int getMaxFieldSize() throws SQLException {\r
+               return st.getMaxFieldSize();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMaxRows()\r
+        */\r
+       public int getMaxRows() throws SQLException {\r
+               return st.getMaxRows();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getQueryTimeout()\r
+        */\r
+       public int getQueryTimeout() throws SQLException {\r
+               return st.getQueryTimeout();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetConcurrency()\r
+        */\r
+       public int getResultSetConcurrency() throws SQLException {\r
+               return st.getResultSetConcurrency();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetHoldability()\r
+        */\r
+       public int getResultSetHoldability() throws SQLException {\r
+               return st.getResultSetHoldability();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSetType()\r
+        */\r
+       public int getResultSetType() throws SQLException {\r
+               return st.getResultSetType();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getUpdateCount()\r
+        */\r
+       public int getUpdateCount() throws SQLException {\r
+               return st.getUpdateCount();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#cancel()\r
+        */\r
+       public void cancel() throws SQLException {\r
+               st.cancel();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#clearBatch()\r
+        */\r
+       public void clearBatch() throws SQLException {\r
+               st.clearBatch();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#clearWarnings()\r
+        */\r
+       public void clearWarnings() throws SQLException {\r
+               st.clearWarnings();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#close()\r
+        */\r
+       public void close() throws SQLException {\r
+               st.close();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMoreResults()\r
+        */\r
+       public boolean getMoreResults() throws SQLException {\r
+               return st.getMoreResults();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#executeBatch()\r
+        */\r
+       public int[] executeBatch() throws SQLException {\r
+               return st.executeBatch();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setFetchDirection(int)\r
+        */\r
+       public void setFetchDirection(int direction) throws SQLException {\r
+               st.setFetchDirection(direction);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setFetchSize(int)\r
+        */\r
+       public void setFetchSize(int rows) throws SQLException {\r
+               st.setFetchSize(rows);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setMaxFieldSize(int)\r
+        */\r
+       public void setMaxFieldSize(int max) throws SQLException {\r
+               st.setMaxFieldSize(max);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setMaxRows(int)\r
+        */\r
+       public void setMaxRows(int max) throws SQLException {\r
+               st.setMaxRows(max);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setQueryTimeout(int)\r
+        */\r
+       public void setQueryTimeout(int seconds) throws SQLException {\r
+               st.setQueryTimeout(seconds);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getMoreResults(int)\r
+        */\r
+       public boolean getMoreResults(int current) throws SQLException {\r
+               return st.getMoreResults(current);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setEscapeProcessing(boolean)\r
+        */\r
+       public void setEscapeProcessing(boolean enable) throws SQLException {\r
+               st.setEscapeProcessing(enable);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#addBatch(java.lang.String)\r
+        */\r
+       public void addBatch(String sql) throws SQLException {\r
+               st.addBatch(sql);\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#setCursorName(java.lang.String)\r
+        */\r
+       public void setCursorName(String name) throws SQLException {\r
+               st.setCursorName(name);\r
+       }\r
+\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getConnection()\r
+        */\r
+       public Connection getConnection() throws SQLException {\r
+               return st.getConnection();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getGeneratedKeys()\r
+        */\r
+       public ResultSet getGeneratedKeys() throws SQLException {\r
+               return st.getGeneratedKeys();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getResultSet()\r
+        */\r
+       public ResultSet getResultSet() throws SQLException {\r
+               return st.getResultSet();\r
+       }\r
+\r
+       /* (非 Javadoc)\r
+        * @see java.sql.Statement#getWarnings()\r
+        */\r
+       public SQLWarning getWarnings() throws SQLException {\r
+               return st.getWarnings();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isClosed()\r
+        */\r
+       public boolean isClosed() throws SQLException {\r
+               return st.isClosed();\r
+       }\r
+\r
+       /**\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#isPoolable()\r
+        */\r
+       public boolean isPoolable() throws SQLException {\r
+               return st.isPoolable();\r
+       }\r
+\r
+       /**\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)\r
+        */\r
+       public boolean isWrapperFor(Class<?> iface) throws SQLException {\r
+               return st.isWrapperFor(iface);\r
+       }\r
+\r
+       /**\r
+        * @param poolable\r
+        * @throws SQLException\r
+        * @see java.sql.Statement#setPoolable(boolean)\r
+        */\r
+       public void setPoolable(boolean poolable) throws SQLException {\r
+               st.setPoolable(poolable);\r
+       }\r
+\r
+       /**\r
+        * @param <T>\r
+        * @param iface\r
+        * @return\r
+        * @throws SQLException\r
+        * @see java.sql.Wrapper#unwrap(java.lang.Class)\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public <T> T unwrap(Class<T> iface) throws SQLException {\r
+               return (T)this;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/util/BeanManager.java b/src/com/lavans/luz2/util/BeanManager.java
new file mode 100644 (file)
index 0000000..b4c81d1
--- /dev/null
@@ -0,0 +1,225 @@
+package com.lavans.luz2.util;\r
+\r
+import java.util.Map;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+\r
+/**\r
+ * Service Manager Implementation for XML file(default).\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class BeanManager {\r
+       /** logger */\r
+       private static final Log logger = LogFactory.getLog(BeanManager.class);\r
+\r
+       /**  */\r
+       private static Map<String, String> packageNameMap = new ConcurrentHashMap<String, String>();\r
+       /** cache of all service */\r
+       private static Map<String, BeanInfo> beanMap =  new ConcurrentHashMap<String, BeanInfo>();\r
+\r
+       private BeanManager(){\r
+       }\r
+\r
+       static{\r
+               load("luz2.xml");\r
+       }\r
+\r
+       /** initialize */\r
+       public static void load(String filename){\r
+               //packageNameMap.clear();\r
+               beanMap.clear();\r
+               Config config = Config.getInstance(filename);\r
+               try {\r
+                       // package map\r
+                       NodeList packageList = config.getNodeList("/root/beans");\r
+                       for(int i=0; i<packageList.getLength(); i++){\r
+                               Element node = (Element)packageList.item(i);\r
+                               String group = node.getAttribute("group");\r
+                               String packageName = node.getAttribute("package");\r
+                               packageNameMap.put(group, packageName);\r
+                       }\r
+\r
+                       // bean map\r
+                       NodeList nodeList = config.getNodeList("//bean");\r
+                       for(int i=0; i<nodeList.getLength(); i++){\r
+                               Element node = (Element)nodeList.item(i);\r
+                               Node parent = node.getParentNode();\r
+                               BeanInfo bean = new BeanInfo();\r
+                               bean.id = node.getAttribute("id");\r
+                               bean.className = node.getAttribute("class");\r
+                               // beanのgroup指定なら\r
+                               if(parent.getNodeName().equals("beans")){\r
+                                       bean.group = node.getAttribute("group");\r
+                                       bean.packageName = node.getAttribute("package");\r
+                                       // add package info to id & className\r
+                                       if(!StringUtils.isEmpty(bean.packageName)){\r
+                                               bean.id        = bean.packageName +"."+ bean.id;\r
+                                               bean.className = bean.packageName +"."+ bean.className;\r
+                                       }\r
+                               }\r
+                               beanMap.put(bean.id, bean);\r
+                       }\r
+               } catch (XPathExpressionException e) {\r
+                       logger.error("Unable to find /lremote/service_base_path");\r
+               }\r
+       }\r
+\r
+       /**\r
+        * get bean class. パッケージ指定有り\r
+        * @param name\r
+        * @param id\r
+        * @return\r
+        */\r
+       public static Class<? extends Object> getBeanClass(String group, String id){\r
+               return getBeanClass(toFullId(group, id));\r
+       }\r
+\r
+       /**\r
+        * beanのreflectionクラスを返す。\r
+        * @param id\r
+        * @return\r
+        */\r
+       public static Class<? extends Object> getBeanClass(String id) {\r
+               // Get FQDN bean info\r
+               BeanInfo bean = getBeanInfo(id);\r
+\r
+               return bean.getClazz();\r
+       }\r
+\r
+       /**\r
+        * get bean instance. パッケージ指定有り\r
+        * @param name\r
+        * @param id\r
+        * @return\r
+        */\r
+       public static Object getBean(String group, String id){\r
+               return getBean(toFullId(group, id));\r
+       }\r
+\r
+       /**\r
+        * beanのsingletonインスタンスを返す\r
+        * @param id\r
+        * @return\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public static <T> T getBean(Class<T> clazz) {\r
+               // Get FQDN bean info\r
+               BeanInfo bean = getBeanInfo(clazz.getName());\r
+\r
+               // now support only singleton\r
+               return (T)bean.getInstance();\r
+       }\r
+       /**\r
+        * beanのsingletonインスタンスを返す\r
+        * @param id\r
+        * @return\r
+        */\r
+       public static Object getBean(String id) {\r
+               // Get FQDN bean info\r
+               BeanInfo bean = getBeanInfo(id);\r
+\r
+               // now support only singleton\r
+               return bean.getInstance();\r
+       }\r
+\r
+       public static String toFullId(String group, String id){\r
+               String packageName = packageNameMap.get(group);\r
+               if(!StringUtils.isEmpty(packageName)){\r
+                       id = packageName+"."+id;\r
+               }\r
+               return id;\r
+       }\r
+\r
+       private static BeanInfo getBeanInfo(String id) {\r
+               // Get FQDN bean info\r
+               BeanInfo bean = beanMap.get(id);\r
+               if(bean==null){\r
+                       // if id is not defined in config file then id is className\r
+                       bean = new BeanInfo();\r
+                       bean.id=bean.className=id;\r
+                       beanMap.put(id, bean);\r
+               }\r
+               return bean;\r
+       }\r
+\r
+}\r
+\r
+class BeanInfo{\r
+       /** logger */\r
+       private static final Log logger = LogFactory.getLog(BeanInfo.class);\r
+       /** parent group info */\r
+       public String group;\r
+       public String packageName;\r
+       /** bean info */\r
+       public String id;\r
+       public String className;\r
+       public String initMethod;\r
+       private Class<? extends Object> clazz=null;\r
+       private Object instance=null;\r
+       /**\r
+        * Classクラスを返す。一度読み込んだらキャッシュして再利用。\r
+        * @return\r
+        */\r
+       public Class<? extends Object> getClazz(){\r
+               if(clazz!=null){\r
+                       return clazz;\r
+               }\r
+\r
+               // load from ClassLoader\r
+               try {\r
+                       clazz = Class.forName(className);\r
+               } catch (ClassNotFoundException e) {\r
+                       logger.error("bean class is not found["+ className +"]", e);\r
+               }\r
+\r
+               return clazz;\r
+       }\r
+       /**\r
+        * instanceを返す。一度読み込んだらキャッシュして再利用。\r
+        * @return\r
+        */\r
+       public Object getInstance(){\r
+               if(instance!=null){\r
+                       return instance;\r
+               }\r
+\r
+               // load from ClassLoader\r
+               try {\r
+                       instance = getClazz().newInstance();\r
+               } catch (Exception e) {\r
+                       logger.error("Bean instance cannot created ["+ className +"]", e);\r
+               }\r
+\r
+               if(!StringUtils.isEmpty(initMethod)){\r
+                       try {\r
+                               clazz.getMethod(initMethod, (Class<?>[])null).invoke(instance, (Object[])null);\r
+                       } catch (Exception e) {\r
+                               logger.error("init method call error ["+ className +"#"+ initMethod +"()]", e);\r
+                       }\r
+               }\r
+\r
+               return instance;\r
+       }\r
+\r
+       /**\r
+        * override toString().\r
+        */\r
+       @Override\r
+       public String toString() {\r
+               return "BeanInfo [group=" + group + ", packageName=" + packageName\r
+                               + ", id=" + id + ", className=" + className + ", initMethod="\r
+                               + initMethod + ", clazz=" + clazz + ", instance=" + instance\r
+                               + "]";\r
+       }\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/util/CondTypeEnum.java b/src/com/lavans/luz2/util/CondTypeEnum.java
new file mode 100644 (file)
index 0000000..b26fb3a
--- /dev/null
@@ -0,0 +1,18 @@
+package com.lavans.luz2.util;\r
+\r
+/**\r
+ * Search condition type.\r
+ *\r
+ * LIST: comma separated values\r
+ *\r
+ * @author dobashi\r
+ *\r
+ */\r
+public enum CondTypeEnum {\r
+       EQUAL, GREATER_EQUAL, LESS_OR_EQUAL, FUZZY_SEARCH, PREFIX_SEARCH, SUFFIX_SEARCH, MULTIPLE,LIST,;\r
+//     EQUAL("="),GREATER_EQUAL(">="),LESS_OR_EQUAL("<="),FUZZY_SEARCH(" LIKE "),LIST,MULTIPLE;\r
+//     String equotation;\r
+//     private CondTypeEnum(String equotation){\r
+//             this.equotation = equotation;\r
+//     }\r
+}\r
diff --git a/src/com/lavans/luz2/util/Config.java b/src/com/lavans/luz2/util/Config.java
new file mode 100644 (file)
index 0000000..4fb4892
--- /dev/null
@@ -0,0 +1,333 @@
+package com.lavans.luz2.util;\r
+\r
+\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.UnsupportedEncodingException;\r
+import java.net.URL;\r
+import java.net.URLDecoder;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.logging.Level;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.parsers.ParserConfigurationException;\r
+import javax.xml.xpath.XPath;\r
+import javax.xml.xpath.XPathConstants;\r
+import javax.xml.xpath.XPathExpressionException;\r
+import javax.xml.xpath.XPathFactory;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+import org.w3c.dom.ls.DOMImplementationLS;\r
+import org.w3c.dom.ls.LSInput;\r
+import org.w3c.dom.ls.LSOutput;\r
+import org.w3c.dom.ls.LSParser;\r
+import org.w3c.dom.ls.LSSerializer;\r
+import org.xml.sax.SAXException;\r
+\r
+import com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl;\r
+\r
+/**\r
+ * 設定ファイル読込クラス。\r
+ * getInstance(String)で設定ファイル名を指定して読み込む。\r
+ *\r
+ * @author     dobashi\r
+ * @version    1.0\r
+ */\r
+public class Config {\r
+       /**\r
+        * logger.\r
+        * Loggerをluz内ではなく外部Loggerを使うようにしたので、Configクラスでも使用可能となった。\r
+        */\r
+       private static Log logger = LogFactory.getLog(Config.class);\r
+\r
+       private static String CONFIG_FILE ="luz2.xml";\r
+\r
+       /** インスタンス一覧 */\r
+       private static Map<String, Config> instanceMap = new HashMap<String, Config>();\r
+\r
+       /** ノード一覧 */\r
+//     private Map<String, List<Node>>  nodeMap= null;\r
+//     /** propertyセクションの値一覧 */\r
+//     private Map<String, String> propertyMap = null;\r
+\r
+       /** 設定ファイル名 */\r
+       private String configFileName = null;\r
+\r
+       /** 設定ファイルのrootノード */\r
+       private Element root = null;\r
+       /** xpath パーサー */\r
+       private XPath xpath = null;\r
+\r
+       /** 書き込み許可モード時の書き込みクラス */\r
+       private LSOutput lsOutput = null;\r
+\r
+       /** 書き込み許可モード時のシリアライズクラス */\r
+       private LSSerializer lsSerializer = null;\r
+\r
+       /** 書き込み可能かどうか */\r
+       private boolean isReadOnly = false;\r
+\r
+       /** デバッグモード */\r
+       private boolean isDebug = false;\r
+\r
+       /** luz.xmlで指定できるようにする */\r
+       public static Level getLuzLogLevel(){\r
+               return Level.FINEST;\r
+       }\r
+       /**\r
+        * インスタンス取得。設定ファイル名指定無しならluz.xmlから読み込む。\r
+        * @return\r
+        */\r
+       public static Config getInstance(){\r
+               return getInstance(CONFIG_FILE);\r
+       }\r
+\r
+       /**\r
+        * インスタンス取得。設定ファイル名指定あり。\r
+        * @param configFile\r
+        * @param reload 再読込するかどうか\r
+        * @return\r
+        */\r
+       public static Config getInstance(String configFile){\r
+               return getInstance(configFile, false);\r
+       }\r
+       public static Config getInstance(String configFile, boolean reload){\r
+               Config config = instanceMap.get(configFile);\r
+               if(reload || config == null){\r
+                       logger.info("load "+ configFile);\r
+                       config = new Config(configFile);\r
+                       instanceMap.put(configFile, config);\r
+               }\r
+               return config;\r
+       }\r
+\r
+       protected Config(String fileName){\r
+               init(fileName);\r
+       }\r
+       /**\r
+        * 初期化。\r
+        * 動的に設定を再読込できるようにpublicにする。\r
+        */\r
+       public void init(String fileName){\r
+               try {\r
+                       Document doc;\r
+                       // パースして DOM ツリーを作成する\r
+                       try{\r
+                               doc = getDocumenFromUrl(fileName);\r
+                       }catch(FileNotFoundException e){\r
+                               // 見つからない場合はリソースから取得(jarファイル内など)\r
+                               doc = getDocumenFromResource(fileName);\r
+                               // 読み込み専用\r
+                               isReadOnly=true;\r
+                       }\r
+\r
+                       root = doc.getDocumentElement();                                                                        // ルートノードの取得\r
+\r
+                       xpath = XPathFactory.newInstance().newXPath();\r
+//                     root = (Element)xpath.evaluate("/luz", new InputSource(fis), XPathConstants.NODE);\r
+\r
+                       // debugの取得\r
+                       isDebug = Boolean.parseBoolean(getNodeValue("/luz/debug"));\r
+               } catch (Exception e) {\r
+                       logger.error("Can't find xml file.["+ fileName +"]", e);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * URLクラスを使用してxmlファイルを読み込む\r
+        * @param fileName\r
+        * @return\r
+        * @throws FileNotFoundException ファイルが見つからない場合\r
+        */\r
+       private Document getDocumenFromUrl(String fileName) throws FileNotFoundException {\r
+               // 設定ファイル -----------------------\r
+               // クラスローダーより設定ファイルを取得\r
+               URL url = Thread.currentThread().getContextClassLoader().getResource(fileName);\r
+               // nullの場合は絶対パスで指定されているケースを想定\r
+               if(url==null){\r
+                       configFileName = fileName;\r
+               }else{\r
+                       try{\r
+                               configFileName = URLDecoder.decode(url.getFile(),"UTF-8");\r
+                       }catch(UnsupportedEncodingException e){}\r
+               }\r
+               // InputStreamの作成\r
+               FileInputStream fis = new FileInputStream(configFileName);\r
+\r
+               // Input ------------------------------\r
+               DOMImplementationLS domImplLS = new DOMImplementationImpl();\r
+               // データの入力ソースオブジェクトの作成\r
+               LSInput lsInput = domImplLS.createLSInput();\r
+               // LSInput に入力ストリームをセット\r
+               lsInput.setByteStream(fis);\r
+\r
+               // Output -----------------------------\r
+           lsOutput=domImplLS.createLSOutput();\r
+           lsOutput.setEncoding(lsInput.getEncoding());\r
+           lsSerializer=domImplLS.createLSSerializer();\r
+\r
+               // パーサーの作成\r
+               // MODE_SYNCHRONOUS の場合、作成された LSParser は同期モードで動作\r
+               // 第2引数(schemaType) Document をロードしているときに使用されるスキーマ言語の種類を表す絶対 URI\r
+               LSParser lsParser = domImplLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);\r
+\r
+               // パースして DOM ツリーを作成する\r
+               Document doc = lsParser.parse(lsInput);\r
+\r
+               return doc;\r
+       }\r
+\r
+       /**\r
+        * リソースからの取得処理。\r
+        * jar/zipファイルからの読み込み用。\r
+        * 書き込み不可となる。\r
+        *\r
+        * @param fileName\r
+        * @return\r
+        * @throws SAXException\r
+        * @throws IOException\r
+        * @throws ParserConfigurationException\r
+        */\r
+       private Document getDocumenFromResource(String fileName) throws SAXException, IOException, ParserConfigurationException{\r
+               DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();        // ドキュメントビルダーファクトリを生成\r
+               DocumentBuilder builder = dbfactory.newDocumentBuilder();                                       // ドキュメントビルダーを生成\r
+               Document doc = builder.parse(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName));\r
+               return doc;\r
+       }\r
+\r
+       public Element getRoot(){\r
+               return root;\r
+       }\r
+\r
+       /**\r
+        * ノードの取得。ノード単体用。\r
+        * 該当するノード名が無い場合はnullを返す。\r
+        *\r
+        * @param nodeName\r
+        * @return\r
+        * @throws XPathExpressionException\r
+        */\r
+       public Node getNode(String xql){\r
+               Node element = null;\r
+               try {\r
+                       synchronized (xpath) {\r
+                               element = (Node)xpath.evaluate(xql, root, XPathConstants.NODE);\r
+                       }\r
+               } catch (XPathExpressionException e) {\r
+                       e.printStackTrace();\r
+               }\r
+               return element;\r
+       }\r
+\r
+       /**\r
+        * ノードの取得。ノード複数用。親ノード指定あり。\r
+        * 該当するノード名が無い場合はException。\r
+        *\r
+        * @param nodeName\r
+        * @return\r
+        * @throws XPathExpressionException\r
+        */\r
+       public NodeList getNodeList(String xql, Object item) throws XPathExpressionException{\r
+               NodeList element;\r
+               synchronized (xpath) {\r
+                       element = (NodeList)xpath.evaluate(xql, item, XPathConstants.NODESET);\r
+               }\r
+               return element;\r
+       }\r
+\r
+       /**\r
+        * ノードの取得。ノード複数用。rootから。\r
+        * 該当するノード名が無い場合はException。\r
+        *\r
+        * @param nodeName\r
+        * @return\r
+        * @throws XPathExpressionException\r
+        */\r
+       public NodeList getNodeList(String xql) throws XPathExpressionException{\r
+               return getNodeList(xql, root);\r
+       }\r
+\r
+       /**\r
+        * テキストノードのコンテンツを取得します。\r
+        * <luz>\r
+        *   <property>\r
+        *     <name1>value1</name1>\r
+        *   </property>\r
+        * という設定ファイルに対して、getNodeValue("/luz/property/name1")で"value1"が返る。\r
+        *\r
+        * @param xql\r
+        * @return\r
+        * @throws XPathExpressionException\r
+        */\r
+       public String getNodeValue(String xql) throws XPathExpressionException{\r
+               String result;\r
+               synchronized (xpath) {\r
+                       result = xpath.evaluate(xql, root);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       public void setNodeValue(String xql, String value){\r
+               Document doc = root.getOwnerDocument();\r
+               Node ele = getNode(xql);\r
+               ele.removeChild(ele.getFirstChild());\r
+               ele.appendChild(doc.createTextNode(value));\r
+       }\r
+\r
+       /**\r
+        * テキストノードのコンテンツを取得します。\r
+        * <luz>\r
+        *   <property>\r
+        *     <name1>value1</name1>\r
+        *     <name1>value2</name1>\r
+        *   </property>\r
+        * という設定ファイルに対して、getNodeValueList("/luz/property/name1")で[value1,value2]が返る。\r
+        *\r
+        * @param xql\r
+        * @return\r
+        * @throws XPathExpressionException\r
+        */\r
+       public List<String> getNodeValueList(String xql) throws XPathExpressionException{\r
+               NodeList nodeList = getNodeList(xql);\r
+               List<String> valueList = new ArrayList<String>(nodeList.getLength());\r
+               for(int i=0; i< nodeList.getLength(); i++){\r
+                       Node node = nodeList.item(i);\r
+                       valueList.add(node.getFirstChild().getNodeValue());\r
+               }\r
+               return valueList;\r
+       }\r
+\r
+       public void save() throws IOException{\r
+\r
+               if(isReadOnly){\r
+                       throw new IOException("Xml file is readonly. It is in jar file.");\r
+               }\r
+\r
+               FileOutputStream fos = new FileOutputStream(configFileName);\r
+               //LSOutput に出力ストリームをセットする\r
+           lsOutput.setByteStream(fos);\r
+           //DOM ツリーをシリアライズする。\r
+           lsSerializer.write(root,lsOutput);\r
+           //ファイルストリームのクローズ\r
+           fos.close();\r
+       }\r
+\r
+       /**\r
+        * luz.xml(Configのデフォルトインスタンス)にあるデバッグモードを返す。\r
+        * @return\r
+        */\r
+       public static boolean isDebug(){\r
+               return getInstance().isDebug;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/util/EnumAlias.java b/src/com/lavans/luz2/util/EnumAlias.java
new file mode 100644 (file)
index 0000000..c4a0b6e
--- /dev/null
@@ -0,0 +1,135 @@
+/* $Id: EnumAlias.java 414 2011-07-28 23:05:16Z dobashi $ */\r
+package com.lavans.luz2.util;\r
+\r
+import java.lang.reflect.Field;\r
+import java.lang.reflect.Method;\r
+import java.util.List;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+\r
+\r
+/**\r
+ * Enum別名クラス。\r
+ * luz.xmlに定義した別名(エイリアス)から、enumクラスを取得する。\r
+ * IEnumインターフェースだけではstaticメソッドが呼び出せないのが、\r
+ * このクラスを利用すれば実際の型がわからなくてもstaticメソッドにアクセスできる。\r
+ *\r
+ * デプロイするシステムに応じて利用するEnumが変わる場合等、\r
+ * Enumの型をハードコーディングしたくない時に使用する。\r
+ *\r
+ * @author Yuki\r
+ *\r
+ */\r
+public class EnumAlias{\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(EnumAlias.class);\r
+\r
+       /** 処理移譲先 */\r
+       private final Class<? extends IEnum> clazz;\r
+\r
+       private boolean isList;\r
+\r
+       /**\r
+        * 任意プロフィールのEnumクラスを返す。\r
+        * 設定が内場合はnull;\r
+        *\r
+        * @param type\r
+        * @return\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public static EnumAlias getEnum(String aliasName){\r
+               EnumAlias alias = null;\r
+\r
+               Config config = Config.getInstance();\r
+               String className="";\r
+               boolean isList=false;;\r
+               try {\r
+                       className = config.getNodeValue("/luz/enum_alias/"+aliasName);\r
+                       Element ele = (Element)config.getNode("/luz/enum_alias/"+aliasName);\r
+                       isList = Boolean.parseBoolean(ele.getAttribute("list"));\r
+               } catch (XPathExpressionException e1) {\r
+               }\r
+               if(className.equals("")){\r
+                       return alias;\r
+               }\r
+\r
+               try {\r
+                       Class<? extends IEnum> clazz = (Class<? extends IEnum>)Class.forName(className);\r
+                       alias = new EnumAlias(clazz);\r
+                       alias.isList=isList;\r
+               } catch (ClassNotFoundException e) {\r
+               }\r
+\r
+               return alias;\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ\r
+        * @param clazz\r
+        */\r
+       public EnumAlias(Class<? extends IEnum> clazz){\r
+               this.clazz=clazz;\r
+       }\r
+\r
+       /**\r
+        * Enum名取得\r
+        * @return\r
+        */\r
+       public String getEnumTitle(){\r
+               String result = "";\r
+               try {\r
+                       Field field = clazz.getField("_TITLE");\r
+                       result = field.get(null).toString();\r
+               } catch (Exception e) {\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * タイトル取得\r
+        * IDがカンマ区切りの場合は一覧で返す。\r
+        * @return\r
+        */\r
+       public String getTitle(String idStr){\r
+               StringBuffer result = new StringBuffer();\r
+               String[] ids = idStr.split(",");\r
+               for (String id : ids) {\r
+                       try {\r
+                               Method method = clazz.getMethod("getTitle", new Class<?>[]{String.class});\r
+                               result.append(" "+method.invoke(null, new Object[]{id}));\r
+                       } catch (Exception e) {\r
+                               logger.debug("",e);\r
+                       }\r
+               }\r
+               return result.substring(1);\r
+       }\r
+\r
+       /**\r
+        * 全インスタンス一覧\r
+        * @return\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public List<? extends IEnum> getAllList(){\r
+               List<? extends IEnum> list = null;\r
+               try {\r
+                       Method method = clazz.getMethod("getAllList", (Class<?>[])null);\r
+                       list = (List<? extends IEnum>)method.invoke(null, (Object[])null);\r
+               } catch (Exception e) {\r
+                       logger.debug("",e);\r
+               }\r
+               return list;\r
+       }\r
+\r
+       public boolean isList() {\r
+               return isList;\r
+       }\r
+\r
+       public void setList(boolean isList) {\r
+               this.isList = isList;\r
+       }\r
+}\r
+\r
diff --git a/src/com/lavans/luz2/util/IEntity.java b/src/com/lavans/luz2/util/IEntity.java
new file mode 100644 (file)
index 0000000..527e1a8
--- /dev/null
@@ -0,0 +1,8 @@
+package com.lavans.luz2.util;\r
+\r
+import java.util.Map;\r
+\r
+public interface IEntity {\r
+       /** Get SQL parameter Map<String, Object> */\r
+       public Map<String, Object> getAttributeMap();\r
+}\r
diff --git a/src/com/lavans/luz2/util/IEnum.java b/src/com/lavans/luz2/util/IEnum.java
new file mode 100644 (file)
index 0000000..1c2e4d1
--- /dev/null
@@ -0,0 +1,15 @@
+/* $Id: IEnum.java 414 2011-07-28 23:05:16Z dobashi $\r
+ * created: 2005/09/30\r
+ */\r
+package com.lavans.luz2.util;\r
+\r
+\r
+\r
+/**\r
+ * enumインターフェース\r
+ * @author annaka\r
+ */\r
+public interface IEnum {\r
+    String getId();\r
+    String getTitle();\r
+}
\ No newline at end of file
diff --git a/src/com/lavans/luz2/util/IParameterizable.java b/src/com/lavans/luz2/util/IParameterizable.java
new file mode 100644 (file)
index 0000000..d02dace
--- /dev/null
@@ -0,0 +1,19 @@
+/* $Id: IParameterizable.java 439 2011-08-06 14:15:23Z dobashi $\r
+ * create: 2004/10/18\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.util;\r
+\r
+import java.io.Serializable;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public interface IParameterizable extends Serializable{\r
+       /** Get HTTP parameter Map<String, String[]> */\r
+       public Map<String, String[]> getParameters(String prefix);\r
+       /** Set HTTP parameter Map<String, String[]> */\r
+       public void setParameters(Map<String, String[]> map, String prefix);\r
+}\r
diff --git a/src/com/lavans/luz2/util/MethodUtil.java b/src/com/lavans/luz2/util/MethodUtil.java
new file mode 100644 (file)
index 0000000..afcf5af
--- /dev/null
@@ -0,0 +1,91 @@
+/* $Id: MethodUtil.java 414 2011-07-28 23:05:16Z dobashi $\r
+ * create: 2004/08/24\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.util;\r
+\r
+\r
+/**\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class MethodUtil{\r
+       /**\r
+        * メソッド名の取得。\r
+        * LogRecord#inferCaller()のパクリ。\r
+        * @see java.util.loggin.LogRecord#inferCaller\r
+        */\r
+       public static String getMethodName(String classname) {\r
+               return getMethodName(classname, "com.lavans.luz2.");\r
+       }\r
+       \r
+       /**\r
+        * メソッド名の取得。ツールデバッグ用\r
+        * LogRecord#inferCaller()のパクリ。\r
+        * @see java.util.loggin.LogRecord#inferCaller\r
+        */\r
+       public static String getMethodNameTool(String classname) {\r
+               return getMethodName(classname, null);\r
+       }\r
+\r
+       /**\r
+        * メソッド名の取得。\r
+        * LogRecord#inferCaller()のパクリ。\r
+        * \r
+        * @see java.util.loggin.LogRecord#inferCaller\r
+        *\r
+        */\r
+       private static String getMethodName(String classname, String ignoreStr) {\r
+               try{\r
+                       //logger.entering("Method","getMethodName");\r
+                       //logger.debug("classname="+ classname);\r
+                       \r
+                       // Get the stack trace.\r
+                       StackTraceElement stack[] = (new Throwable()).getStackTrace();\r
+                       // First, search back to a method in the Logger class.\r
+                       int ix = 0;\r
+                       while (ix < stack.length) {\r
+                               StackTraceElement frame = stack[ix];\r
+                               String cname = frame.getClassName();\r
+       //                      logger.log(cname);\r
+                               if (classname.equals(cname)) {\r
+                                       break;\r
+                               }\r
+                               ix++;\r
+                       }\r
+                       // Now search for the first frame before the "Logger" class.\r
+                       while (ix < stack.length) {\r
+                               StackTraceElement frame = stack[ix];\r
+                               String cname = frame.getClassName();\r
+       //                      logger.debugTool(cname+"#"+frame.getMethodName() +"()");\r
+                               if (!classname.equals(cname) && ((ignoreStr==null) || !cname.startsWith(ignoreStr))) {\r
+                                       //logger.exiting("Logger","getMethodName");\r
+       //                              return frame.toString();\r
+       //                              return cname+"#"+frame.getMethodName() +"()";\r
+                                       return cname+"#"+frame.getMethodName() +"():"+ frame.getLineNumber();\r
+       //                              return cname+"#"+frame.getMethodName() +"("+frame.getFileName() +":"+ frame.getLineNumber() +")";\r
+                               }\r
+                               ix++;\r
+                       }\r
+                       \r
+                       //logger.exiting("Method","getMethodName");\r
+               }catch(Exception e){\r
+                       e.printStackTrace();\r
+               }\r
+               return "";\r
+       }\r
+       \r
+       /**\r
+        * プリミティブ型のラッパークラスから、プリミティブ型を表すClassインスタンスを返す。\r
+        * @param obj\r
+        * @return\r
+        */\r
+//     public static Class getPrimitiveClass(Object obj){\r
+//             Class result = null;\r
+//             if(obj instanceof Integer){\r
+//                     result = Integer.TYPE;\r
+//             }\r
+//             \r
+//             return result;\r
+//     }\r
+}\r
diff --git a/src/com/lavans/luz2/util/PageInfo.java b/src/com/lavans/luz2/util/PageInfo.java
new file mode 100644 (file)
index 0000000..b3a4d8b
--- /dev/null
@@ -0,0 +1,125 @@
+/* $Id: PageInfo.java 472 2011-08-20 13:34:00Z dobashi $\r
+ * created: 2005/08/08\r
+ */\r
+package com.lavans.luz2.util;\r
+\r
+import java.io.Serializable;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+\r
+/**\r
+ * Pager情報。\r
+ * 現在のページ番号、1ページあたりの行数など、\r
+ * Daoクラスから一覧読み込みを行うときに必要な情報を保持する。\r
+ * @author dobashi\r
+ */\r
+public class PageInfo implements IParameterizable, Serializable{\r
+       /**\r
+        *\r
+        */\r
+       private static final long serialVersionUID = 5562045120082975793L;\r
+\r
+       /** 無制限 */\r
+       public static final int ROWS_UNLIMITED = -1;\r
+\r
+       public static final String PAGE="page";\r
+       public static final String ROWS="rows";\r
+       public static final String PREV="prev";\r
+       public static final String NEXT="next";\r
+\r
+       /** 現在のページ。0オリジン。 */\r
+       private int page=0;\r
+\r
+       /** 1ページに表示する行数:default10。 */\r
+       private int rows = 10;\r
+\r
+       /**\r
+        * コンストラクタ。表示行数指定無し。\r
+        */\r
+       public PageInfo() {\r
+               Config config = Config.getInstance();\r
+               try{\r
+                       String rowsStr = config.getNodeValue("/luz/pager/rows");\r
+                       rows = Integer.parseInt(rowsStr);\r
+               }catch (Exception e) {\r
+                       // デフォルトの10行を使う\r
+               }\r
+       }\r
+\r
+       /**\r
+        * コンストラクタ。表示行数指定。\r
+        */\r
+       public PageInfo(int rows) {\r
+               super();\r
+               this.rows = rows;\r
+       }\r
+\r
+       /** ページ数取得 */\r
+       public int getPage(){\r
+               return page;\r
+       }\r
+       /** ページ数設定 */\r
+       public void setPage(int x){\r
+               page = x;\r
+       }\r
+       /**\r
+        * @param rows 表示行数を設定。\r
+        */\r
+       public void setRows(int rows) {\r
+               this.rows = rows;\r
+       }\r
+\r
+       /**\r
+        * 表示行数取得。\r
+        * @author dobashi\r
+        * @return int 表示行数\r
+        */\r
+       public int getRows() {\r
+               // 無制限ならintの上限を返す\r
+               if(rows == ROWS_UNLIMITED){\r
+                       return Integer.MAX_VALUE;\r
+               }\r
+               return rows;\r
+       }\r
+\r
+       /**\r
+        * Htmlへ書き出す必要があるパラメータの取得。\r
+        * @see com.tradersfs.carrera.common.HtmlParameterizable#getParameters()\r
+        */\r
+       public Map<String, String[]> getParameters() {\r
+               return getParameters("");\r
+       }\r
+       public Map<String, String[]> getParameters(String prefix) {\r
+               Map<String, String[]> result = new HashMap<String, String[]>();\r
+               result.put(prefix+PAGE, new String[]{String.valueOf(page)});\r
+               result.put(prefix+ROWS, new String[]{String.valueOf(rows)});\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * パラメータから自クラスの状態をセットする。\r
+        * @see com.tradersfs.carrera.common.HtmlParameterizable#setParameters(java.util.Map)\r
+        */\r
+       public void setParameters(Map<String, String[]> map) {\r
+               setParameters(map, "");\r
+       }\r
+       public void setParameters(Map<String, String[]> map, String prefix) {\r
+               // ページ設定\r
+               try{\r
+                       page = Integer.parseInt((map.get(prefix+PAGE))[0]);\r
+               }catch (Exception e) {\r
+                       page = 0;\r
+               }\r
+               // 行数\r
+               try{\r
+                       if(map.get(prefix+ROWS)!=null) rows = Integer.parseInt((map.get(prefix+ROWS))[0]);\r
+               }catch (Exception e) {\r
+                       // 変更しない\r
+               }\r
+\r
+               // フォームボタンの場合のPREV/NEXT\r
+               if(map.get(prefix+PREV)!=null) page -= 1;\r
+               if(map.get(prefix+NEXT)!=null) page += 1;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/util/Pager.java b/src/com/lavans/luz2/util/Pager.java
new file mode 100644 (file)
index 0000000..40f0cad
--- /dev/null
@@ -0,0 +1,291 @@
+/* $Id: Pager.java 472 2011-08-20 13:34:00Z dobashi $\r
+ * create: 2004/10/18\r
+ * (c)2004 Lavans Networks Inc. All Rights Reserved.\r
+ */\r
+package com.lavans.luz2.util;\r
+\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import com.lavans.luz2.commons.ArrayUtils;\r
+\r
+//import com.lavans.util.Logger;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ * @version 1.00\r
+ */\r
+public class Pager<E> implements Serializable{\r
+       /**\r
+        *\r
+        */\r
+       private static final long serialVersionUID = 4429141113724792971L;\r
+\r
+       /** Logger */\r
+//     private static Logger logger = Logger.getInstance();\r
+\r
+       /** ページ情報 */\r
+       private PageInfo pageInfo = null;\r
+\r
+       /** 全件数。 */\r
+       private long totalCount;\r
+       /** 全ページ数。 */\r
+       private int totalPage;\r
+\r
+       /** 次ページ制御用リンク先URL */\r
+       private String linkUrl="";\r
+       /** 次ページ制御用リンクパラメータ */\r
+       private String linkParam="";\r
+\r
+       /** 保持しているデータのリスト */\r
+       private List<E> dataList;\r
+\r
+       /** 属性格納用Map */\r
+       private Map<String, Object> attributeMap = new HashMap<String, Object>();\r
+\r
+       // 複数選択\r
+       /** 前画面での全ID */\r
+       public static final String ID_LIST = "id_list";\r
+       /** 保存済みID */\r
+       public static final String CHECKED_ID_LIST = "checked_id_list";\r
+       /** 今回選択されたID */\r
+       public static final String CHECKED_ID = "checked_id";\r
+       /** 複数選択時の選択済みID一覧 */\r
+       private Set<String> checkedIdList;\r
+\r
+       /**\r
+        * コンストラクタ。表示行数指定。\r
+        */\r
+       public Pager(PageInfo pageInfo) {\r
+               this.pageInfo = pageInfo;\r
+               dataList = new ArrayList<E>(pageInfo.getRows());\r
+               checkedIdList = new HashSet<String>();\r
+       }\r
+\r
+       //----------------------------------------------------------\r
+       // ページ制御情報設定\r
+       //----------------------------------------------------------\r
+       /**\r
+        * 件数設定。\r
+        * この件数を元にページ数や次ページ存在チェック等を行う。\r
+        * DAOクラスで読込の際に使用する。\r
+        *\r
+        */\r
+       public void setTotalCount(long x){\r
+               totalCount = x;\r
+               // 全ページ数\r
+               totalPage = (int)(totalCount / pageInfo.getRows() -1);\r
+               if(totalCount % pageInfo.getRows() != 0){\r
+                       totalPage++;\r
+               }\r
+       }\r
+\r
+       /** 前のページがあるか。 */\r
+       public boolean hasPrev(){\r
+               return pageInfo.getPage()>0;\r
+       }\r
+       /** 次のページがあるか。 */\r
+       public boolean hasNext(){\r
+               return pageInfo.getPage() < totalPage;\r
+       }\r
+//     protected void setHasNext(boolean x){\r
+//             hasNext = x;\r
+//     }\r
+       /** 全ページ数。 */\r
+       public int getTotalPage(){\r
+               return totalPage;\r
+       }\r
+\r
+       /**\r
+        * 全件データから現在のページを表すpagerにする。\r
+        * @param totalData\r
+        */\r
+       public void setTotalData(List<E> totalData){\r
+               // 全件数\r
+               setTotalCount(totalData.size());\r
+\r
+               int start = pageInfo.getPage() * pageInfo.getRows();\r
+               for(int i=start; i<start+pageInfo.getRows(); i++){\r
+                       if(i>=totalData.size()){\r
+                               break;\r
+                       }\r
+                       add(totalData.get(i));\r
+               }\r
+\r
+       }\r
+\r
+\r
+       //----------------------------------------------------------\r
+       // 複数選択処理\r
+       //----------------------------------------------------------\r
+       /**\r
+        * 複数選択時の選択項目判別処理\r
+        * 下記のようにパラメータを渡すと、選択/非選択の判定を行う。\r
+        * pager.setCheckedParams(request.getParamegerMap());\r
+        */\r
+       public void setCheckedParams(Map<String, String[]> params){\r
+               // 今回選択されたID\r
+               String checkedId[] = null;\r
+               if(params.containsKey(CHECKED_ID)){\r
+                       checkedId = params.get(CHECKED_ID);\r
+                       // 今回選択されたIDを保存\r
+                       checkedIdList.addAll(Arrays.asList(checkedId));\r
+               }\r
+               // 保存済みID\r
+               if(params.containsKey(CHECKED_ID_LIST) && !params.get(CHECKED_ID_LIST)[0].equals("")){\r
+                       checkedIdList.addAll(Arrays.asList(params.get(CHECKED_ID_LIST)[0].split(",")));\r
+               }\r
+\r
+               // 前画面の分がなければここで終了\r
+               if(!params.containsKey(ID_LIST)) return;\r
+               // 前画面で表示していたすべてのid\r
+               String idList[] = params.get(ID_LIST)[0].split(",");\r
+               // 保存済みIDから、前回表示で選択されなかったIDを引く\r
+               for(int i=0; i<idList.length; i++){\r
+                       if(!ArrayUtils.contains(checkedId, idList[i])){\r
+                               checkedIdList.remove(idList[i]);\r
+                       }\r
+               }\r
+       }\r
+\r
+\r
+       /**\r
+        * タイトル : ポジションデータ取得処理\r
+        * 説明 :\r
+        * @return List\r
+        * @param なし\r
+        * @throws なし\r
+        */\r
+       public E get(int i) {\r
+               return dataList.get(i);\r
+       }\r
+\r
+       /**\r
+        * タイトル : ポジションデータ取得処理\r
+        * 説明 :\r
+        * @return List\r
+        * @param なし\r
+        * @throws なし\r
+        */\r
+       public void add(E obj) {\r
+               dataList.add(obj);\r
+       }\r
+\r
+       /**\r
+        * タイトル : ポジションリスト取得処理\r
+        * 説明 :\r
+        * @return List\r
+        * @param なし\r
+        * @throws なし\r
+        */\r
+       public List<E> getList() {\r
+               return dataList;\r
+       }\r
+\r
+       /**\r
+        * タイトル : ポジションリストサイズ取得処理\r
+        * 説明 :\r
+        * @return int\r
+        * @param なし\r
+        * @throws なし\r
+        */\r
+       public int size() {\r
+               return dataList.size();\r
+       }\r
+\r
+       /**\r
+        * 表示開始番号。\r
+        * @return\r
+        */\r
+       public int getStartNumber(){\r
+               return pageInfo.getPage()*pageInfo.getRows()+1;\r
+       }\r
+\r
+       /**\r
+        * 表示終了番号。\r
+        * @return\r
+        */\r
+       public int getEndNumber(){\r
+               return getStartNumber()+dataList.size()-1;\r
+       }\r
+\r
+       /**\r
+        * @return totalCount を戻します。\r
+        */\r
+       public long getTotalCount() {\r
+               return totalCount;\r
+       }\r
+       /**\r
+        * @return linkParam を戻します。\r
+        */\r
+       public String getLinkParam() {\r
+               // pageInfoのrowsも自動的に付加する。\r
+               if(pageInfo!=null){\r
+                       return linkParam + PageInfo.ROWS +"="+pageInfo.getRows()+"&";\r
+               }\r
+               return linkParam;\r
+       }\r
+       /**\r
+        * @param linkParam linkParam を設定。\r
+        */\r
+       public void setLinkParam(String linkParam) {\r
+               this.linkParam = linkParam;\r
+//             this.linkParam = StringUtil.encodeParameterValues(linkParam);\r
+       }\r
+       /**\r
+        * @return linkUrl を戻します。\r
+        */\r
+       public String getLinkUrl() {\r
+               return linkUrl;\r
+       }\r
+       /**\r
+        * @param linkUrl linkUrl を設定。\r
+        */\r
+       public void setLinkUrl(String linkUrl) {\r
+               this.linkUrl = linkUrl;\r
+       }\r
+       /**\r
+        * @return pageInfo を戻します。\r
+        */\r
+       public PageInfo getPageInfo() {\r
+               return pageInfo;\r
+       }\r
+\r
+       /**\r
+        * 属性追加。\r
+        * @param key\r
+        * @param value\r
+        */\r
+       public void setAttribute(String key, Object value){\r
+               attributeMap.put(key, value);\r
+       }\r
+       /**\r
+        * 属性取得。\r
+        * @param key\r
+        * @param value\r
+        */\r
+       public Object getAttribute(String key){\r
+               return attributeMap.get(key);\r
+       }\r
+\r
+       /**\r
+        * @return the checkedIdList\r
+        */\r
+       public Set<String> getCheckedIdList() {\r
+               return checkedIdList;\r
+       }\r
+\r
+       /**\r
+        * @param checkedIdList the checkedIdList to set\r
+        */\r
+       public void setCheckedIdList(Set<String> checkedIdList) {\r
+               this.checkedIdList = checkedIdList;\r
+       }\r
+}\r
diff --git a/src/com/lavans/luz2/util/ParameterUtils.java b/src/com/lavans/luz2/util/ParameterUtils.java
new file mode 100644 (file)
index 0000000..b02bcca
--- /dev/null
@@ -0,0 +1,126 @@
+package com.lavans.luz2.util;\r
+\r
+import java.io.UnsupportedEncodingException;\r
+import java.net.URLEncoder;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+\r
+/**\r
+ * IParameterizableのデータをやりとりするユーティリティ群。\r
+ * prefixはIParametarizable#getParameters()に実装することにした\r
+ * そうしないとsetParameters()とかloadStringのprefixとの関係があやふやになる\r
+ * \r
+ * @author dobashi\r
+ *\r
+ */\r
+public class ParameterUtils {\r
+       /**\r
+        * Map<String, String>からIParameterizable#setParameters()に適した\r
+        * Map<String, String[]>形式に変換。いらないかも\r
+        *\r
+        * @return\r
+        */\r
+//     public static Map<String, String[]> convertMap(Map<String, String> map){\r
+//             // Map<String, String[]>からMap<String, String>に変換\r
+//             Map<String, String[]> newMap = new HashMap<String, String[]>();\r
+//             for(Map.Entry<String, String> entry: map.entrySet()){\r
+//                     newMap.put(entry.getKey(), new String[]{entry.getValue()});\r
+//             }\r
+//             return newMap;\r
+//     }\r
+\r
+       /**\r
+        * Stringから読み込み。\r
+        * 引数で渡された文字列key1=value1&key2=value2..からMap<String, String[]>を作成する\r
+        *\r
+        * @param str\r
+        * @see getStoreString()\r
+        */\r
+       public static Map<String, String[]> loadString(IParameterizable target, String str){\r
+               Map<String, String[]> params = new HashMap<String, String[]>();\r
+               String strs[] = str.split("&");\r
+               for(int i = 0; i < strs.length; i++){\r
+                       if(strs[i].equals(""))\r
+                               continue;\r
+                       String datas[] = strs[i].split("=");\r
+                       String key = datas[0];\r
+                       String value = datas[1];\r
+                       if(params.containsKey(key)){\r
+                               // 存在している場合は文字列配列を取り出して最後に追加する\r
+                               int length = params.get(key).length;\r
+                               String values[] = new String[length+1];\r
+                               System.arraycopy(params.get(key), 0, values, 0, length);\r
+                               values[length] = value;\r
+                               params.put(datas[0], values);\r
+                       }else{\r
+                               params.put(datas[0], new String[]{ datas[1] });\r
+                       }\r
+               }\r
+\r
+               return params;\r
+       }\r
+\r
+       /**\r
+        * ターゲットをStringに変換。key1=value1形式。\r
+        * プリフィクス、エンコード無し。\r
+        * @param target\r
+        * @return\r
+        */\r
+       public static String toStoreString(IParameterizable target){\r
+               return toStoreString(target, "", null);\r
+       }\r
+\r
+       /**\r
+        * ターゲットをStringに変換。key1=value1形式。\r
+        * エンコード無し。\r
+        * @param target\r
+        * @prefix キー名の前につけるprefix. 例: 「cond.」をつければcond.memberId=1&cond.memberName=ああ\r
+        * @return\r
+        */\r
+       public static String toStoreString(IParameterizable target, String prefix){\r
+               return toStoreString(target, prefix, null);\r
+       }\r
+\r
+       /**\r
+        * ターゲットをkey1=value1形式のStringに変換。\r
+        * HTML用にvalue部分だけエンコードする。\r
+        * @param target\r
+        * @return\r
+        */\r
+       public static String toStoreString(IParameterizable target, String prefix, String encoding){\r
+               return toStoreString(target.getParameters(prefix), encoding);\r
+       }\r
+\r
+       /**\r
+        * Mapからkey1=value1&形式のStringに変換。\r
+        * HTML用にvalue部分だけエンコードする。\r
+        * @param target\r
+        * @return\r
+        */\r
+       public static String toStoreString(Map<String, String[]> params, String encoding){\r
+               // nullチェック\r
+               if (params == null){\r
+                       return "";\r
+               }\r
+\r
+               StringBuilder result = new StringBuilder();\r
+               for(Map.Entry<String, String[]> entry: params.entrySet()){\r
+                       String[] values=entry.getValue();\r
+                       for(String value: values){\r
+                               if(StringUtils.isEmpty(value)){\r
+                                       continue;\r
+                               }\r
+                               if(encoding!=null){\r
+                                       try {\r
+                                               value = URLEncoder.encode(value, encoding);\r
+                                       } catch (UnsupportedEncodingException e) {}\r
+                               }\r
+                               result.append(entry.getKey() + "="+ value +"&");\r
+                       }\r
+               }\r
+\r
+               return result.toString();\r
+       }\r
+}\r
diff --git a/src/test/BigDecimalTest.java b/src/test/BigDecimalTest.java
new file mode 100644 (file)
index 0000000..8dc67b8
--- /dev/null
@@ -0,0 +1,23 @@
+package test;\r
+\r
+import java.math.BigDecimal;\r
+import java.text.NumberFormat;\r
+import java.util.Locale;\r
+\r
+public class BigDecimalTest {\r
+       public static void main(String[] args){\r
+               NumberFormat nf = NumberFormat.getInstance(Locale.JAPANESE);\r
+               NumberFormat nf2= NumberFormat.getInstance(Locale.JAPANESE);\r
+               BigDecimal dec = new BigDecimal("-0.00001");\r
+               dec.setScale(4, BigDecimal.ROUND_FLOOR);\r
+               System.out.println(dec);\r
+               \r
+               System.out.println(nf.format(dec));\r
+               \r
+               nf.setMinimumFractionDigits(11);\r
+               System.out.println(nf.format(dec));\r
+               \r
+               nf.setMaximumFractionDigits(10);\r
+               System.out.println(nf2.format(dec));\r
+       }\r
+}\r
diff --git a/src/test/ConfigTest.java b/src/test/ConfigTest.java
new file mode 100644 (file)
index 0000000..c446e34
--- /dev/null
@@ -0,0 +1,32 @@
+package test;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+public class ConfigTest {\r
+\r
+       /**\r
+        * @param args\r
+        */\r
+       public static void main(String[] args) {\r
+               Config conf = Config.getInstance();\r
+               try {\r
+                       System.out.println(conf.getNodeValue("/luz/property/name2"));\r
+               } catch (XPathExpressionException e1) {\r
+                       e1.printStackTrace();\r
+               }\r
+               conf.setNodeValue("/luz/property/name1", "value2");\r
+               try {\r
+                       conf.save();\r
+               } catch (IOException e) {\r
+                       // TODO 自動生成された catch ブロック\r
+                       e.printStackTrace();\r
+               }\r
+//             HttpServletRequest req=null;\r
+//             EncodingFilter.EncodeHttpServletRequest r = new EncodingFilter.EncodeHttpServletRequest(req);\r
+       }\r
+\r
+}\r
diff --git a/src/test/ConnectTest.java b/src/test/ConnectTest.java
new file mode 100644 (file)
index 0000000..3cc5f39
--- /dev/null
@@ -0,0 +1,36 @@
+package test;\r
+\r
+import java.sql.ResultSet;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.DBManager;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+import com.lavans.luz2.sql.stats.Statistics;\r
+\r
+public class ConnectTest extends TestCase {\r
+       private static Log logger = LogFactory.getLog(Statistics.class);\r
+\r
+       \r
+       public void testConnect() throws Exception{\r
+               try {\r
+                       \r
+               BindConnection con = DBManager.getConnection();\r
+               BindPreparedStatement st = con.bindPrepareStatement("select * from tab");\r
+               ResultSet rs = st.executeQuery();\r
+               int i=1;\r
+               while(rs.next()){\r
+                       logger.info(i++);\r
+                       logger.info(rs.getString(1));\r
+                       logger.info(rs.getString(2));\r
+                       logger.info(rs.getString(3));\r
+               }\r
+               } catch (Exception e) {\r
+                       logger.info(e);\r
+               }\r
+       }\r
+}\r
diff --git a/src/test/Entity.java b/src/test/Entity.java
new file mode 100644 (file)
index 0000000..9d9101c
--- /dev/null
@@ -0,0 +1,8 @@
+package test;\r
+\r
+public interface Entity {\r
+       static String a="";\r
+       Entity.PK getPK();\r
+       interface PK{\r
+       }\r
+}\r
diff --git a/src/test/GDTEst.java b/src/test/GDTEst.java
new file mode 100644 (file)
index 0000000..b073e86
--- /dev/null
@@ -0,0 +1,82 @@
+package test;\r
+\r
+import java.io.Serializable;\r
+import java.lang.reflect.Field;\r
+import java.lang.reflect.Member;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import test.com.lavans.luz2.dao.old.GenericDao;\r
+\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+\r
+public class GDTEst {\r
+       private static Log logger = LogFactory.getLog(GDTEst.class);\r
+       public static void main(String args[]){\r
+               GDao<LMember> dao = new GDao<LMember>(LMember.class);\r
+       }\r
+}\r
+\r
+class GDao<T extends Entity> {\r
+       private static Log logger = LogFactory.getLog(GenericDao.class);\r
+\r
+       private String table, columnsSelect, columnsInsert, columnsUpdate;\r
+\r
+       public GDao(Class<T> clazz) {\r
+               super();\r
+               Class<? extends Serializable> pk = getPKClass(clazz);\r
+               table = StringUtils.toUnderscore(clazz.getSimpleName()).toUpperCase();\r
+               StringBuffer bufSelect = new StringBuffer();\r
+               StringBuffer bufInsert = new StringBuffer();\r
+               StringBuffer bufUpdate = new StringBuffer();\r
+               Field[] fields = clazz.getDeclaredFields();\r
+               Field[] fieldsPk = pk.getDeclaredFields();\r
+               for (Field field : fields) {\r
+                       logger.info(field.getType().getName());\r
+                       logger.info(field.getType().isMemberClass());\r
+                       logger.info(field.getType().isLocalClass());\r
+                       bufSelect.append(",").append(field.getName().toUpperCase());\r
+                       bufSelect.append(",").append(field.getName().toUpperCase());\r
+               }\r
+               columnsSelect = bufSelect.substring(1);\r
+               columnsInsert = bufInsert.toString();\r
+               columnsUpdate = bufUpdate.toString();\r
+               Object str = T.a;// clazz.getClasses();\r
+\r
+               logger.info(bufSelect.toString());\r
+               logger.info(str);\r
+\r
+       }\r
+\r
+       @SuppressWarnings("unchecked")\r
+       private Class<? extends Serializable> getPKClass(Class<T> clazz) {\r
+               Class<?>[] classes = clazz.getClasses();\r
+               for (Class<?> cls : classes) {\r
+                       logger.debug(cls.getSimpleName());\r
+                       if (cls.getSimpleName().equals("PK")) {\r
+                               return (Class<? extends Serializable>) cls;\r
+                       }\r
+               }\r
+               logger.error("Can't find PK class." + clazz.getName());\r
+               return null;\r
+       }\r
+\r
+\r
+}\r
+\r
+class LMember implements test.Entity{\r
+       private int id;\r
+       private String name;\r
+       private PK pk=null;\r
+       @Override\r
+       public Entity.PK getPK() {\r
+               pk = new PK();\r
+               pk.id=id;\r
+               return pk;\r
+       }\r
+       public class PK implements Entity.PK{\r
+               private int id;\r
+       }\r
+}
\ No newline at end of file
diff --git a/src/test/com/lavans/luz2/dao/old/DaoUtils.java b/src/test/com/lavans/luz2/dao/old/DaoUtils.java
new file mode 100644 (file)
index 0000000..cf0fb28
--- /dev/null
@@ -0,0 +1,116 @@
+package test.com.lavans.luz2.dao.old;\r
+\r
+import java.lang.reflect.Field;\r
+import java.sql.SQLException;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * Meta data get utility\r
+ * @author dobashi\r
+ *\r
+ */\r
+public class DaoUtils {\r
+       private static Log logger = LogFactory.getLog(GenericDao.class);\r
+\r
+       private static String toSqlName(String str){\r
+               return StringUtils.toUnderscore(str).toUpperCase();\r
+       }\r
+\r
+\r
+       // for dao\r
+       /**\r
+        * Make table name from entity name.\r
+        * Change camel case to bar\r
+        * @return\r
+        */\r
+       public static String getTableName(Class<?> entityClass){\r
+               return toSqlName(entityClass.getSimpleName());\r
+       }\r
+       /**\r
+        * Make all column\r
+        * Change camel case to bar\r
+        * @return\r
+        */\r
+       public static String getSelectColumns(List<Field> fields){\r
+               return toSqlName(StringUtils.join(getFieldNames(fields), ","));\r
+       }\r
+       public static String getInsertColumns(List<Field> fields){\r
+               return ":"+StringUtils.join(getFieldNames(fields), ",:");\r
+       }\r
+       public static String getUpdateColumns(List<Field> fields){\r
+               // null check\r
+               if(fields==null || fields.size()==0) return "";\r
+\r
+               StringBuilder sb = new StringBuilder();\r
+               for(Field field: fields){\r
+                       sb.append("AND ").append(toSqlName(field.getName())).append("=:").append(field.getName());\r
+               }\r
+               return sb.substring(4);\r
+       }\r
+\r
+       /**\r
+        * Get sequence name for serial id.\r
+        * @return\r
+        */\r
+       public static String getSequenceName(Field field){\r
+               // first field of pk should be serial.\r
+               // *** this mthod is for postgresql only ***\r
+               // @todo for other DB\r
+               String tableName = getTableName(field.getDeclaringClass());\r
+               String fieldname = toSqlName(field.getName());\r
+               return tableName+"_"+fieldname+"_SEQ";\r
+       }\r
+\r
+       private static List<String> getFieldNames(List<Field> src){\r
+               List<String> list = new LinkedList<String>();\r
+               for(Field field: src){\r
+                       list.add(field.getName());\r
+               }\r
+\r
+               logger.debug(list);\r
+\r
+               return list;\r
+       }\r
+\r
+       /**\r
+        * Make condition String for select from PK.\r
+        * @return\r
+        */\r
+       public static String getConditions(List<Field> fields){\r
+               StringBuilder sb = new StringBuilder();\r
+               for(Field field: fields){\r
+                       sb.append("AND "+toSqlName(field.getName()) +"=:"+ field.getName());\r
+               }\r
+\r
+               logger.debug(sb.toString());\r
+\r
+               return "WHERE"+ sb.substring(3);\r
+       }\r
+\r
+\r
+       /**\r
+        * xmlからSQL取得。共通部。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+        public static String getSql(Class<?> clazz, String key){\r
+               Config config = Config.getInstance(clazz.getName().replace(".","/")+".xml");\r
+               String sql="";\r
+               try {\r
+                       sql = config.getNodeValue("/sql/"+key).trim();\r
+               } catch (Exception e) {\r
+               }\r
+               if(StringUtils.isEmpty(sql)){\r
+                       logger.error("Can not find SQL["+ key +"]");\r
+               }\r
+               return sql;\r
+       }\r
+}\r
diff --git a/src/test/com/lavans/luz2/dao/old/EntityMetaData.java b/src/test/com/lavans/luz2/dao/old/EntityMetaData.java
new file mode 100644 (file)
index 0000000..71cc3ac
--- /dev/null
@@ -0,0 +1,180 @@
+package test.com.lavans.luz2.dao.old;\r
+\r
+import java.io.Serializable;\r
+import java.lang.reflect.Field;\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+import java.sql.SQLException;\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+\r
+public class EntityMetaData<T> {\r
+       private static Log logger = LogFactory.getLog(EntityMetaData.class);\r
+\r
+       // static utils\r
+\r
+       private Class<T> clazz;\r
+       private List<Field> entityFields, pkFields;\r
+\r
+       public EntityMetaData(Class<T> clazz){\r
+               this.clazz = clazz;\r
+\r
+               entityFields = new LinkedList<Field>(Arrays.asList(clazz.getDeclaredFields()));\r
+               pkFields = new LinkedList<Field>(Arrays.asList(getPKClass().getDeclaredFields()));\r
+\r
+               // except PK class.\r
+               Iterator<Field> ite = entityFields.listIterator();\r
+               while(ite.hasNext()){\r
+                       Field field = ite.next();\r
+                       // except member class(= PK class).\r
+                       if(field.getType().isMemberClass()){\r
+                               ite.remove();\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+\r
+       // =====================\r
+       // Entity meta utils\r
+       // =====================\r
+       /**\r
+        * get target entity class's class.\r
+        */\r
+       public Class<T> getEntityClass(){\r
+               return clazz;\r
+       }\r
+\r
+       /**\r
+        * get target entity PK's class.\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       public Class<? extends Serializable> getPKClass(){\r
+               Class<?>[] classes = clazz.getClasses();\r
+               for(Class<?> cls: classes){\r
+                       logger.debug(cls.getSimpleName());\r
+                       if(cls.getSimpleName().equals("PK")){\r
+                               return (Class<? extends Serializable>)cls;\r
+                       }\r
+               }\r
+               logger.error("Can't find PK class."+ clazz.getName());\r
+               return null;\r
+       }\r
+       /**\r
+        * make entity instance from map\r
+        * @param rs\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public T toEntity(Map<String, Object> dataMap)  {\r
+               //Constructor<T> constructor = clazz.getConstructor((Class<?>)null);\r
+               //T t = constructor.newInstance((Object[])null);\r
+               T entity = null;\r
+               try {\r
+                       entity = clazz.newInstance();\r
+\r
+                       // foreach of dataMap\r
+                       for(Entry<String, Object> entry: dataMap.entrySet()){\r
+                               logger.debug("search "+entry.toString());\r
+                               // find field.\r
+                               Field field = getField(StringUtils.toCamelCase(entry.getKey()));\r
+                               if(field==null){\r
+                                       logger.debug("Can't find field["+ entry.getKey() +"]");\r
+                                       continue;\r
+                               }\r
+\r
+                               // get Setter and set data.\r
+                               Method method = getSetterMethod(field);\r
+                               logger.debug(field.getName()+":"+method.getName()+"("+dataMap.get(field.getName())+")");\r
+                               method.invoke(entity, dataMap.get(field.getName()));\r
+                       }\r
+               } catch (Exception e) {\r
+                       // catch for debug\r
+                       logger.error("reflect error["+clazz.getSimpleName()+"]", e);\r
+               }\r
+\r
+               return entity;\r
+       }\r
+\r
+\r
+       /**\r
+        * Make Map<String fieldName, Object value> from Entity instance.\r
+        * エンティティインスタンスからMap<String fieldName, Object value>なMapを作る。\r
+        * @see makeEntity(Map)\r
+        *\r
+        * @param <PK>\r
+        * @param pk\r
+        * @return\r
+        * @throws NoSuchMethodException\r
+        * @throws InvocationTargetException\r
+        * @throws IllegalAccessException\r
+        * @throws SecurityException\r
+        * @throws IllegalArgumentException\r
+        */\r
+       public Map<String, Object> toParams(Object entity, List<Field> fields) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException{\r
+               // result map\r
+               Map<String, Object> params = new HashMap<String, Object>();\r
+\r
+               // invoke getter method for each pk field.\r
+               for(Field field: fields){ // =fieldsPk\r
+                       params.put(":"+field.getName(), getGetterMethod(field).invoke(entity));\r
+               }\r
+               logger.debug(params.toString());\r
+               return params;\r
+       }\r
+\r
+\r
+\r
+       // reflect utils\r
+       /**\r
+        * return getter meethod.\r
+        */\r
+       private Method getGetterMethod(Field field) throws SecurityException, NoSuchMethodException{\r
+               String methodName = "get"+StringUtils.capitalize(field.getName());\r
+               Method method = clazz.getMethod(methodName);\r
+               return method;\r
+       }\r
+       /**\r
+        * return setter meethod.\r
+        */\r
+       private Method getSetterMethod(Field field) throws SecurityException, NoSuchMethodException{\r
+               String methodName = "set"+StringUtils.capitalize(field.getName());\r
+               Method method = clazz.getMethod(methodName, field.getDeclaringClass());\r
+               return method;\r
+       }\r
+\r
+       /**\r
+        * get Field class from name.\r
+        * if name is no exist return null.\r
+        * @param name\r
+        * @return\r
+        */\r
+       private Field getField(String name){\r
+               for(Field field: entityFields){\r
+                       if(field.getName().equals(name)){\r
+                               return field;\r
+                       }\r
+               }\r
+               // not found.\r
+               return null;\r
+       }\r
+\r
+       public List<Field> getEntityFields() {\r
+               return entityFields;\r
+       }\r
+       public List<Field> getPkFields() {\r
+               return pkFields;\r
+       }\r
+\r
+}\r
+\r
diff --git a/src/test/com/lavans/luz2/dao/old/GenericDao.java b/src/test/com/lavans/luz2/dao/old/GenericDao.java
new file mode 100644 (file)
index 0000000..612ab39
--- /dev/null
@@ -0,0 +1,362 @@
+package test.com.lavans.luz2.dao.old;\r
+\r
+import java.lang.reflect.Field;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.sql.DBManager;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+import com.lavans.luz2.util.PageInfo;\r
+import com.lavans.luz2.util.Pager;\r
+\r
+/**\r
+ *\r
+ * @author dobashi\r
+ *\r
+ * @param <T>\r
+ */\r
+public class GenericDao<T> {\r
+       private static Log logger = LogFactory.getLog(GenericDao.class);\r
+       /** select SQL */\r
+       private static final String SQL_SELECT = "SELECT $select_columns FROM $table $condition $order $limit";\r
+       /** nextval SQL for PostgreSQL */\r
+       private static final String SQL_NEXTVAL = "SELECT NEXTVAL('$seq')";\r
+       /** insert SQL */\r
+       private static final String SQL_INSERT = "INSERT INTO $table VALUES( $insert_columns )";\r
+       /** update SQL */\r
+       private static final String SQL_UPDATE = "UPDATE $table SET $update_columns $condition_pk";\r
+       /** delete SQL */\r
+       private static final String SQL_DELETE = "DELETE FROM $table $condition";\r
+\r
+       //private Class<T> clazz;\r
+       private EntityMetaData<T> entityMetaData;\r
+       private String connectionName = "default";\r
+       //, seq;\r
+       /**\r
+        * Constructor.\r
+        */\r
+       public  GenericDao(Class<T> value){\r
+               super();\r
+               entityMetaData = new EntityMetaData<T>(value);\r
+               //clazz = value;\r
+       }\r
+\r
+       /**\r
+        * Constructor.\r
+        */\r
+       public  GenericDao(Class<T> value, String connectionName){\r
+               this(value);\r
+               this.connectionName = connectionName;\r
+       }\r
+\r
+       /**\r
+        * Executes the given SQL statement, which returns ResultSet object. This method convert ResultSet to List<Map<String, Object>>\r
+        *\r
+        * @return converted data.\r
+        */\r
+       public List<Map<String, Object>> executeQuery(String sql) throws SQLException {\r
+               return executeQuery(sql, null);\r
+       }\r
+       public List<Map<String, Object>> executeQuery(String sql, Map<String, Object> params) throws SQLException {\r
+               logger.debug(sql);\r
+               List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       ResultSet rs = st.executeQuery();\r
+                       if (rs.next()) {\r
+                               result.add(makeDataMap(rs));\r
+                       }\r
+                       logger.debug("result count = "+ result.size());\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * make a dataMap from ResultSet.\r
+        *\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private Map<String, Object> makeDataMap(ResultSet rs) throws SQLException {\r
+               Map<String, Object> result = new HashMap<String, Object>();\r
+               ResultSetMetaData metaData = rs.getMetaData();\r
+               for(int i=1; i<metaData.getColumnCount(); i++){\r
+                       result.put(metaData.getColumnName(i), rs.getObject(i));\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        *  Executes the given SQL statement, which returns effective rows(INSERT/DELETE/UPDATE) or returns nothing(DDL);\r
+        */\r
+\r
+       public int executeUpdate(String sql, Map<String, Object> params) throws SQLException {\r
+               logger.debug(sql);\r
+               int result = -1;\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       result = st.executeUpdate();\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+\r
+       /**\r
+        * Load single instance from PK.\r
+        * If data is not exist, return null.\r
+        */\r
+       public <PK> T load(PK pk) throws SQLException {\r
+               // result entity instance\r
+               T result = null;\r
+\r
+               // make sql\r
+               String sql = SQL_SELECT;\r
+               sql.replace("$select_columns", DaoUtils.getSelectColumns(entityMetaData.getEntityFields()));\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+               sql.replace("$condition", DaoUtils.getConditions(entityMetaData.getPkFields()));\r
+               sql.replace("$order", "");\r
+               sql.replace("$limit", "");\r
+\r
+               // make sql conditions\r
+               Map<String, Object> params = null;\r
+               try {\r
+                       params = entityMetaData.toParams(pk, entityMetaData.getPkFields());\r
+               }catch (Exception e) {\r
+                       // other exception has to be catched for only debug.\r
+                       logger.error("",e);\r
+               }\r
+\r
+               // execute sql\r
+               List<Map<String, Object>> list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               if(list.size()>0){\r
+                       result = entityMetaData.toEntity(list.get(0));\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * get next sequence id if id is serial.\r
+        * if pk is not serial, this method will throw SQLException.\r
+        * @return\r
+        */\r
+       public long getNextId() throws SQLException{\r
+               // if pk fiesld is not exist, throw exception;\r
+               List<Field> pkFields = entityMetaData.getPkFields();\r
+               if(pkFields == null || pkFields.size()==0){\r
+                       logger.debug("PK Field is NULL");\r
+               }\r
+               long id = -1;\r
+\r
+               String sql = SQL_NEXTVAL;\r
+               sql.replace("$seq", DaoUtils.getSequenceName(pkFields.get(0)));\r
+\r
+               // execute sql\r
+               List<Map<String, Object>> list = executeQuery(sql);\r
+               id = (Long)list.get(0).values().toArray()[0];\r
+               return id;\r
+       }\r
+\r
+       /**\r
+        * insert single instance.\r
+        * @return count of insert rows. usually 1.\r
+        */\r
+       public int insert(T entity) throws SQLException {\r
+               //long id = -1;\r
+               //id = getNextId();\r
+\r
+               // make sql\r
+               String sql = SQL_INSERT;\r
+               sql.replace("$insert_columns", DaoUtils.getInsertColumns(entityMetaData.getEntityFields()));\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+\r
+               // make sql conditions\r
+               Map<String, Object> params = null;\r
+               try {\r
+                       params = entityMetaData.toParams(entity, entityMetaData.getEntityFields());\r
+               }catch (Exception e) {\r
+                       // other exception has to be catched for only debug.\r
+                       logger.error("",e);\r
+               }\r
+\r
+               // execute sql\r
+               int result = executeUpdate(sql, params);\r
+               if (result != 1) {\r
+                       logger.info("INSERT result != 1.[" + result +"]");\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * update entity.\r
+        * @return count of update rows. 1 or 0(fail).\r
+        */\r
+       public int update(T entity) throws SQLException {\r
+               // make sql\r
+               String sql = SQL_UPDATE;\r
+               sql.replace("$update_columns", DaoUtils.getUpdateColumns(entityMetaData.getEntityFields()));\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+\r
+               // make sql conditions\r
+               Map<String, Object> params = null;\r
+               try {\r
+                       params = entityMetaData.toParams(entity, entityMetaData.getEntityFields());\r
+               }catch (Exception e) {\r
+                       // other exception has to be catched for only debug.\r
+                       logger.error("",e);\r
+               }\r
+\r
+               // execute sql\r
+               int result = executeUpdate(sql, params);\r
+               if (result != 1) {\r
+                       logger.info("UPDATE result != 1.[" + result +"]");\r
+               }\r
+\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * delete 1 instance\r
+        */\r
+       public <PK> int delete(PK pk) throws SQLException {\r
+               // make sql\r
+               String sql = SQL_DELETE;\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+               sql.replace("$condition", DaoUtils.getConditions(entityMetaData.getPkFields()));\r
+\r
+               // make sql conditions\r
+               Map<String, Object> params = null;\r
+               try {\r
+                       params = entityMetaData.toParams(pk, entityMetaData.getPkFields());\r
+               }catch (Exception e) {\r
+                       // other exception has to be catched for only debug.\r
+                       logger.error("",e);\r
+               }\r
+\r
+               // execute sql\r
+               int result = executeUpdate(sql, params);\r
+               if (result != 1) {\r
+                       logger.info("DELETE result != 1.[" + result +"]");\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * delete from condition. no need?\r
+        */\r
+//     public int delete(String condition, Map<String, Object> params)\r
+//                     throws SQLException {\r
+//             // make sql\r
+//             String sql = SQL_DELETE;\r
+//             sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+//             sql.replace("$condition", condition);\r
+//\r
+//             // execute sql\r
+//             int result = executeUpdate(sql, params);\r
+//             return result;\r
+//     }\r
+\r
+       /**\r
+        * list for pager\r
+        *\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public Pager<T> list(PageInfo pageInfo, String condition, String order, Map<String, Object> params) throws SQLException {\r
+               if (condition == null) condition = "";\r
+               if (order == null) order = "";\r
+\r
+               // make count sql\r
+               String sql = SQL_SELECT;\r
+               sql.replace("$select_columns", "COUNT(1)");\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+               sql.replace("$condition", condition);\r
+               sql.replace("$order", "");\r
+               sql.replace("$limit", "");\r
+\r
+               // execute count sql\r
+               List<Map<String, Object>> list = executeQuery(sql);\r
+               int count = (Integer)list.get(0).values().toArray()[0];\r
+\r
+\r
+               // make select sql\r
+               sql = SQL_SELECT;\r
+               sql.replace("$select_columns", DaoUtils.getSelectColumns(entityMetaData.getEntityFields()));\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+               sql.replace("$condition", condition);\r
+               sql.replace("$order", order);\r
+               int start = pageInfo.getPage() * pageInfo.getRows();\r
+               sql.replace("$limit", "OFFSET "+ start +" LIMIT "+ pageInfo.getRows());\r
+\r
+               // execute sql\r
+               list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               Pager<T> pager = new Pager<T>(pageInfo);\r
+               pager.setTotalCount(count);\r
+               for(Map<String, Object> dataMap: list){\r
+                       pager.add(entityMetaData.toEntity(dataMap));\r
+               }\r
+               return pager;\r
+       }\r
+\r
+       /**\r
+        *\r
+        *\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       public List<T> list(String condition, Map<String, Object> params) throws SQLException {\r
+               if (condition == null) condition = "";\r
+\r
+               // make select sql\r
+               String sql = SQL_SELECT;\r
+               sql.replace("$select_columns", DaoUtils.getSelectColumns(entityMetaData.getEntityFields()));\r
+               sql.replace("$table", DaoUtils.getTableName(entityMetaData.getEntityClass()));\r
+               sql.replace("$condition", condition);\r
+\r
+               // execute sql\r
+               List<Map<String, Object>> list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               List<T> resultList = new ArrayList<T>();\r
+               for(Map<String, Object> dataMap: list){\r
+                       resultList.add(entityMetaData.toEntity(dataMap));\r
+               }\r
+               return resultList;\r
+       }\r
+}\r
diff --git a/src/test/com/lavans/luz2/dao/old/SqlDao.java b/src/test/com/lavans/luz2/dao/old/SqlDao.java
new file mode 100644 (file)
index 0000000..ef2c349
--- /dev/null
@@ -0,0 +1,256 @@
+package test.com.lavans.luz2.dao.old;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+import java.sql.ResultSet;\r
+import java.sql.ResultSetMetaData;\r
+import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.StringUtils;\r
+import com.lavans.luz2.sql.DBManager;\r
+import com.lavans.luz2.sql.bind.BindConnection;\r
+import com.lavans.luz2.sql.bind.BindPreparedStatement;\r
+import com.lavans.luz2.util.Config;\r
+import com.lavans.luz2.util.PageInfo;\r
+import com.lavans.luz2.util.Pager;\r
+\r
+/**\r
+ * SQL実行用汎用Daoクラス\r
+ * 接続先ごとにインスタンスを持つが、connectionNameを使い分けているだけで\r
+ * all staticでも可能\r
+ *\r
+ * @author dobashi\r
+ *\r
+ * @param <T>\r
+ */\r
+public class SqlDao{\r
+       /** logger */\r
+       private static Log logger = LogFactory.getLog(SqlDao.class);\r
+\r
+       /**\r
+        * xmlからSQL取得。共通部。\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+        public static String getSql(Class<?> clazz, String key){\r
+               Config config = Config.getInstance(clazz.getName().replace(".","/")+".xml");\r
+               String sql="";\r
+               try {\r
+                       sql = config.getNodeValue("/sql/"+key).trim();\r
+               } catch (Exception e) {\r
+               }\r
+               if(StringUtils.isEmpty(sql)){\r
+                       logger.error("Can not find SQL["+ key +"]");\r
+               }\r
+               return sql;\r
+       }\r
+\r
+\r
+       /**\r
+        * インスタンス取得。\r
+        * デフォルトコネクション(default)\r
+        * @return\r
+        */\r
+       public static SqlDao getInstance(){\r
+               return getInstance("deafault");\r
+       }\r
+\r
+        /**\r
+         * インスタンス取得。\r
+         * 接続先DB指定\r
+         * @return\r
+         */\r
+       public static SqlDao getInstance(String connectionName){\r
+               return getInstance("deafault");\r
+       }\r
+\r
+       private String connectionName=null;\r
+\r
+       /**\r
+        * Executes the given SQL statement, which returns ResultSet object. This method convert ResultSet to List<Map<String, Object>>\r
+        *\r
+        * @return converted data.\r
+        */\r
+       public List<Map<String, Object>> executeQuery(String sql) throws SQLException {\r
+               return executeQuery(sql, null);\r
+       }\r
+       public List<Map<String, Object>> executeQuery(String sql, Map<String, Object> params) throws SQLException {\r
+               logger.debug(sql);\r
+               List<Map<String, Object>> result = null;\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       ResultSet rs = st.executeQuery();\r
+                       result = rsToMapList(rs);\r
+                       logger.debug("result count = "+ result.size());\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * ResultSetからList<Map<String, Object>>に変換\r
+        * @param rs\r
+        * @return\r
+        * @throws SQLException\r
+        */\r
+       private List<Map<String, Object>> rsToMapList(ResultSet rs) throws SQLException{\r
+               List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();\r
+               while (rs.next()) {\r
+                       Map<String, Object> record = new LinkedHashMap<String, Object>();\r
+                       ResultSetMetaData metaData = rs.getMetaData();\r
+                       for(int i=1; i<metaData.getColumnCount(); i++){\r
+                               record.put(metaData.getColumnName(i), rs.getObject(i));\r
+                       }\r
+                       result.add(record);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        *  Executes the given SQL statement, which returns effective rows(INSERT/DELETE/UPDATE) or returns nothing(DDL);\r
+        */\r
+\r
+       public int executeUpdate(String sql, Map<String, Object> params) throws SQLException {\r
+               logger.debug(sql);\r
+               int result = -1;\r
+               BindConnection con = null;\r
+               BindPreparedStatement st = null;\r
+               try {\r
+                       con = DBManager.getConnection(connectionName);\r
+                       st = con.bindPrepareStatement(sql);\r
+                       st.setParams(params);\r
+                       // execute SQL.\r
+                       result = st.executeUpdate();\r
+               }catch (SQLException e) {\r
+                       // SQLException needs rethrow.\r
+                       throw e;\r
+               } finally {\r
+                       try { st.close(); } catch (Exception e) {}\r
+                       try { con.close(); } catch (Exception e) {}\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * list for pager.\r
+        * You have to insert ":offset" and ":limit" like this:\r
+        * "SELECT * FROM MEMBER OFFSET :offset LIMIT :limit".\r
+        *\r
+        * @param <T>\r
+        * @param countSql      SQL string for count all.\r
+        * @param pageInfo\r
+        * @param sql           SQL string for select.\r
+        * @param params\r
+        * @return\r
+        * @throws SQLException\r
+        * @throws InvocationTargetException\r
+        * @throws NoSuchMethodException\r
+        * @throws IllegalAccessException\r
+        * @throws InstantiationException\r
+        */\r
+       public <T> Pager<T> list(Class<T> clazz, String countSql, PageInfo pageInfo, String sql, Map<String, Object> params) throws SQLException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {\r
+               // execute count sql\r
+               List<Map<String, Object>> list = executeQuery(sql);\r
+               int count = (Integer)list.get(0).values().toArray()[0];\r
+\r
+               // make select sql\r
+               int start = pageInfo.getPage() * pageInfo.getRows();\r
+               sql.replace(":offset", String.valueOf(start));\r
+               sql.replace(":limit",  String.valueOf(pageInfo.getRows()));\r
+               // これでもいける?\r
+//             params.put(":offset", start);\r
+//             params.put(":limit", pageInfo.getRows());\r
+\r
+               // execute sql\r
+               list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               Pager<T> pager = new Pager<T>(pageInfo);\r
+               pager.setTotalCount(count);\r
+               for(Map<String, Object> dataMap: list){\r
+                       pager.add(mapToEntity(dataMap, clazz));\r
+               }\r
+               return pager;\r
+       }\r
+\r
+\r
+       /**\r
+        * SQLから呼び出した汎用Map<String, Object>からEntityに変換\r
+        * try to set all columns to entity with java.lang.reflection\r
+        *\r
+        * @param <T>\r
+        * @param record\r
+        * @param clazz\r
+        * @return\r
+        * @throws InstantiationException\r
+        * @throws IllegalAccessException\r
+        * @throws NoSuchMethodException\r
+        * @throws InvocationTargetException\r
+        */\r
+       private <T> T mapToEntity(Map<String, Object> record, Class<T> clazz) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException{\r
+               T entity = clazz.newInstance();\r
+               // for each map member, set value to entity\r
+               for(Map.Entry<String, Object> column: record.entrySet()){\r
+                       // "MEMBER_ID_SEQ" -> "member_id_seq" -> "memberIdSeq"(Camel) -> "MemberIdSeq"(Capitalize) -> "setMemberId"\r
+                       String setterName = "set"+StringUtils.capitalize(StringUtils.toCamelCase(column.getKey().toLowerCase()));\r
+                       logger.debug(setterName);\r
+                       try {\r
+                               Method setterMethod = clazz.getMethod(setterName, column.getValue().getClass());\r
+                               setterMethod.invoke(entity, column.getValue());\r
+                       } catch (SecurityException e) {\r
+                               logger.error(setterName, e);\r
+                       } catch (NoSuchMethodException e) {\r
+                               logger.error(setterName, e);\r
+                               throw e;\r
+                       } catch (IllegalArgumentException e) {\r
+                               logger.error(setterName, e);\r
+                               throw e;\r
+                       } catch (InvocationTargetException e) {\r
+                               logger.error(setterName, e);\r
+                               throw e;\r
+                       }\r
+               }\r
+\r
+\r
+               return entity;\r
+       }\r
+\r
+       /**\r
+        *\r
+        *\r
+        * @return\r
+        * @throws SQLException\r
+        * @throws InvocationTargetException\r
+        * @throws NoSuchMethodException\r
+        * @throws IllegalAccessException\r
+        * @throws InstantiationException\r
+        */\r
+       public <T> List<T> list(Class<T> clazz, String sql, Map<String, Object> params) throws SQLException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {\r
+               // execute sql\r
+               List<Map<String, Object>> list = executeQuery(sql, params);\r
+\r
+               // make entity instance from result data.\r
+               List<T> resultList = new ArrayList<T>();\r
+               for(Map<String, Object> dataMap: list){\r
+                       resultList.add(mapToEntity(dataMap, clazz));\r
+               }\r
+               return resultList;\r
+       }\r
+}\r
diff --git a/src/test/com/lavans/luz2/text/NumberUtilTest.java b/src/test/com/lavans/luz2/text/NumberUtilTest.java
new file mode 100644 (file)
index 0000000..e8645a5
--- /dev/null
@@ -0,0 +1,24 @@
+package test.com.lavans.luz2.text;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
+import com.lavans.luz2.commons.NumberUtils;\r
+\r
+public class NumberUtilTest extends TestCase {\r
+       private static Log logger = LogFactory.getLog(NumberUtilTest.class.getName());\r
+\r
+       public void testIsNumeric(){\r
+               logger.info("1:"+NumberUtils.isNumeric("123.45"));\r
+               logger.info("2:"+NumberUtils.isNumeric("1121223.45"));\r
+               logger.info("3:"+NumberUtils.isNumeric("335,123.45"));\r
+               logger.info("4:"+NumberUtils.isNumeric("123.5"));\r
+               logger.info("5:"+NumberUtils.isNumeric("123.0"));\r
+               logger.info("6:"+NumberUtils.isNumeric("123.00abc00"));\r
+               logger.info("7:"+NumberUtils.isNumeric("123.xe0x00"));\r
+               logger.info("8:"+NumberUtils.isNumeric("a.0000"));\r
+               logger.info("9:"+NumberUtils.isNumeric("1"));\r
+       }\r
+}\r
diff --git a/src/test/com/lavans/luz2/text/StringUtilsTest.java b/src/test/com/lavans/luz2/text/StringUtilsTest.java
new file mode 100644 (file)
index 0000000..ccde18b
--- /dev/null
@@ -0,0 +1,9 @@
+package test.com.lavans.luz2.text;\r
+\r
+public class StringUtilsTest {\r
+       public static void main(String args[]){\r
+               System.out.println(" ()".trim());\r
+               System.out.println("   ( ) ".replaceAll("^[ \\s]*","").replaceAll(" $",""));\r
+\r
+       }\r
+}\r
diff --git a/src/test/com/lavans/luz2/text/ValidatorTest.java b/src/test/com/lavans/luz2/text/ValidatorTest.java
new file mode 100644 (file)
index 0000000..81090ca
--- /dev/null
@@ -0,0 +1,11 @@
+package test.com.lavans.luz2.text;\r
+\r
+import junit.framework.TestCase;\r
+\r
+public class ValidatorTest extends TestCase {\r
+       public void testEmailValidater(){\r
+//             assertTrue(Validator.isValidMail("\"土橋\" <dobashi@example.com>"));\r
+//             assertTrue(Validator.isValidMail("dobashi+? @example.com"));\r
+       }\r
+\r
+}\r
diff --git a/src/test/com/lavans/luz2/util2/InstanceManager.java b/src/test/com/lavans/luz2/util2/InstanceManager.java
new file mode 100644 (file)
index 0000000..3741885
--- /dev/null
@@ -0,0 +1,146 @@
+/* $Id: InstanceManager.java 415 2011-07-28 23:07:08Z dobashi $\r
+ * created: 2005/09/30\r
+ */\r
+package test.com.lavans.luz2.util2;\r
+\r
+import java.lang.reflect.Constructor;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import javax.xml.xpath.XPathExpressionException;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+import com.lavans.luz2.util.Config;\r
+\r
+/**\r
+ * @deprecated\r
+ * @author dobashi\r
+ */\r
+public class InstanceManager {\r
+       /** ロガー。debug用 */\r
+       private static Log logger = LogFactory.getLog(InstanceManager.class);\r
+\r
+       private static Config config = Config.getInstance("luz.xml");\r
+       private static String SERVICE_ROOT ="instance_manager";\r
+       private static String BEAN = "bean";\r
+       private static String ID = "id";\r
+       private static String CLASS = "class";\r
+       private static String SCOPE = "scope";\r
+\r
+       /** idとクラス名を保管 */\r
+       private static Map<String, Bean> beanMap = new HashMap<String, Bean>();\r
+\r
+       static{\r
+               init();\r
+       }\r
+       /**\r
+        * 初期化。\r
+        * 設定ファイルを読み込む。\r
+        *\r
+        */\r
+       public static void init(){\r
+               NodeList list=null;\r
+               try {\r
+                       list = config.getNodeList(SERVICE_ROOT);\r
+               } catch (XPathExpressionException e) {\r
+               }\r
+\r
+               // 指定無しの場合はなにもしない。\r
+               if(list==null){\r
+                       return;\r
+               }\r
+\r
+               // rootノード(=Midget)\r
+               // 各設定情報を取得\r
+               for(int i=0; i<list.getLength(); i++){\r
+                       Node node = list.item(i);\r
+//                     System.out.println(node.getNodeName());\r
+                       // テキストノードは無視\r
+//                     if((node.getNodeType()==Node.TEXT_NODE) ||\r
+//                        (node.getNodeType()==Node.COMMENT_NODE) ){\r
+//                             continue;\r
+//                     }\r
+\r
+                       if(node.getNodeName().equals(BEAN)){\r
+                               Element ele = (Element)node;\r
+                               Bean bean = new Bean();\r
+                               bean.id = ele.getAttribute(ID);\r
+                               bean.className = ele.getAttribute(CLASS);\r
+                               bean.scope = ele.getAttribute(SCOPE);\r
+\r
+                               beanMap.put(bean.id, bean);\r
+                       }else{\r
+                               logger.info("無効な設定項目["+ node.getNodeName() +"]");\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * 個別指定のサービスクラス名を返す。\r
+        * 未指定なら引数で渡されたクラス名でインスタンス化する。\r
+        * 失敗した場合はnull。\r
+        * クラス名をFQDNで渡す。\r
+        *\r
+        * @author dobashi\r
+        */\r
+       public static <T> T getInstance(Class<T> clazz){\r
+               return getInstance(clazz.getName(), clazz);\r
+       }\r
+       public static <T> T getInstance(String id){\r
+               return getInstance(id, null);\r
+       }\r
+       public static <T> T getInstance(String id, Class<T> clazz){\r
+               Bean bean = beanMap.get(id);\r
+               // 指定されたIDで取れない場合のデフォルト\r
+               if(bean==null && clazz!=null){\r
+                       // class型指定ありならfullクラス名\r
+                       bean = beanMap.get(clazz.getName());\r
+                       // デフォルトのimplを探す\r
+                       if(bean==null){\r
+                               String pkgNname = clazz.getName().substring(0, clazz.getName().lastIndexOf('.'));\r
+//                             String className = pkgNname+".impl."+clazz.getSimpleName()+"Impl";\r
+                               String className = clazz.getName();\r
+                               bean = new Bean();\r
+                               bean.id = id;\r
+                               bean.className = className;\r
+                       }\r
+                       if(bean!=null){\r
+                               beanMap.put(id, bean);\r
+                       }\r
+               }\r
+               try {\r
+                       // prototypeなら毎回新規作成\r
+                       if(bean.scope.equals("prototype")){\r
+                               Class<?> newClazz =  Class.forName(bean.className);\r
+                               Constructor<?> constructor = newClazz.getDeclaredConstructor(new Class[]{});\r
+                               //constructor.setAccessible(true);      //コンストラクタのアクセス権設定(singleton対策)\r
+                               return (T)constructor.newInstance((Object[])null);\r
+                       }else{\r
+                               // デフォルトはsingleton\r
+                               if(bean.object==null){\r
+                                       Class<?> newClazz =  Class.forName(bean.className);\r
+                                       Constructor<?> constructor = newClazz.getDeclaredConstructor(new Class[]{});\r
+                                       constructor.setAccessible(true);        //コンストラクタのアクセス権設定(singleton対策)\r
+                                       bean.object = constructor.newInstance((Object[])null);\r
+                               }\r
+                               return (T)bean.object;\r
+                       }\r
+               } catch (Exception e) {\r
+                       logger.error("初期化に失敗。cayen.xmlのinstance_manager設定を見直してください。", e);\r
+                       return null;\r
+               }\r
+       }\r
+       private static class Bean {\r
+               String id;\r
+               String className;\r
+               String scope="singleton";\r
+               Object object;\r
+               public Bean(){}\r
+       }\r
+\r
+}\r
diff --git a/src/test/com/lavans/luz2/util2/ParameterUtilTest.java b/src/test/com/lavans/luz2/util2/ParameterUtilTest.java
new file mode 100644 (file)
index 0000000..cf46d31
--- /dev/null
@@ -0,0 +1,15 @@
+package test.com.lavans.luz2.util2;\r
+\r
+import com.lavans.luz2.util.IParameterizable;\r
+import com.lavans.luz2.util.PageInfo;\r
+import com.lavans.luz2.util.ParameterUtils;\r
+\r
+public class ParameterUtilTest {\r
+       public static void main(String args[]){\r
+               IParameterizable pageInfo = new PageInfo();\r
+               String str ="rows=1&rows=2&page=1";\r
+               ParameterUtils.loadString(pageInfo, str);\r
+\r
+               System.out.println(pageInfo.getParameters(""));\r
+       }\r
+}\r