package io.khasang.wlogs.model;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;

public class InsertDataTable {
        public static String sqlCheck;

        public void sqlInsert() {
            SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
            dataSource.setDriverClass(com.mysql.jdbc.Driver.class);
            dataSource.setUsername("root");
            dataSource.setUrl("jdbc:mysql://localhost/wlogs");
            dataSource.setPassword("root");
            JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
            System.out.println("try to update db...");
            try {
                System.out.println("Creating tables");
               /* jdbcTemplate.execute("DROP TABLE IF EXISTS loginfo");
                jdbcTemplate.execute("create table wlogs(ID INT NOT NULL,"
                + " minute INT NOT NULL, errorLvL MEDIUMTEXT NOT NULL)");*/
                jdbcTemplate.update("INSERT INTO loginfo(ID, errorinfo, descr) VALUES(6, 'error', 'red')");
                jdbcTemplate.update("INSERT INTO loginfo(ID, errorinfo, descr) VALUES(7, 'warn', 'yellow')");
                jdbcTemplate.update("INSERT INTO loginfo(ID, errorinfo, descr) VALUES(8, 'ok', 'green')");
                sqlCheck = "db updated";
            } catch (Exception e) {
                sqlCheck = "Have error: " + e;
                System.err.println(sqlCheck);
            }
        }

        public String sqlInsertCheck() {
            InsertDataTable sql = new InsertDataTable();
            sql.sqlInsert();
            return sqlCheck;
        }
}
@@ -176,24 +176,57 @@
 Table %7B%0A    
+private static String sqlCheck;%0A%0A
     public s
@@ -238,31 +238,142 @@
  String 
-s
+getS
 qlCheck
-;%0A%0A    
+() %7B%0A        InsertDataTable sql = new InsertDataTable();%0A        sql.sqlInsert();%0A        return sqlCheck;%0A    %7D%0A%0A
     publ
@@ -402,20 +402,16 @@
         
-   
- 
 SimpleDr
@@ -468,36 +468,32 @@
 urce();%0A        
-    
 dataSource.setDr
@@ -532,36 +532,32 @@
 class);%0A        
-   
- 
 dataSource.setUs
@@ -564,36 +564,32 @@
 ername(%22root%22);%0A
-    
         dataSour
@@ -635,28 +635,24 @@
 %22);%0A        
-  
-  
 dataSource.s
@@ -667,28 +667,24 @@
 rd(%22root%22);%0A
-    
         Jdbc
@@ -737,36 +737,32 @@
 ource);%0A        
-  
-  
 System.out.print
@@ -796,20 +796,16 @@
         
-    
 try %7B%0A  
@@ -810,28 +810,24 @@
             
- 
-   
 System.out.p
@@ -1080,36 +1080,32 @@
 ;*/%0A            
-    
 jdbcTemplate.upd
@@ -1176,28 +1176,24 @@
 , 'red')%22);%0A
-    
             
@@ -1282,28 +1282,24 @@
 yellow')%22);%0A
-    
             
@@ -1393,36 +1393,32 @@
 %22);%0A            
-    
 sqlCheck = %22db u
@@ -1426,20 +1426,16 @@
 dated%22;%0A
-    
         
@@ -1462,36 +1462,32 @@
 ) %7B%0A            
-    
 sqlCheck = %22Have
@@ -1509,28 +1509,24 @@
             
-   
- 
 System.err.p
@@ -1555,29 +1555,17 @@
     
-    %7D%0A   
+%7D%0A
     
- 
 %7D%0A%0A
-    
     
@@ -1601,28 +1601,24 @@
 ) %7B%0A        
-  
-  
 InsertDataTa
@@ -1654,28 +1654,24 @@
 ();%0A        
-    
 sql.sqlInser
@@ -1679,28 +1679,24 @@
 ();%0A        
- 
-   
 return sqlCh
@@ -1700,19 +1700,15 @@
 lCheck;%0A
-    
     %7D%0A%7D

add getString