postgreSQLでidの自動採番方法

SQLコマンド
ALTER TABLE “public”.”sys_user”
DROP CONSTRAINT “sys_user_pkey” ,
DROP COLUMN “id”,
ADD COLUMN “id” serial8 NOT NULL,
ADD CONSTRAINT “sys_user_pkey” PRIMARY KEY (“id”);

CentOSでJDKのインストールメモ

1.OSの確認
# uname -a
Linux localhost.localdomain 3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

2.JDK8のインストール
#cd usr/local/
#mkdir ct
#cd ct/

# tar -zxv -f jdk-8u65-linux-i586.gz
#mv jdk1.8.0_65 javajdk
#cd javajdk

3.環境変数
#vim /etc/profile
追記
JAVA_HOME=/usr/local/kencery/javajdk
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH

#source /etc/profile
#java -version
# echo $JAVA_HOME
4.JDKのアンインストール
#rpm -qa|grep jdk
#yum -y remove java java java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64

Windows7でJava環境構築の変数設定メモ

操作手順
「コントロールパネル」-システムセキュリティ-システム
「システムの詳細設定」-環境変数->新規

変数名:JAVA_HOME
変数値:C:\Program Files\Java\jdk1.8.0_111
変数名:PATH
変数値:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

変数名:CLASSPATH
変数値:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

TomcatのクラスタリングClusterの設定方法

設定内容
<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster” channelSendOptions=”8″>
<Manager className=”org.apache.catalina.ha.session.DeltaManager”
expireSessionsOnShutdown=”false”
notifyListenersOnReplication=”true”/>

<Channel className=”org.apache.catalina.tribes.group.GroupChannel”>

<Membership className=”org.apache.catalina.tribes.membership.McastService”
address=”125.1.2.12″
port=”45564″
frequency=”500″
dropTime=”3000″/>
<Receiver className=”org.apache.catalina.tribes.transport.nio.NioReceiver”
address=”auto”
port=”4000″
autoBind=”100″
selectorTimeout=”5000″
maxThreads=”6″/>

<Sender className=”org.apache.catalina.tribes.transport.ReplicationTransmitter”>

<Transport className=”org.apache.catalina.tribes.transport.nio.PooledParallelSender”/>
</Sender>
<Interceptor className=”org.apache.catalina.tribes.group.interceptors.TcpFailureDetector”/>

<Interceptor className=”org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor”/>
</Channel>
<Valve className=”org.apache.catalina.ha.tcp.ReplicationValve” filter=””/>
<Valve className=”org.apache.catalina.ha.session.JvmRouteBinderValve”/>

<Deployer className=”org.apache.catalina.ha.deploy.FarmWarDeployer”
tempDir=”/tmp/war-temp/”
deployDir=”/tmp/war-deploy/”
watchDir=”/tmp/war-listen/”
watchEnabled=”false”/>
<ClusterListener className=”org.apache.catalina.ha.session.ClusterSessionListener”/>
</Cluster>

「JavaScript入門」正規表現の使用方法

1.数字の判断
function isDigit(s)
{
var patrule=/^[0-9]{1,20}$/;
if (!patrule.exec(s)) return false
return true
}

2. ログイン名のチェック
function isRegUserName(s)
{
var patrule=/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;
if (!patrule.exec(s))
return false
return true
}

3.ユーザ名のチェック
function isValidUserName(s)
{
var patrule=/^[a-zA-Z]{1,30}$/;
if (!patrule.exec(s)) return false
return true
}
}}
//パスワードのチェック
function isUserPassword(s)
{
var patrule=/^(/w){6,20}$/;
if (!patrule.exec(s)) return false
return true
}

MySQLで複数テーブルのデータを削除する

1.テーブルの作成
CREATE TABLE table1 (id int, username nvarchar(30));
CREATE TABLE table2 (id int);
CREATE TABLE table3 (id int);
CREATE TABLE table4 (id int);

INSERT INTO table1 VALUES (1, ‘testuser’),(2, ‘ctmuser’);
INSERT INTO table2 VALUES (1),(2);
INSERT INTO table3 VALUES (1),(2);
INSERT INTO table4 VALUES (1),(2);

SELECT COUNT(*) FROM table1;
2
SELECT COUNT(*) FROM table2;
2
SELECT COUNT(*) FROM table3;
2
SELECT COUNT(*) FROM table4;
2
2.MySQL複数のテーブルのデータを削除
DELETE t1, t2, t3, t4 FROM
table1 as t1
INNER JOIN table2 as t2 on t1.id = t2.id
INNER JOIN table3 as t3 on t1.id=t3.id
INNER JOIN table4 as t4 on t1.id=t4.id
WHERE t1.username=’testuser’ AND t1.id=’1′;

