Monthly Archives: 8月 2016

Oracleでテーブルロック(table lock)とsessionプロセス(process)を殺す(kill)

1.ロックされたテーブルを探す
select count(*) from v$locked_object;
select * from v$locked_object;

2.ロックされたテーブルの詳細情報を探す
select n.owner,n.object_name,m.session_id,m.locked_mode
from v$locked_object m,dba_objects n
where n.object_id = m.object_id;

3.sessionを探す
select n.username,n.sid,n.serial#,logon_time
from v$locked_object m,v$session n
where m.session_id = n.sid order by n.logon_time;

4.プロセスを殺す
alter system kill session’3020,34′;
sid->3030 serial#->34

Java開発入門–@Temporal(TemporalType.DATE)の使い方

1.基本知識
DATE ->java.sql.Date
TIME ->java.sql.Time
TIMESTAMP->java.sql.Timestamp

2.年月日DATE
@Temporal(TemporalType.DATE)
@Column(name = “updateDate”, nullable = false, length = 10)
public Date getUpdateDate() {
return updateDate;
}

結果:2016-06-05

3.時間TIME
@Temporal(TemporalType.TIME)
結果:12:50:30

4.TIMESTAMP
@Temporal(TemporalType.TIMESTAMP)
結果:2016-06-05 12:51:34:000

5.JSP画面に日時を表示
<td align=”center”>&nbsp;<fmt:formatDate value=”${list[0].createTime}” pattern=”yyyy-MM-dd HH:mm:ss”></fmt:formatDate></td>

Java入門–Class.forName()の使い方

サンプルコード:
public class ReflectDemoClass {

public ReflectDemoClass() {
System.out.println(“>>ReflectDemoClass() construct>>”);
}
static {
System.out.println(“***ReflectDemoClass static operation***”);
}

public static void main(String[] args) {
try {
Class.forName(“kaku.DateDemoClassObj”);
} catch (ClassNotFoundException e) {

e.printStackTrace();
}
}
}

実行結果
***ReflectDemoClass static operation***

JavaScriptでHash機能を実現する

サンプルコード
Hash = function () {
}
Hash.prototype = {
constructor: Hash,
add: function (k, v) {
if (!this.hasOwnProperty(k)) {
this[k] = v;
}
},
remove: function (k) {
if (this.hasOwnProperty(k)) {
delete this[k];
}
},
update: function (k, v) {
this[k] = v;
},
has: function (k) {
var type = typeof k;
if (type === ‘string’ || type === ‘number’) {
return this.hasOwnProperty(k);
} else if (type === ‘function’ && this.some(k)) {
return true;
}
return false;
},
clear: function () {
for (var k in this) {
if (this.hasOwnProperty(k)) {
delete this[k];
}
}
},
empty: function () {
for (var k in this) {
if (this.hasOwnProperty(k)) {
return false;
}
}
return true;
},
each: function (fn) {
for (var k in this) {
if (this.hasOwnProperty(k)) {
fn.call(this, this[k], k, this);
}
}
},
map: function (fn) {
var hash = new Hash;
for (var k in this) {
if (this.hasOwnProperty(k)) {
hash.add(k, fn.call(this, this[k], k, this));
}
}
return hash;
},
filter: function (fn) {
var hash = new Hash;
for (var k in this) {

}
},
join: function (split) {
split = split !== undefined ? split : ‘,’;
var rst = [];
this.each(function (v) {
rst.push(v);
});
return rst.join(split);
},
every: function (fn) {
for (var k in this) {
if (this.hasOwnProperty(k)) {
if (!fn.call(this, this[k], k, this)) {
return false;
}
}
}
return true;
},
some: function (fn) {
for (var k in this) {
if (this.hasOwnProperty(k)) {
if (fn.call(this, this[k], k, this)) {
return true;
}
}
}
return false;
},
find: function (k) {
var type = typeof k;
if (type === ‘string’ || type === ‘number’ && this.has(k)) {
return this[k];
} else if (type === ‘function’) {
for (var _k in this) {
if (this.hasOwnProperty(_k) && k.call(this, this[_k], _k, this)) {
return this[_k];
}
}
}
return null;
}
};

Java開発メモ–log4j.propertiesの詳細設定方法

必要なライブラリ
log4j-1.2.8.jar

CLASSPATHの直下にlog4j.propertiesを作成する

サンプルコード
log4j.rootCategory=INFO, stdout , R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=C:\\Tomcat 5.5\\logs\\start.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
1log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c – %m%n

log4j.logger.com.startnews24=DEBUG
log4j.logger.com.opensymphony.oscache=ERROR
log4j.logger.net.sf.navigator=ERROR
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=ERROR
log4j.logger.org.springframework=DEBUG
log4j.logger.com.ibatis.db=WARN
log4j.logger.org.apache.velocity=FATAL

log4j.logger.com.ctn.checkhp=WARN

log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN
log4j.logger.org.hibernate=DEBUG
log4j.logger.org.logicalcobwebs=WARN

