Explorar o código

增加NCsql工具代码

longht %!s(int64=2) %!d(string=hai) anos
pai
achega
aefa04f8b4

+ 10 - 9
.classpath

@@ -8,14 +8,15 @@
 	<classpathentry kind="src" path="METADATA"/>
 	<classpathentry kind="src" path="script"/>
 	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Ant_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Product_Common_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Middleware_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Framework_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Module_Public_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Module_Client_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Module_Private_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Module_Lang_Library"/>
-	<classpathentry kind="con" path="com.yonyou.ria.g2.container/Generated_EJB"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Ant_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Product_Common_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Middleware_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Framework_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Public_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Client_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Private_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Module_Lang_Library"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/Generated_EJB"/>
+	<classpathentry kind="con" path="com.yonyou.studio.udt.core.container/NCCloud_Library"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 6 - 0
META-INF/PubDevTool.upm

@@ -13,6 +13,12 @@
             <interface>nc.itf.pubdev.pubtool.BDTool.IBDDatasGainTool</interface>
             <implementation>nc.impl.pubdev.pubtool.BDTool.BDDatasGainToolimpl</implementation>
         </component> 
+        
+          <!--sqltool-->
+        <component remote="true" singleton="true" tx="CMT">
+            <interface>nc.itf.pubdev.pubtool.sqlTool.ISqlExecTool</interface>
+            <implementation>nc.impl.pubdev.pubtool.sqlTool.SqlExecToolimpl</implementation>
+        </component> 
 	</public>
 	<private>
 	</private>

+ 32 - 0
src/private/nc/impl/pubdev/pubtool/sqlTool/SqlExecToolimpl.java

@@ -0,0 +1,32 @@
+package nc.impl.pubdev.pubtool.sqlTool;
+
+import nc.bs.dao.BaseDAO;
+import nc.itf.pubdev.pubtool.sqlTool.ISqlExecTool;
+import nc.vo.pub.BusinessException;
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
+
+public class SqlExecToolimpl implements ISqlExecTool{
+
+	@Override
+	public void doNCExesql_RequiresNew(String sql) throws BusinessException {
+		// TODO Auto-generated method stub
+		try {
+			new BaseDAO().executeUpdate(sql);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			ExceptionUtils.wrappBusinessException("Ö´ÐÐsqlʧ°Ü£º"+e.getMessage());
+		}
+	}
+
+	@Override
+	public void doNCExesql(String sql) throws BusinessException {
+		// TODO Auto-generated method stub
+		try {
+			new BaseDAO().executeUpdate(sql);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			ExceptionUtils.wrappBusinessException("Ö´ÐÐsqlʧ°Ü£º"+e.getMessage());
+		}
+	}
+
+}

+ 23 - 0
src/public/nc/itf/pubdev/pubtool/sqlTool/ISqlExecTool.java

@@ -0,0 +1,23 @@
+package nc.itf.pubdev.pubtool.sqlTool;
+
+import nc.vo.pub.BusinessException;
+
+public interface ISqlExecTool {
+	
+	/**
+	 * 独立事务接口_nc
+	 * 一般执行 update or delete sql 
+	 * @param sql
+	 * @throws BusinessException
+	 */
+	public abstract void doNCExesql_RequiresNew(String sql ) throws BusinessException;
+	
+	/**
+	 * 非独立事务_nc
+	 *  一般执行 update or delete sql 
+	 * @param sql
+	 * @throws BusinessException
+	 */
+	public abstract void doNCExesql(String sql ) throws BusinessException;
+
+}

+ 29 - 0
src/public/nc/pub/tools/pubtool/SqlDevToolUtil.java

@@ -0,0 +1,29 @@
+package nc.pub.tools.pubtool;
+
+import org.apache.commons.lang3.StringUtils;
+
+import nc.bs.framework.common.NCLocator;
+import nc.itf.pubdev.pubtool.sqlTool.ISqlExecTool;
+import nc.vo.pub.BusinessException;
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
+
+public class SqlDevToolUtil {
+	
+	/**
+	 * NC执行sql
+	 * @param sql 一般执行 update or delete sql 
+	 * @param isalone 是否独立事务
+	 * @throws BusinessException 
+	 */
+	public static void ExecNcSql(String sql,boolean isalone) throws BusinessException {
+		if(StringUtils.isAllBlank(sql))
+			ExceptionUtils.wrappBusinessException("传入的sql不允许为空,请检查!!!");
+		if(isalone) {
+			NCLocator.getInstance().lookup(ISqlExecTool.class).doNCExesql_RequiresNew(sql);
+		}else {
+			NCLocator.getInstance().lookup(ISqlExecTool.class).doNCExesql(sql);
+		}
+	}
+	
+
+}