Ejemplo n.º 1
0
 private void createTables() {
   Connection connection = null;
   Statement statement = null;
   try {
     connection = getConnection();
     statement = connection.createStatement();
     statement.execute("drop table if exists agent");
     statement.execute(
         "create table agent (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, username varchar(20), "
             + "emailaddress varchar(132), name varchar(132), city varchar(50), state char(2), "
             + "zipcode varchar(9),  latitude DECIMAL(18,12), longitude DECIMAL(18,12), level smallint, "
             + "profileid char(21), imageurl varchar(132), role smallint, vetted char(1)) ");
     statement.execute("create unique index agent1 on agent (emailaddress)");
     statement.execute("create unique index agent2 on agent (profileid)");
     statement.execute("drop table if exists googleapiclient");
     statement.execute("create table googleapiclient (id varchar(132), secret varchar(50))");
     statement.execute("drop table if exists geocache");
     statement.execute(
         "create table geocache "
             + "(query varchar(132) primary key, latitude DECIMAL(18,12), longitude DECIMAL(18,12), "
             + "formatted_address varchar(256) ,city varchar(50), state char(2), zipcode char(9) )");
     statement.execute("drop table if exists comment");
     statement.execute(
         "create table comment (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, commenttype smallint, commenttext varchar(256), emailaddress varchar(132), logtime timestamp)");
     statement.execute("create index comment1 on comment (emailaddress)");
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     close(statement, connection);
   }
   GoogleApiClientDAO googleApiClientDAO = new GoogleApiClientDAO();
   GoogleApiClient googleApiClient = new GoogleApiClient();
   googleApiClient.setId(properties.getProperty("googleapiclientid"));
   googleApiClient.setSecret(properties.getProperty("googleapisecret"));
   googleApiClientDAO.insert(googleApiClient);
 }