CentOS 6.7にsysstatのインストール、設定と基本操作コマンド

1.インストール
# cat /etc/redhat-release
CentOS release 6.7 (Final)
# yum install sysstat
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
epel/metalink | 5.3 kB 00:00
* base: ftp.iij.ad.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
base | 3.7 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:01
extras | 3.4 kB 00:00
nginx | 2.9 kB 00:00
nginx/primary_db | 19 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 4.3 MB 00:00
Resolving Dependencies
–> Running transaction check
—> Package sysstat.x86_64 0:9.0.4-27.el6 will be updated
—> Package sysstat.x86_64 0:9.0.4-31.el6 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Updating:
sysstat x86_64 9.0.4-31.el6 base 234 k

Transaction Summary
========================================================================================================================
Upgrade 1 Package(s)

Total download size: 234 k
Is this ok [y/N]: y
Downloading Packages:
sysstat-9.0.4-31.el6.x86_64.rpm | 234 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : sysstat-9.0.4-31.el6.x86_64 1/2
Cleanup : sysstat-9.0.4-27.el6.x86_64 2/2
Verifying : sysstat-9.0.4-31.el6.x86_64 1/2
Verifying : sysstat-9.0.4-27.el6.x86_64 2/2

Updated:
sysstat.x86_64 0:9.0.4-31.el6

Complete!

2.設定
2.1 sysstat の Crontab 設定
#vi /etc/cron.d/sysstat

# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# 0 * * * * root /usr/lib64/sa/sa1 600 6 &
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A

箇所1
修正前
*/10 * * * * root /usr/lib64/sa/sa1 1 1
修正後
*/6 * * * * root /usr/lib64/sa/sa1 1 1

箇所2
修正前
53 23 * * * root /usr/lib64/sa/sa2 -A

修正後
59 23 * * * root /usr/lib64/sa/sa2 -A
2.2 リソース状態の保存期間の設定
#vi /etc/sysconfig/sysstat
# How long to keep log files (in days).
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=28

修正前
HISTORY=28

修正後
HISTORY=7
3.ログ確認
# less /var/log/sa/sar06
0:00:01 CPU %usr %nice %sys %iowait %steal %irq %soft %guest %idle
00:10:01 all 3.22 0.00 0.15 0.22 0.06 0.00 0.00 0.00 96.36
00:10:01 0 2.44 0.00 0.10 0.50 0.09 0.00 0.00 0.00 96.88
4.CPU使用状況
#sar -u 1
09:46:11 CPU %user %nice %system %iowait %steal %idle
09:46:12 all 0.00 0.00 0.00 0.00 0.00 100.00

5.ロードアベレージ確認

#sar -q 1
09:47:21 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
09:47:22 1 168 0.08 0.03 0.01
09:47:23 0 167 0.08 0.03 0.01
09:47:24 0 167 0.08 0.03 0.01

6.コンテキストスイッチ確認

#sar -w 1

09:48:04 proc/s cswch/s
09:48:05 0.00 87.00
09:48:06 0.00 145.00

7.メモリ確認
#sar -r 1
09:48:26 kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
09:48:27 96760 1825312 94.97 4036 106284 2583268 64.27
09:48:28 96760 1825312 94.97 4036 106284 2583268 64.27
09:48:29 96760 1825312 94.97 4036 106284 2583268 64.2
8.スワップ確認
#sar -S 1
09:49:07 kbswpfree kbswpused %swpused kbswpcad %swpcad
09:49:08 1762912 334236 15.94 15912 4.76
09:49:09 1762912 334236 15.94 15912 4.76
09:49:10 1762912 334236 15.94 15912 4.76

9.ディスク確認
# sar -p -d 1 1
09:49:48 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
09:49:49 vda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
Average: vda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

struts+spring+hibernateでのSQL構文を実行する

javaコード:
String strhsql = “delete CFTTable cft where cft.Userid= ?”;
Query query = this.getSession().createQuery(strhsql);
query.setString(0, “007”);
query.executeUpdate();

UbuntuにrootログインGUI画面を設定する方法

#vim /etc/lightdm/lightdm.conf

設定内容
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
greeter-show-manual-login=true

Spring MVCでエイリアス(alias)インターセプターを利用する

1.web.xmlにFilterクラスを指定
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

2.struts.xmlにパラメータを設定する
Action1の定義
<action name=”XXX” class=”XXXAction”>
<result name=”success”></result>
<result name=”input” type=”chain”>
<param name=”actionName”>input_error</param>
</result>
</action>

Action2の定義
<action name=”input_error” class=”inputErrorAction”>
<param name=”aliases”>#{‘error_status’:’status’,’error_desc’:’desc’}</param>
</action>