1 package net.sf.jasperreports.mysql; 2 3 import java.sql.SQLException ; 4 import java.sql.Statement ; 5 6 10 public class Destination extends Database 11 { 12 13 17 public void createTables() 18 { 19 createShowStatus(); 21 createProcessList(); 22 createTableStatus(); 23 24 } 25 26 38 39 private void createShowStatus(){ 40 try{ 42 Statement create = getConnection().createStatement(); 44 create.executeUpdate("CREATE TABLE IF NOT EXISTS status(" + 45 "source VARCHAR(255)," + 46 "report_time TIMESTAMP(12)," + 47 "bytes_received BIGINT," + 48 "bytes_sent BIGINT," + 49 "total_selects BIGINT," + 50 "total_insert BIGINT," + 51 "connections BIGINT," + 52 "uptime BIGINT" + 53 ");" 54 ); 55 }catch(SQLException e){ 56 e.printStackTrace(); 57 System.out.println("Exception: " + e.getMessage()); 58 System.exit(1); 59 } 60 System.out.print("created table: status.\n"); 61 } 62 63 64 75 76 private void createProcessList(){ 77 try{ 79 Statement create = getConnection().createStatement(); 81 create.executeUpdate("CREATE TABLE IF NOT EXISTS process_list(" + 82 "source VARCHAR(255)," + 83 "report_time TIMESTAMP(12)," + 84 "user VARCHAR(255)," + 85 "host VARCHAR(255)," + 86 "database_name VARCHAR(255)," + 87 "time BIGINT" + 88 ");" 89 ); 90 }catch(SQLException e){ 91 e.printStackTrace(); 92 System.out.println("Exception: " + e.getMessage()); 93 System.exit(1); 94 } 95 System.out.print("created table: process_list.\n"); 96 } 97 98 113 114 private void createTableStatus(){ 115 try{ 117 Statement create = getConnection().createStatement(); 119 create.executeUpdate("CREATE TABLE IF NOT EXISTS table_status(" + 120 "source VARCHAR(255)," + 121 "database_name VARCHAR(255)," + 122 "report_time TIMESTAMP(12)," + 123 "name VARCHAR(255)," + 124 "create_time DATETIME," + 125 "rows BIGINT," + 126 "average_row_length BIGINT," + 127 "data_length BIGINT," + 128 "index_length BIGINT," + 129 "update_time DATETIME," + 130 "check_time DATETIME" + 131 ");" 132 ); 133 }catch(SQLException e){ 134 e.printStackTrace(); 135 System.err.println("Exception: " + e.getMessage()); 136 System.exit(1); 137 } 138 System.out.print("created table: table_status.\n"); 139 } 140 } 141 | Popular Tags |