MySQL游标多一次循环

触发器代码片段如下:

declare c_name cursor for select b.id from asset_db_priv a,mc$priv_database b where a.node_name=b.priv_name and a.p_node_name=new.name;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; 
	set pnid=new.id;
	open c_name;
	REPEAT
        fetch c_name into p_id;
	    insert into db_operation_priv(op_id,priv_db_id,status) values (pnid,p_id,'1');
	UNTIL done END REPEAT;
	close c_name;

发现db_operation_priv表格会被多插一条记录(最后一条重复)。查看触发器代码很明显done = 1时还会执行一次insert,那么在insert之前加一层判断即可。我先加了if not done then或者if done<>1 then,发现insert 一次都没有执行,将done值插入测试表发现done在变为1之前都是null,改为if done is null then即可。
改好的代码片段如下:

declare c_name cursor for select b.id from asset_db_priv a,mc$priv_database b where a.node_name=b.priv_name and a.p_node_name=new.name;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; 
	set pnid=new.id;
	open c_name;
	REPEAT
        fetch c_name into p_id;
        if done is null then
	    insert into db_operation_priv(op_id,priv_db_id,status) values (pnid,p_id,'1');
	end if;
	UNTIL done END REPEAT;
	close c_name;

tuxedo simpapp 示例运行

接上文。
simpapp 是一个非常简单的示例:将客户端发送小写字母转换为大写返回给客户端。
所在目录:/home/tuxedo/bea/tuxedo12.1.1.0/samples/atmi/simpapp
这里为了不影响原文件,我将simpapp文件夹复制到/home/tuxedo/bea/tuxedo12.1.1.0/下。

1.配置tux.env文件

将/home/tuxedo/bea/tuxedo12.1.1.0/的tux.env文件复制到simpapp文件夹下。

[tuxedo@ant simpapp]$ ls
README  simpcl.c  simpserv.c tux.env  ubbsimple 

然后修改tux.env,添加红字部分

[tuxedo@ant simpapp]$ vi tux.env
TUXDIR=/home/tuxedo/bea/tuxedo12.1.1.0; export TUXDIR
JAVA_HOME=$TUXDIR/jre; export JAVA_HOME
JVMLIBS=$JAVA_HOME/lib/amd64/server:$JAVA_HOME/jre/bin
PATH=$TUXDIR/bin:$JAVA_HOME/bin:$PATH; export PATH
COBCPY=:$TUXDIR/cobinclude; export COBCPY
COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"; export COBOPT
SHLIB_PATH=$TUXDIR/lib:$JVMLIBS:$SHLIB_PATH; export SHLIB_PATH
LIBPATH=$TUXDIR/lib:$JVMLIBS:$LIBPATH; export LIBPATH
LD_LIBRARY_PATH=$TUXDIR/lib:$JVMLIBS:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
WEBJAVADIR=$TUXDIR/udataobj/webgui/java; export WEBJAVADIR

APPDIR=$TUXDIR/simpapp; export APPDIR
TUXCONFIG=$APPDIR/tuxconfig; export TUXCONFIG
LANG=C; export LANG
WSNADDR=//172.16.4.111:3200; export WSNADDR

2.配置ubbsimple文件

[tuxedo@ant simpapp]$ vi ubbsimple
#       (c) 2003 BEA Systems, Inc. All Rights Reserved.
#ident  "@(#) samples/atmi/simpapp/ubbsimple    $Revision: 1.7 $"

#Skeleton UBBCONFIG file for the TUXEDO Simple Application.
#Replace the  items with the appropriate values.

*RESOURCES
IPCKEY          123456

#Example:
#IPCKEY         123456

DOMAINID        simpapp
MASTER          simple
MAXACCESSERS    10
MAXSERVERS      5
MAXSERVICES     10
MODEL           SHM
LDBAL           N

*MACHINES
DEFAULT:
                APPDIR="/home/tuxedo/bea/tuxedo12.1.1.0/simpapp"
                TUXCONFIG="/home/tuxedo/bea/tuxedo12.1.1.0/simpapp/tuxconfig"
                TUXDIR="/home/tuxedo/bea/tuxedo12.1.1.0"
#注意与tux.env配置一致
#Example:
#               APPDIR="/home/me/simpapp"
#               TUXCONFIG="/home/me/simpapp/tuxconfig"
#               TUXDIR="/usr/tuxedo"

ant     LMID=simple     #ant为本机hostname
        MAXWSCLIENTS=5

#Example:
#beatux         LMID=simple

*GROUPS
GROUP1
        LMID=simple     GRPNO=1 OPENINFO=NONE

*SERVERS
DEFAULT:
                CLOPT="-A"

simpserv        SRVGRP=GROUP1 SRVID=1
WSL             SRVGRP=GROUP1 SRVID=10 #2个进程
                CLOPT="-A -- -n //172.16.4.111:3200"
#注意与tux.env配置一致
*SERVICES
TOUPPER

3.编译
设置环境变量:
[tuxedo@ant simpapp]$ . ./tux.env
读取UBBCONFIG 检查错误等:
[tuxedo@ant simpapp]$ tmloadcf -y ubbsimple
编译服务器端程序:
[tuxedo@ant simpapp]$ buildserver -f simpserv.c -o simpserv -s TOUPPER
编译客户端程序:
[tuxedo@ant simpapp]$ buildclient -f simpcl.c -o simpcl
如以上没有报错,即已经顺利完成。

4.运行
运行命令:

tmboot -y
[tuxedo@ant simpapp]$  tmboot -y
Booting all admin and server processes in /home/tuxedo/bea/tuxedo12.1.1.0/simpapp/tuxconfig
INFO: Oracle Tuxedo, Version 12.1.1.0, 64-bit, Patch Level (none)

