public class HarDatabaseConfig
extends java.lang.Object
| Constructor and Description |
|---|
HarDatabaseConfig(java.lang.String driverClassName,
java.lang.String jdbcUrl,
java.lang.String login,
java.lang.String password,
java.lang.String tablePrefix,
java.lang.String dbAutoGeneratedId,
java.lang.String stringDbType,
java.lang.String longDbType,
java.lang.String timestampDbType,
java.lang.String smallIntDbType)
Creates a new
HarDatabaseConfig object to store/retrieve HAR
representations in/from a database. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCreatedTable(java.lang.String tableName)
Add a table to the list of tables that have been created
|
void |
closeConnection(java.sql.Connection c)
Close the given connection (actually put it back as is in the connection
pool)
|
void |
deleteFromTable(long logId,
HarDatabaseConfig config,
java.lang.String tableName)
Delete objects in the given database table referencing the specified logId.
|
void |
dropTableIfEmpty(java.sql.Connection c,
java.lang.String tableName,
HarDatabaseConfig config)
Check if a table is empty with a COUNT(*) and drop it if it is.
|
java.sql.Connection |
getConnection()
Retrieve a database connection using the current configuration.
|
java.lang.String |
getDbAutoGeneratedId()
Returns the dbAutoGeneratedId value.
|
java.lang.String |
getDriverClassName()
Returns the driverClassName value.
|
java.util.List<java.lang.Long> |
getHarLogIds()
Return the list of HarLog ids stored in the database.
|
java.lang.String |
getJdbcUrl()
Returns the jdbcUrl value.
|
java.lang.String |
getLogin()
Returns the login value.
|
java.lang.String |
getLongDbType()
Returns the longDbType value.
|
long |
getNbOfEntries(java.lang.String tableName)
Return the number of entries stored in the database table
|
java.lang.String |
getPassword()
Returns the password value.
|
java.lang.String |
getSmallIntDbType()
Returns the smallIntDbType value.
|
java.lang.String |
getStringDbType()
Returns the stringDbType value.
|
java.lang.String |
getTablePrefix()
Returns the tablePrefix value.
|
java.lang.String |
getTimestampDbType()
Returns the timestampDbType value.
|
boolean |
isCreatedTable(java.lang.String tableName)
Returns true if the given table name is in the list of created tables
|
void |
removeTable(java.lang.String tableName)
Remove a table to the list of tables that have been created (cache
invalidation)
|
void |
setDbAutoGeneratedId(java.lang.String dbAutoGeneratedId)
Sets the dbAutoGeneratedId value.
|
void |
setDriverClassName(java.lang.String driverClassName)
Sets the driverClassName value.
|
void |
setJdbcUrl(java.lang.String jdbcUrl)
Sets the jdbcUrl value.
|
void |
setLogin(java.lang.String login)
Sets the login value.
|
void |
setLongDbType(java.lang.String longDbType)
Sets the longDbType value.
|
void |
setPassword(java.lang.String password)
Sets the password value.
|
void |
setSmallIntDbType(java.lang.String smallIntDbType)
Sets the smallIntDbType value.
|
void |
setStringDbType(java.lang.String stringDbType)
Sets the stringDbType value.
|
void |
setTablePrefix(java.lang.String tablePrefix)
Sets the tablePrefix value.
|
void |
setTimestampDbType(java.lang.String timestampDbType)
Sets the timestampDbType value.
|
long |
writeNameValueCommentJDBC(long logId,
HarDatabaseConfig config,
java.lang.String tableName,
java.lang.String nameColumn,
java.lang.String nameValue,
java.lang.String valueColumn,
java.lang.String valueValue,
java.lang.String commentColumn,
java.lang.String commentValue)
Write this object in the given database referencing the specified logId.
|
public HarDatabaseConfig(java.lang.String driverClassName,
java.lang.String jdbcUrl,
java.lang.String login,
java.lang.String password,
java.lang.String tablePrefix,
java.lang.String dbAutoGeneratedId,
java.lang.String stringDbType,
java.lang.String longDbType,
java.lang.String timestampDbType,
java.lang.String smallIntDbType)
throws java.sql.SQLException
HarDatabaseConfig object to store/retrieve HAR
representations in/from a database.driverClassName - Class name of the database driverjdbcUrl - the JDBC URL to access the databsaelogin - database user loginpassword - database user passwordtablePrefix - prefix to use in front of table namesdbAutoGeneratedId - database type to define an auto-generated key (if
null, "BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY" is
used)stringDbType - database type to define a string type (if null,
"LONG VARCHAR" is used)longDbType - database type to define a long type (if null, "BIGINT" is
used)timestampDbType - type to define a timestamp type (if null,
"TIMESTAMP" is used)smallIntDbType - type to defined a small int type (if null, "SMALLINT"
is used)java.sql.SQLException - if the database driver cannot be loadedpublic java.util.List<java.lang.Long> getHarLogIds()
throws java.sql.SQLException
HarLog.HarLog(HarDatabaseConfig, long) to fetch HarLog entries.java.sql.SQLException - if a db error occurspublic long getNbOfEntries(java.lang.String tableName)
throws java.sql.SQLException
tableName - name of the table to COUNT(*)java.sql.SQLException - if a db error occurspublic java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLException - if an error occured creating the databasepublic void closeConnection(java.sql.Connection c)
c - connection to closepublic long writeNameValueCommentJDBC(long logId,
HarDatabaseConfig config,
java.lang.String tableName,
java.lang.String nameColumn,
java.lang.String nameValue,
java.lang.String valueColumn,
java.lang.String valueValue,
java.lang.String commentColumn,
java.lang.String commentValue)
throws java.sql.SQLException
logId - the logId this object refers toconfig - the database configurationtableName - name of the table to insert data into (without the table
prefix)nameColumn - name of the name columnnameValue - value of the name fieldvalueColumn - name of the value columnvalueValue - value of the value fieldcommentColumn - name of the comment columncommentValue - value of the comment fieldjava.sql.SQLException - if a database access error occurs *public void dropTableIfEmpty(java.sql.Connection c,
java.lang.String tableName,
HarDatabaseConfig config)
throws java.sql.SQLException
c - an open connection to the databasetableName - the name of the table to checkconfig - database config to be updated if the table is dropped (cache
update)java.sql.SQLException - if an error occurspublic void deleteFromTable(long logId,
HarDatabaseConfig config,
java.lang.String tableName)
throws java.sql.SQLException
logId - the logId this object refers toconfig - the database configurationtableName - name of the table to insert data into (without the table
prefix)java.sql.SQLException - if a database access error occurs *public void addCreatedTable(java.lang.String tableName)
tableName - the table that has been created (or already exists)public boolean isCreatedTable(java.lang.String tableName)
tableName - the table to look forpublic void removeTable(java.lang.String tableName)
tableName - the table that has been removedpublic java.lang.String getDriverClassName()
public void setDriverClassName(java.lang.String driverClassName)
driverClassName - The driverClassName to set.public java.lang.String getJdbcUrl()
public void setJdbcUrl(java.lang.String jdbcUrl)
jdbcUrl - The jdbcUrl to set.public java.lang.String getLogin()
public void setLogin(java.lang.String login)
login - The login to set.public java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - The password to set.public java.lang.String getTablePrefix()
public void setTablePrefix(java.lang.String tablePrefix)
tablePrefix - The tablePrefix to set.public java.lang.String getDbAutoGeneratedId()
public void setDbAutoGeneratedId(java.lang.String dbAutoGeneratedId)
dbAutoGeneratedId - The dbAutoGeneratedId to set.public java.lang.String getStringDbType()
public void setStringDbType(java.lang.String stringDbType)
stringDbType - The stringDbType to set.public java.lang.String getSmallIntDbType()
public void setSmallIntDbType(java.lang.String smallIntDbType)
smallIntDbType - The smallIntDbType to set.public java.lang.String getLongDbType()
public void setLongDbType(java.lang.String longDbType)
longDbType - The longDbType to set.public java.lang.String getTimestampDbType()
public void setTimestampDbType(java.lang.String timestampDbType)
timestampDbType - The timestampDbType to set.Copyright © 2011 Emmanuel Cecchet - University of Massachusetts - All Rights Reserved.