com.bolinfest.prisonerbot.logging
Class JdbcLogger

java.lang.Object
  extended by com.bolinfest.prisonerbot.logging.AbstractLogger
      extended by com.bolinfest.prisonerbot.logging.JdbcLogger
All Implemented Interfaces:
GameLogger

public class JdbcLogger
extends AbstractLogger

JdbcLogger is...

Author:
mbolin

Field Summary
protected static String INSERT_GAME
           
protected static String INSERT_MATRIX
           
protected static String INSERT_PLAYER
           
protected static String INSERT_ROUND
           
protected static String LAST_GAME_ID
           
protected static String LAST_MATRIX_ID
           
protected static String LAST_PLAYER_ID
           
protected  String password
           
protected static String SELECT_MATRIX
           
protected static String SELECT_PLAYER
           
protected  String url
           
protected  String userName
           
 
Constructor Summary
JdbcLogger(String url, String userName, String password)
           
 
Method Summary
protected  int addMatrix(Connection cn, PayoffMatrix matrix)
           
protected  int addPlayer(Connection cn, String name)
           
protected  int getChoiceId(Choice c)
           
protected  int getMatrixId(Connection cn, PayoffMatrix matrix)
           
protected  int getPlayerId(Connection cn, String name)
           
protected  int hasMatrix(Connection cn, PayoffMatrix matrix)
           
protected  int hasPlayer(Connection cn, String name)
           
protected  int insertGameTable(Connection cn, int p1id, int p2id, int matrixId, int p1rounds, int p2rounds)
           
protected  void insertRounds(Connection cn, int gameId, Iterator iterations)
           
 void log(String s)
           
protected  void logGame(Connection cn, UnmodifiableGame game)
           
 void logGame(UnmodifiableGame game)
           
 
Methods inherited from class com.bolinfest.prisonerbot.logging.AbstractLogger
normalizeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

protected final String url

userName

protected final String userName

password

protected final String password

SELECT_PLAYER

protected static final String SELECT_PLAYER
See Also:
Constant Field Values

INSERT_PLAYER

protected static final String INSERT_PLAYER
See Also:
Constant Field Values

LAST_PLAYER_ID

protected static final String LAST_PLAYER_ID
See Also:
Constant Field Values

SELECT_MATRIX

protected static final String SELECT_MATRIX
See Also:
Constant Field Values

INSERT_MATRIX

protected static final String INSERT_MATRIX
See Also:
Constant Field Values

LAST_MATRIX_ID

protected static final String LAST_MATRIX_ID
See Also:
Constant Field Values

INSERT_GAME

protected static final String INSERT_GAME
See Also:
Constant Field Values

LAST_GAME_ID

protected static final String LAST_GAME_ID
See Also:
Constant Field Values

INSERT_ROUND

protected static final String INSERT_ROUND
See Also:
Constant Field Values
Constructor Detail

JdbcLogger

public JdbcLogger(String url,
                  String userName,
                  String password)
           throws Exception
Throws:
Exception
Method Detail

log

public void log(String s)
Specified by:
log in interface GameLogger
Specified by:
log in class AbstractLogger

logGame

public void logGame(UnmodifiableGame game)
Specified by:
logGame in interface GameLogger
Specified by:
logGame in class AbstractLogger

logGame

protected void logGame(Connection cn,
                       UnmodifiableGame game)
                throws SQLException
Throws:
SQLException

getPlayerId

protected int getPlayerId(Connection cn,
                          String name)
                   throws SQLException
Throws:
SQLException

hasPlayer

protected int hasPlayer(Connection cn,
                        String name)
                 throws SQLException
Throws:
SQLException

addPlayer

protected int addPlayer(Connection cn,
                        String name)
                 throws SQLException
Throws:
SQLException

getMatrixId

protected int getMatrixId(Connection cn,
                          PayoffMatrix matrix)
                   throws SQLException
Throws:
SQLException

hasMatrix

protected int hasMatrix(Connection cn,
                        PayoffMatrix matrix)
                 throws SQLException
Throws:
SQLException

addMatrix

protected int addMatrix(Connection cn,
                        PayoffMatrix matrix)
                 throws SQLException
Throws:
SQLException

insertGameTable

protected int insertGameTable(Connection cn,
                              int p1id,
                              int p2id,
                              int matrixId,
                              int p1rounds,
                              int p2rounds)
                       throws SQLException
Throws:
SQLException

insertRounds

protected void insertRounds(Connection cn,
                            int gameId,
                            Iterator iterations)
                     throws SQLException
Throws:
SQLException

getChoiceId

protected int getChoiceId(Choice c)