Package fj.control.db
Class DbState
- java.lang.Object
-
- fj.control.db.DbState
-
public final class DbState extends java.lang.Object
Performs database I/O, in order to read or write the database state.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Connector
driverManager(java.lang.String url)
A simple connector (the default) that gets connections to the given database URL from the driver manager.static DbState
reader(Connector pc)
Returns a new reader that reads the database via the given Connector.static DbState
reader(java.lang.String url)
Creates a database state reader given a connection URL.<A> A
run(DB<A> dba)
Runs the given database action as a single transaction.static DbState
writer(Connector pc)
Returns a new writer that writes the database via the given Connector.static DbState
writer(java.lang.String url)
Creates a database state writer given a connection URL.
-
-
-
Method Detail
-
driverManager
public static Connector driverManager(java.lang.String url)
A simple connector (the default) that gets connections to the given database URL from the driver manager.- Parameters:
url
- The database URL to connect to.- Returns:
- A connector that generates connections to the given database.
-
reader
public static DbState reader(java.lang.String url)
Creates a database state reader given a connection URL.- Parameters:
url
- The connection URL to the database.- Returns:
- A database state reader that reads the given database.
-
writer
public static DbState writer(java.lang.String url)
Creates a database state writer given a connection URL.- Parameters:
url
- The connection URL to the database.- Returns:
- A database state writer that writes the given database.
-
reader
public static DbState reader(Connector pc)
Returns a new reader that reads the database via the given Connector.- Parameters:
pc
- A connector with which to generate database connections.- Returns:
- A new reader that reads the database via the given Connector.
-
writer
public static DbState writer(Connector pc)
Returns a new writer that writes the database via the given Connector.- Parameters:
pc
- A connector with which to generate database connections.- Returns:
- A new writer that writes the database via the given Connector.
-
run
public <A> A run(DB<A> dba) throws java.sql.SQLException
Runs the given database action as a single transaction.- Parameters:
dba
- A database action to run.- Returns:
- The result of running the action against the database.
- Throws:
java.sql.SQLException
- in case of a database error.
-
-