log4j.rootCategory=INFO, stdout , R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=C:\\Tomcat 5.5\\logs\\start.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
1log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c – %m%n

log4j.logger.com.startnews24=DEBUG
log4j.logger.com.opensymphony.oscache=ERROR
log4j.logger.net.sf.navigator=ERROR
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=ERROR
log4j.logger.org.springframework=DEBUG
log4j.logger.com.ibatis.db=WARN
log4j.logger.org.apache.velocity=FATAL

log4j.logger.com.ctn.checkhp=WARN

log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN
log4j.logger.org.hibernate=DEBUG
log4j.logger.org.logicalcobwebs=WARN
ログ出力
protected final Log log = LogFactory.getLog(getClass());
if (log.isDebugEnabled()){

log.debug(“Ouput log …..”);

}

Oracle SQL でdecode関数のorder byの使い方

SQL構文
SELECT kotost.adv_cd
FROM mg_ kotost kotost
ORDER BY decode(kotost.adv_cd,
‘COST’,
1,
‘INCOME’,
2,
3) ASC;

実行結果
17 COST
18 COST
19 COST
20 INCOME
21 INCOME
22 INCOME

Java開発入門–ArrayListとLinkedList配列にForとIteratorを使って実行時間を計算する

javaコード:
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class IteratorSampleFuncDemo {

public static long LoopsForCheck(List<String> list) {
long start = 0L, end = 0L;
@SuppressWarnings(“unused”)
String ck = null;
start = System.nanoTime();
for (int i = list.size() – 1; i >= 0; –i) {
ck = list.get(i);
}
end = System.nanoTime();
return end – start;
}

public static long IteratorCheckFunc(List<String> list) {
long start = 0L, end = 0L;
@SuppressWarnings(“unused”)
String ck = null;
start = System.nanoTime();
Iterator<String> it = list.iterator();
while (it.hasNext()) {
ck = it.next();
}
end = System.nanoTime();
return end – start;
}

public static void main(String[] args) {

final int lstLen = 20000;
List<String> arraylist = new ArrayList<String>();
List<String> linkedlist = new LinkedList<String>();
for (int i = 0; i < lstLen; ++i) {
String s = Integer.toString(i, 2);
arraylist.add(s);
linkedlist.add(s);
}
final String FORMAT = “%1$-16s%2$-16s%3$16d\n”;
System.out.println(“Test Result as Follows”);
System.out.println(“List\t\tType\t\tTime(nanoseconds)”);
System.out.println(“————————————————-“);
System.out.printf(FORMAT, “ArrayList”, “For”, LoopsForCheck(arraylist));
System.out.printf(FORMAT, “ArrayList”, “Iterator”, IteratorCheckFunc(arraylist));
System.out.printf(FORMAT, “LinkedList”, “For”, LoopsForCheck(linkedlist));
System.out.printf(FORMAT, “LinkedList”, “Iterator”, IteratorCheckFunc(linkedlist));
}

}

実行結果
Test Result as Follows
List Type Time(nanoseconds)
————————————————-
ArrayList For 2113920
ArrayList Iterator 1917363
LinkedList For 617852031
LinkedList Iterator 1624393

C#でConnector/Net 6.9.9を使ってMySQLに接続する方法

1.Connector/Netのダウンロード

http://dev.mysql.com/downloads/connector/net/

2.web.configの設定

<configuration
<connectionStrings>
<addname=”MysqlConnection”connectionString=”server=localhost;userid=root;password=pwdstartnews24;database=dbstartnews24;”/>
</connectionStrings>
</configuration
3.MySQLに接続するコード
string sqlstring = System.Configuration.ConfigurationManager.ConnectionStrings[“MysqlConnection”].ConnectionString;
MySqlConnection myconn=new MySqlConnection(sqlstring);
myconn.Open();

正規表現入門–IPアドレス、日時、年月日のチェック方法

①IPアドレス
^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$

②日時HH:MM:SS

([0-1][0-9]|2[0-3])\:[0-5][0-9]\:[0-5][0-9]

③年月日YYYY/MM/DD

^[0-9]{4}/(((0[13578]|(10|12))/(0[1-9]|[1-2][0-9]|3[0-1]))|(02/(0[1-9]|[1-2][0-9]))|((0[469]|11)/(0[1-9]|[1-2][0-9]|30)))$

ASP.NET入門–FileUpload手動入力禁止方法

1.htmlコード
<input type=”text” name=”tmd_st” onkeydown=”event.returnValue=false;” onpaste=”return false” />

2.Server側コード
<asp:TextBox ID=”tmd_qd” runat=”server” onkeydown=”event.returnValue=false;” onpaste=”return false”></asp:TextBox>

3.FileUpload手動入力禁止
<asp:FileUpload ID=”msj_file” runat=”server” onkeydown=”event.returnValue=false;” onpaste=”return false” />

1 / 612345...最後 »