Booting admin processes ...

exec BBL -A :
        process id=20610 ... Started.

Booting server processes ...

exec simpserv -A :
        process id=20612 ... Started.
exec WSL -A -- -n //172.16.4.111:3200 :
        process id=20613 ... Started.
3 processes started.
[tuxedo@ant simpapp]$

5.测试

[tuxedo@ant simpapp]$  ./simpcl hello
Returned string is: HELLO

关闭应用:
tmshutdown -y

测试2:(TCP/IP方式通讯)

[root@node1 simpapp]# tmloadcf -y ubbsimple 
[root@node1 simpapp]# buildclient -f simpcl.c -o ws -w  //重新编译客户端,ws 为编译的可执行程序,-w 参数表示客户端的编译是按照TCP/IP方式通讯的。

启动:
tmboot -y
测试:

[tuxedo@ant simpapp]$  ./ws hello
Returned string is: HELLO

6.注
如有CMDTUX_CAT:868: ERROR: tmloadcf cannot run on a non-master node报错,请确认hostname是否设置正确。
详细信息大家可以参考《Tuxedo企业级运维实战》这本书。

tuxedo12c简单安装过程

tuxedo下载地址:http://www.oracle.com/technetwork/cn/middleware/tuxedo/downloads/index.html
本次使用的版本为:Oracle Tuxedo 12cR1 (12.1.1.0)
安装包:tuxedo12110_64_linux_5_x86.bin
安装环境:centos5.5 64bit
在console模式下安装

[tuxedo@localhost tmp]$ ./tuxedo12110_64_linux_5_x86.bin -i console
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...

Launching installer...

Preparing CONSOLE Mode Installation...

===============================================================================
Choose Locale...
----------------

  ->1- English

CHOOSE LOCALE BY NUMBER:
===============================================================================
Tuxedo 12.1.1.0                   (created with InstallAnywhere by Macrovision)
-------------------------------------------------------------------------------




===============================================================================
Introduction
------------

InstallAnywhere will guide you through the Tuxedo 12.1.1.0 installation.



It is strongly recommended that you quit all programs before continuing with
this installation.

Enter "next' to proceed to the next screen. Enter "back" to modify the previous
screen.

You may cancel this installation at any time by typing "quit".



WARNING: "Quitting" creates an incomplete  Tuxedo 12.1.1.0 installation.You
must re-install  Tuxedo 12.1.1.0. For more information, see "Preparing to
Install the Oracle Tuxedo System" in the  Tuxedo 12.1.1.0 Installation Guide.



PRESS  TO CONTINUE:



===============================================================================
Choose Install Set
------------------

Please choose the Install Set to be installed by this installer.

  ->1- Full Install
    2- Server Install
    3- Full Client Install
    4- Jolt Client Install
    5- ATMI Client Install
    6- CORBA Client Install

    7- Customize...

ENTER THE NUMBER FOR THE INSTALL SET, OR PRESS  TO ACCEPT THE DEFAULT
   :



===============================================================================
Choose Oracle Home
------------------


    1- Create new Oracle Home

Enter a number:
Enter a number: 1
Specify a new Oracle Home directory: /tuxedo/bea
Path must be absolute and have write permission!
Specify a new Oracle Home directory: /home/tuxedo/bea



===============================================================================
Choose Product Directory
------------------------


    1- Modify Current Selection (/home/tuxedo/bea/tuxedo12.1.1.0)
    2- Use Current Selection (/home/tuxedo/bea/tuxedo12.1.1.0)

Enter a number: 2
Install Samples (Y/N): y



===============================================================================
Pre-Installation Summary
------------------------

Please Review the Following Before Continuing:

Product Name:
    Tuxedo 12.1.1.0

Install Folder:
    /home/tuxedo/bea/tuxedo12.1.1.0

Required Space:
    382 MB

Available Space:
    10599 MB



PRESS  TO CONTINUE:



===============================================================================
Ready To Install
----------------

InstallAnywhere is now ready to install Tuxedo 12.1.1.0 onto your system at the
following location:



   /home/tuxedo/bea/tuxedo12.1.1.0

PRESS  TO INSTALL:



===============================================================================
Installing...
-------------

 [==================|==================|==================|==================]
 [------------------|------------------|------------------|------------------]



===============================================================================
Configure tlisten Service
-------------------------

Password:
Verify Password:
Passwords do not match, re-enter password.
Password:
Verify Password:
Password Accepted! Please wait...



===============================================================================
SSL Installation Choice.
------------------------

Would you like to install SSL Support?

  ->1- Yes
    2- No

ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS  TO ACCEPT THE DEFAULT:
   : 2




===============================================================================
Installation Complete
---------------------

Congratulations. Tuxedo 12.1.1.0 has been successfully installed to:



   /home/tuxedo/bea/tuxedo12.1.1.0

PRESS  TO EXIT THE INSTALLER:

[tuxedo@localhost tmp]$

java.lang.UnsupportedOperationException 异常

报错信息如下:

Exception in thread "main" java.lang.UnsupportedOperationException
	at java.util.AbstractList.add(Unknown Source)
	at java.util.AbstractList.add(Unknown Source)
	at Wmic.main(Wmic.java:129)

测试代码:

List list = Arrays.asList("test".split(","));
list.add("test2");

调试发现执行Arrays.asList后的list是java.util.Arrays$ArrayList类型,即是Arrays的一个内部类,其继承自AbstractList,没有override add()等方法,所以会报没有提供该方法的异常,具体可以查看JDK源码。

解决方法:

List list = Arrays.asList("test".split(","));
List arrayList = new ArrayList(list);
arrayList.add("test2");