• R/O
  • SSH
  • HTTPS

webserver: Commit


Commit MetaInfo

Revision48 (tree)
Time2010-10-03 21:29:06
Authorhoritaku

Log Message

修正

Change Summary

Incremental Difference

--- branch/Basic 0.2x/import_lib/lib/xml/FileDataInvalidException.java (revision 47)
+++ branch/Basic 0.2x/import_lib/lib/xml/FileDataInvalidException.java (revision 48)
@@ -1,7 +1,7 @@
11 package lib.xml;
22
33 /**
4- * ファイル内容不正例外
4+ * 繝輔ぃ繧、繝ォ蜀?ョケ荳肴ュ」萓句、
55 *
66 */
77 public class FileDataInvalidException extends Exception {
--- branch/Basic 0.2x/import_lib/lib/DAO/ConstUtil.java (nonexistent)
+++ branch/Basic 0.2x/import_lib/lib/DAO/ConstUtil.java (revision 48)
@@ -0,0 +1,9 @@
1+package lib.DAO;
2+
3+public interface ConstUtil {
4+ final static String DB_MYSQL = "MySQL";
5+ final static String DB_ORACLE = "Oracle";
6+ final static String DBUNIT_XML_INS = "DBユニットでインサートするモード";
7+
8+ final static String[] Test01 = {DB_MYSQL, "localhost", "Cloud_Text", "root", "bsc"};
9+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/import_lib/lib/DAO/Query/TableDataQuery.java (nonexistent)
+++ branch/Basic 0.2x/import_lib/lib/DAO/Query/TableDataQuery.java (revision 48)
@@ -0,0 +1,45 @@
1+package lib.DAO.Query;
2+
3+import java.sql.ResultSet;
4+import java.sql.SQLException;
5+import java.util.*;
6+
7+/**
8+ * テーブルデータ全取得Queryクラス
9+ * @author t_horimatsu
10+ */
11+public class TableDataQuery extends CommonQuery<HashMap<String,String>>{
12+ private String[] getColumnName = null;
13+
14+ /**
15+ * コンストラクタ
16+ * @param connection
17+ */
18+ public TableDataQuery(String[] schemeAry){
19+ super(schemeAry);
20+ }
21+
22+ /**
23+ * 取得対象のテーブル名をセットする
24+ * @param getColumnName テーブル名の配列
25+ */
26+ public void setColumnName(String[] getColumnName) {
27+ this.getColumnName = getColumnName;
28+ }
29+
30+ /**
31+ * SQLにより取得した行を任意の形に成形する
32+ */
33+ @Override
34+ public HashMap<String,String> mapRow(ResultSet rs) throws SQLException {
35+ HashMap<String,String> map = new HashMap<String,String>();
36+
37+ for(int i = 0;i < getColumnName.length;i++) {
38+ String name = getColumnName[i];
39+
40+ String column = rs.getString(name);
41+ map.put(name, column);
42+ }
43+ return map;
44+ }
45+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/import_lib/lib/DAO/Query/CommonQuery.java (nonexistent)
+++ branch/Basic 0.2x/import_lib/lib/DAO/Query/CommonQuery.java (revision 48)
@@ -0,0 +1,140 @@
1+package lib.DAO.Query;
2+
3+import java.sql.Connection;
4+import java.sql.DriverManager;
5+import java.sql.PreparedStatement;
6+import java.sql.ResultSet;
7+import java.sql.SQLException;
8+import java.util.ArrayList;
9+import java.util.List;
10+
11+import lib.DAO.ConstUtil;
12+
13+public abstract class CommonQuery<R> {
14+ Connection conn = null;
15+ private String[] schemeAry = null;
16+
17+ public long selectCount = 0;
18+
19+ /** DBコネクションオブジェクト */
20+ private Connection con;
21+
22+ public CommonQuery(String[] schemeAry) {
23+ this.schemeAry = schemeAry;
24+ }
25+
26+ /**
27+ * 参照用SQL実行メソッド.
28+ * @param sql
29+ * @return
30+ * @throws SQLException
31+ */
32+ public List<R> executeQuery(String sql) throws SQLException {
33+ List<R> list;
34+ PreparedStatement stmt = null;
35+ ResultSet rs = null;
36+
37+ selectCount = 0;
38+ try {
39+ stmt = con.prepareStatement(sql);
40+
41+ rs = stmt.executeQuery();
42+
43+ list = new ArrayList<R>();
44+
45+ while(rs.next()) {
46+ selectCount++;
47+ list.add(mapRow(rs));
48+ }
49+ } finally {
50+ try {
51+ if (rs != null) {
52+ rs.close();
53+ }
54+ } finally {
55+ if (stmt != null) {
56+ stmt.close();
57+ }
58+ }
59+ }
60+
61+ return list;
62+ }
63+
64+ /**
65+ * 更新用SQL実行メソッド.
66+ * @param sql
67+ * @throws SQLException
68+ */
69+ public int executeUpdate(String sql) throws SQLException {
70+ int c = 0;
71+ PreparedStatement preparedStatement = null;
72+
73+ try {
74+ preparedStatement = con.prepareStatement(sql);
75+
76+ //更新用SQLを実行する
77+ preparedStatement.executeUpdate();
78+ c = preparedStatement.getUpdateCount();
79+
80+ } finally {
81+ if(preparedStatement!=null){
82+ //ステートメントを閉じる
83+ preparedStatement.close();
84+ }
85+ }
86+ return c;
87+ }
88+
89+ /**
90+ * コネクション取得
91+ * @throws Exception
92+ */
93+ public Connection getConnection() throws Exception{
94+ String db_type = schemeAry[0];
95+ String host = schemeAry[1];
96+ String scheme = schemeAry[2];
97+ String userID = schemeAry[3];
98+ String pass = schemeAry[4];
99+
100+ try {
101+ if(db_type == ConstUtil.DB_ORACLE) {
102+ Class.forName("oracle.jdbc.driver.OracleDriver");
103+ conn = DriverManager.getConnection("jdbc:oracle:thin:@"
104+ + host + ":1521:" + scheme, userID, pass);
105+
106+ } else if(db_type == ConstUtil.DB_MYSQL) {
107+ Class.forName("com.mysql.jdbc.Driver");
108+
109+ // MySQLの場合
110+ String url = "jdbc:mysql://" + host + ":3306/" + scheme;
111+ conn = DriverManager.getConnection(url, userID, pass);
112+ }
113+
114+ conn.setAutoCommit(false);
115+ } catch (Exception e) {
116+ e.printStackTrace();
117+ throw e;
118+ }
119+ return conn;
120+ }
121+
122+ /**
123+ * コネクション解放
124+ * @throws Exception
125+ */
126+ public void closeConnection() throws Exception {
127+ try {
128+ if(conn!=null){
129+ conn.close();
130+ }
131+ } finally {
132+ conn = null;
133+ }
134+ }
135+
136+ /**
137+ * SQLにより取得した行を任意の形に成形する
138+ */
139+ public abstract R mapRow(ResultSet rs) throws SQLException;
140+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/reflectAction/refrect_action/LoginCheck.java (nonexistent)
+++ branch/Basic 0.2x/reflectAction/refrect_action/LoginCheck.java (revision 48)
@@ -0,0 +1,22 @@
1+package refrect_action;
2+
3+import servercore.http.HttpRequest;
4+import servercore.http.HttpResponse;
5+import servercore.servelet.reflect.Action;
6+
7+public class LoginCheck extends Action{
8+
9+ public HttpResponse execute(HttpRequest request) {
10+ HttpResponse res = new HttpResponse();
11+ res.addHeader("Cache-Control", "no-cache");
12+ String uid = request.getPostParams().get("user_id");
13+ String pass = request.getPostParams().get("password");
14+ if("tak".equals(uid) && "tak".equals(pass)) {
15+ res.addHeader("Set-Cookie", "SESSIONID=cookieok");
16+ res.setStatusCore(204);
17+ } else {
18+ res.setStatusCore(403);
19+ }
20+ return res;
21+ }
22+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/reflectAction/refrect_action/ContentsList.java (nonexistent)
+++ branch/Basic 0.2x/reflectAction/refrect_action/ContentsList.java (revision 48)
@@ -0,0 +1,21 @@
1+package refrect_action;
2+
3+import servercore.http.HttpRequest;
4+import servercore.http.HttpResponse;
5+import servercore.servelet.reflect.Action;
6+
7+import models.ContentsBiz;
8+
9+public class ContentsList extends Action{
10+
11+ public HttpResponse execute(HttpRequest request) {
12+ HttpResponse res = new HttpResponse();
13+ String type = request.getGetParams().get("type");
14+ res.addHeader("Cache-Control", "no-cache");
15+ ContentsBiz biz = new ContentsBiz();
16+ if("getall".equals(type)) {
17+
18+ }
19+ return res;
20+ }
21+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/models/models/ContentsBiz.java (nonexistent)
+++ branch/Basic 0.2x/models/models/ContentsBiz.java (revision 48)
@@ -0,0 +1,10 @@
1+package models;
2+
3+import java.util.HashMap;
4+
5+public class ContentsBiz {
6+ public HashMap<String, String> getTitle() {
7+ return null;
8+ }
9+
10+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Show on old repository browser