1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Data;
|
21
|
|
using Seasar.Extension.ADO;
|
22
|
|
using Seasar.Framework.Log;
|
23
|
|
using Seasar.Framework.Util;
|
24
|
|
|
25
|
|
namespace Seasar.Extension.ADO.Impl
|
26
|
|
{
|
27
|
|
public class BasicUpdateHandler : BasicHandler, IUpdateHandler
|
28
|
|
{
|
29
|
|
private static Logger logger = Logger.GetLogger(typeof(BasicUpdateHandler));
|
30
|
|
|
31
|
0
|
public BasicUpdateHandler()
|
32
|
|
{
|
33
|
|
}
|
34
|
|
|
35
|
10
|
public BasicUpdateHandler(IDataSource dataSource, string sql)
|
36
|
|
: base(dataSource, sql)
|
37
|
|
{
|
38
|
|
}
|
39
|
|
|
40
|
0
|
public BasicUpdateHandler(IDataSource dataSource, string sql,
|
41
|
|
ICommandFactory commandFactory)
|
42
|
|
: base(dataSource, sql, commandFactory)
|
43
|
|
{
|
44
|
|
}
|
45
|
|
|
46
|
|
#region IUpdateHandler メンバ
|
47
|
|
|
48
|
4
|
public int Execute(object[] args)
|
49
|
|
{
|
50
|
4
|
Type[] argTypes = GetArgTypes(args);
|
51
|
4
|
string[] argNames = GetArgNames();
|
52
|
4
|
return Execute(args, argTypes, argNames);
|
53
|
|
}
|
54
|
|
|
55
|
10
|
public int Execute(object[] args, Type[] argTypes, string[] argNames)
|
56
|
|
{
|
57
|
10
|
if(logger.IsDebugEnabled)
|
58
|
10
|
logger.Debug(GetCompleteSql(args));
|
59
|
10
|
IDbConnection connection = Connection;
|
60
|
10
|
try
|
61
|
|
{
|
62
|
10
|
return Execute(connection, args, argTypes, argNames);
|
63
|
|
}
|
64
|
|
finally
|
65
|
|
{
|
66
|
10
|
DataSourceUtil.CloseConnection(this.DataSource, connection);
|
67
|
|
}
|
68
|
|
}
|
69
|
|
|
70
|
10
|
protected int Execute(IDbConnection connection, object[] args, Type[] argTypes,
|
71
|
|
string[] argNames)
|
72
|
|
{
|
73
|
10
|
IDbCommand cmd = this.Command(connection);
|
74
|
10
|
try
|
75
|
|
{
|
76
|
10
|
BindArgs(cmd, args, argTypes, argNames);
|
77
|
10
|
return CommandUtil.ExecuteNonQuery(this.DataSource, cmd);
|
78
|
|
}
|
79
|
|
finally
|
80
|
|
{
|
81
|
10
|
CommandUtil.Close(cmd);
|
82
|
|
}
|
83
|
|
}
|
84
|
|
|
85
|
|
#endregion
|
86
|
|
}
|
87
|
|
}
|
88
|
|
|