islandev
Class IslandsJDBC

java.lang.Object
  |
  +--islandev.IslandsJDBC

public class IslandsJDBC
extends java.lang.Object

This class allows the interaction between the Islands Server and a MySQL database. Data about different clients is logged into the database as well as novel solutions and new runs.

This class should be made more genertic implementing an interface so that other storage solutions could be used, not only MySQL.


Field Summary
protected  int infinity
           
protected  java.sql.Statement stmt
           
 
Constructor Summary
IslandsJDBC()
          Creates new JDBC
 
Method Summary
 void clearGrid()
           
 java.lang.String filterString(java.lang.String str)
           
 void foundSolution(java.lang.String name)
           
 int getClientID(java.lang.String name)
           
 void newPacket(java.lang.String name, int evalsDiff, int fitImprv, int runID, Individual bestInd, java.awt.Point pos)
           
 void registerBestIndividual(Individual ind, int runID, java.lang.String userName, int generation)
          Register an individual in database, links it to its run
 void registerFirstBestIndividual(Individual ind, int runID, java.lang.String userName, int generation)
          Register the first best this server has seen, if something already in database then assume this run is being resumed and the best in database is up to date.
 int registerRun(java.lang.String name, java.lang.String short_descr, java.lang.String descr, java.lang.String serverName, int bestHDIndID, int effort)
          Register run in MySQL database, return the id of this run
 int registerTeam(java.lang.String teamName)
           
 boolean registerUser(java.lang.String name, java.lang.String ip, java.lang.String email, java.lang.String teamName, java.awt.Point pos, int runID)
          Register user in MySQL database, returns false if user was already there.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stmt

protected java.sql.Statement stmt

infinity

protected final int infinity
Constructor Detail

IslandsJDBC

public IslandsJDBC()
            throws java.sql.SQLException,
                   java.lang.ClassNotFoundException
Creates new JDBC
Method Detail

clearGrid

public void clearGrid()
               throws java.sql.SQLException

getClientID

public int getClientID(java.lang.String name)
                throws java.sql.SQLException

registerRun

public int registerRun(java.lang.String name,
                       java.lang.String short_descr,
                       java.lang.String descr,
                       java.lang.String serverName,
                       int bestHDIndID,
                       int effort)
                throws java.sql.SQLException
Register run in MySQL database, return the id of this run

registerFirstBestIndividual

public void registerFirstBestIndividual(Individual ind,
                                        int runID,
                                        java.lang.String userName,
                                        int generation)
                                 throws java.sql.SQLException
Register the first best this server has seen, if something already in database then assume this run is being resumed and the best in database is up to date.

registerBestIndividual

public void registerBestIndividual(Individual ind,
                                   int runID,
                                   java.lang.String userName,
                                   int generation)
                            throws java.sql.SQLException
Register an individual in database, links it to its run

registerUser

public boolean registerUser(java.lang.String name,
                            java.lang.String ip,
                            java.lang.String email,
                            java.lang.String teamName,
                            java.awt.Point pos,
                            int runID)
                     throws java.sql.SQLException
Register user in MySQL database, returns false if user was already there.

registerTeam

public int registerTeam(java.lang.String teamName)
                 throws java.sql.SQLException

newPacket

public void newPacket(java.lang.String name,
                      int evalsDiff,
                      int fitImprv,
                      int runID,
                      Individual bestInd,
                      java.awt.Point pos)
               throws java.sql.SQLException

foundSolution

public void foundSolution(java.lang.String name)
                   throws java.sql.SQLException

filterString

public java.lang.String filterString(java.lang.String str)