[Jiemamy-notify:2828] commit [3750] refactor

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 11月 20日 (金) 17:20:10 JST


Revision: 3750
          http://sourceforge.jp/projects/jiemamy/svn/view?view=rev&revision=3750
Author:   daisuke_m
Date:     2009-11-20 17:20:10 +0900 (Fri, 20 Nov 2009)

Log Message:
-----------
refactor

Modified Paths:
--------------
    metis/jiemamy-tutorial/trunk/src/main/java/org/jiemamy/tutorial/JiemamyServlet.java

Modified: metis/jiemamy-tutorial/trunk/src/main/java/org/jiemamy/tutorial/JiemamyServlet.java
===================================================================
--- metis/jiemamy-tutorial/trunk/src/main/java/org/jiemamy/tutorial/JiemamyServlet.java	2009-11-20 08:09:53 UTC (rev 3749)
+++ metis/jiemamy-tutorial/trunk/src/main/java/org/jiemamy/tutorial/JiemamyServlet.java	2009-11-20 08:20:10 UTC (rev 3750)
@@ -28,6 +28,14 @@
 	
 	private static final String URI = "jdbc:postgresql://localhost:5432/jiemamy";
 
+	private static final String TABLE = "T_ITEM";
+
+	private static final String COLUMN_ID = "ID";
+
+	private static final String COLUMN_ITEM_NAME = "ITEM_NAME";
+
+	private static final String COLUMN_PRICE = "PRICE";
+
 	
 	@Override
 	public void doGet(HttpServletRequest request, HttpServletResponse response)
@@ -66,12 +74,12 @@
 			db = DriverManager.getConnection(URI, USERNAME, PASSWORD);
 			st = db.createStatement();
 			
-			rs = st.executeQuery("SELECT * FROM T_ITEM");
+			rs = st.executeQuery("SELECT * FROM " + TABLE);
 			if (rs != null) {
 				while (rs.next()) {
-					int id = rs.getInt("ID");
-					String item = rs.getString("ITEM_NAME");
-					int price = rs.getInt("PRICE");
+					int id = rs.getInt(COLUMN_ID);
+					String item = rs.getString(COLUMN_ITEM_NAME);
+					int price = rs.getInt(COLUMN_PRICE);
 					
 					sb.append("<tr><th>");
 					sb.append(id);




Jiemamy-notify メーリングリストの案内
アーカイブの一覧に戻る