[Title] bug fix. db query
authorHyunjong,park <phjwithyou.park@samsung.com>
Tue, 3 Dec 2013 02:47:23 +0000 (11:47 +0900)
committerHyunjong,park <phjwithyou.park@samsung.com>
Tue, 3 Dec 2013 02:47:23 +0000 (11:47 +0900)
[Desc.] limit query
[Issue] -

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java

index e8a37c9..182801b 100755 (executable)
@@ -141,70 +141,70 @@ public class SqlManager {
                return connection;
        }
 
-//     public Connection getReplayConnection(String path) {
-//             try {
-//                     if (null != replayConnection) {
-//                             return replayConnection;
-//                     }
-//                     Class.forName("org.h2.Driver");
-//                     String dbUrl = "jdbc:h2:file:" + path + File.separator
-//                                     + AnalyzerConstants.DATABASE_NAME; //$NON-NLS-1$ //$NON-NLS-2$
-//                     replayConnection = DriverManager.getConnection(dbUrl, "SA", "");
-//                     SQLWarning warning = replayConnection.getWarnings();
-//                     while (warning != null) {
-//                             System.out.println("Message: " + warning.getMessage());
-//                             System.out.println("SQL state: " + warning.getSQLState());
-//                             System.out.println("Vendor code: " + warning.getErrorCode());
-//                             warning = warning.getNextWarning();
-//                     }
-//             } catch (ClassNotFoundException e) {
-//                     e.printStackTrace();
-//             } catch (SQLException e) {
-//                     e.printStackTrace();
-//             }
-//             return replayConnection;
-//     }
-//
-//     public Connection getConnection(String path) {
-//             try {
-//                     if (null != connection) {
-//                             return connection;
-//                     }
-//                     Class.forName("org.h2.Driver");
-//                     String dbUrl = "jdbc:h2:file:" + path + File.separator
-//                                     + AnalyzerConstants.DATABASE_NAME; //$NON-NLS-1$ //$NON-NLS-2$
-//                     connection = DriverManager.getConnection(dbUrl, "SA", "");
-//                     SQLWarning warning = connection.getWarnings();
-//                     while (warning != null) {
-//                             System.out.println("Message: " + warning.getMessage());
-//                             System.out.println("SQL state: " + warning.getSQLState());
-//                             System.out.println("Vendor code: " + warning.getErrorCode());
-//                             warning = warning.getNextWarning();
-//                     }
-//             } catch (ClassNotFoundException e) {
-//                     e.printStackTrace();
-//             } catch (SQLException e) {
-//                     e.printStackTrace();
-//             }
-//             return connection;
-//     }
+       // public Connection getReplayConnection(String path) {
+       // try {
+       // if (null != replayConnection) {
+       // return replayConnection;
+       // }
+       // Class.forName("org.h2.Driver");
+       // String dbUrl = "jdbc:h2:file:" + path + File.separator
+       //                                      + AnalyzerConstants.DATABASE_NAME; //$NON-NLS-1$ //$NON-NLS-2$
+       // replayConnection = DriverManager.getConnection(dbUrl, "SA", "");
+       // SQLWarning warning = replayConnection.getWarnings();
+       // while (warning != null) {
+       // System.out.println("Message: " + warning.getMessage());
+       // System.out.println("SQL state: " + warning.getSQLState());
+       // System.out.println("Vendor code: " + warning.getErrorCode());
+       // warning = warning.getNextWarning();
+       // }
+       // } catch (ClassNotFoundException e) {
+       // e.printStackTrace();
+       // } catch (SQLException e) {
+       // e.printStackTrace();
+       // }
+       // return replayConnection;
+       // }
+       //
+       // public Connection getConnection(String path) {
+       // try {
+       // if (null != connection) {
+       // return connection;
+       // }
+       // Class.forName("org.h2.Driver");
+       // String dbUrl = "jdbc:h2:file:" + path + File.separator
+       //                                      + AnalyzerConstants.DATABASE_NAME; //$NON-NLS-1$ //$NON-NLS-2$
+       // connection = DriverManager.getConnection(dbUrl, "SA", "");
+       // SQLWarning warning = connection.getWarnings();
+       // while (warning != null) {
+       // System.out.println("Message: " + warning.getMessage());
+       // System.out.println("SQL state: " + warning.getSQLState());
+       // System.out.println("Vendor code: " + warning.getErrorCode());
+       // warning = warning.getNextWarning();
+       // }
+       // } catch (ClassNotFoundException e) {
+       // e.printStackTrace();
+       // } catch (SQLException e) {
+       // e.printStackTrace();
+       // }
+       // return connection;
+       // }
 
        public void semaphoreAcquire() {
-               if (connection != null) {
-                       try {
-                               semaphore.acquire();
-                       } catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-               }
+//             if (connection != null) {
+//                     try {
+//                             semaphore.acquire();
+//                     } catch (InterruptedException e) {
+//                             e.printStackTrace();
+//                     }
+//             }
        }
 
        public void semaphoreRelease() {
-               if (connection == null) {
-                       return;
-               } else {
-                       semaphore.release();
-               }
+//             if (connection == null) {
+//                     return;
+//             } else {
+//                     semaphore.release();
+//             }
        }
 
        public void closeReplayConnection() {
@@ -317,6 +317,19 @@ public class SqlManager {
                return query.toString();
        }
 
+       private void executeCreateIndexTable(Statement stat, String tableName,
+                       String indeColumn) {
+               String createIndexTable = "create index " + tableName + "_index on "//$NON-NLS-1$//$NON-NLS-2$
+                               + tableName + CommonConstants.OPEN_BRACKET + indeColumn
+                               + CommonConstants.CLOSE_BRACKET;
+               try {
+                       executeUpdateCreateTable(stat, createIndexTable);
+               } catch (SQLException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+
        public String createDropTableQuery(String target) {
                StringBuffer query = new StringBuffer();
                query.append("drop table if exists "); //$NON-NLS-1$  TODO
@@ -342,6 +355,8 @@ public class SqlManager {
                                        System.out.println("table create failed..."
                                                        + info.getTableName());
                                }
+                               executeCreateIndexTable(stat, info.getTableName(),
+                                               "seqnumber, time");//$NON-NLS-1$//$NON-NLS-2$
                        }
                } catch (SQLException e) {
                        e.printStackTrace();
index a389013..4a5f848 100644 (file)
@@ -330,7 +330,7 @@ public abstract class DAWindowingTableComposite extends Composite {
                        scrollStartSelection = 0;
                }
 
-               scrollEndSelection = getTableLenght();
+               scrollEndSelection = getTableLenght()+1;
                if (getItemCount() < additionalSelectCount) {
                        scrollEndSelection = getItemCount();
                } else {
@@ -374,7 +374,7 @@ public abstract class DAWindowingTableComposite extends Composite {
 
        private List<LogData> getItemListFromDB() {
                int scrollSelection = scrollbar.getSelection();
-               int selectedEndIndex = scrollSelection + getTableLenght() + 1;
+               int selectedEndIndex = getTableLenght() + 1;
                if (getItemCount() <= selectedEndIndex) {
                        selectedEndIndex = getItemCount();
                }