public class MysqlSQLContext extends java.lang.Object implements SQLContext
Constructor and Description |
---|
MysqlSQLContext(AppContext ctx,
DatabaseService serv,
java.sql.Connection conn) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Clean up internal state
|
DateSQLExpression |
convertToDate(SQLExpression<? extends java.lang.Number> val,
long res)
Convert a Number
SQLExpression to a date. |
SQLExpression<? extends java.lang.Number> |
convertToMilliseconds(SQLExpression<java.util.Date> expr)
Convert a Date
SQLExpression to milliseconds |
SQLExpression<? extends java.lang.Number> |
dateDifference(long resolution,
SQLExpression<java.util.Date> start,
SQLExpression<java.util.Date> end)
generate a
SQLExpression for the difference between two dates. |
java.sql.Connection |
getConnection()
Get a database connection for the current context
|
java.lang.String |
getConnectionHost()
Get an identifying string for the database host we are connected to.
|
AppContext |
getContext() |
FieldTypeVisitor |
getCreateVisitor(java.lang.StringBuilder sb,
java.util.List<java.lang.Object> args)
Get a
FieldTypeVisitor used to generate table specifications. |
DatabaseService |
getService()
get the
DatabaseService |
SQLExpression<java.lang.String> |
hashFunction(Hash h,
SQLExpression<java.lang.String> arg)
Generate a SQL hash function.
|
boolean |
isReadOnly()
Is this a read-only connection
|
java.lang.StringBuilder |
quote(java.lang.StringBuilder sb,
java.lang.String name)
Quote a field or table name
|
java.lang.StringBuilder |
quoteQualified(java.lang.StringBuilder sb,
java.lang.String table,
java.lang.String name)
Quote a field or table name
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertToSeconds
public MysqlSQLContext(AppContext ctx, DatabaseService serv, java.sql.Connection conn)
public java.sql.Connection getConnection()
SQLContext
getConnection
in interface SQLContext
public java.lang.StringBuilder quote(java.lang.StringBuilder sb, java.lang.String name)
SQLContext
quote
in interface SQLContext
sb
- StringBuilderpublic java.lang.StringBuilder quoteQualified(java.lang.StringBuilder sb, java.lang.String table, java.lang.String name)
SQLContext
quoteQualified
in interface SQLContext
sb
- StringBuilderpublic SQLExpression<? extends java.lang.Number> convertToMilliseconds(SQLExpression<java.util.Date> expr)
SQLContext
SQLExpression
to millisecondsconvertToMilliseconds
in interface SQLContext
public SQLExpression<? extends java.lang.Number> dateDifference(long resolution, SQLExpression<java.util.Date> start, SQLExpression<java.util.Date> end)
SQLContext
SQLExpression
for the difference between two dates.dateDifference
in interface SQLContext
resolution
- size of time unit (in milliseconds)SQLExpression
public DateSQLExpression convertToDate(SQLExpression<? extends java.lang.Number> val, long res)
SQLContext
SQLExpression
to a date.convertToDate
in interface SQLContext
res
- resolution in millisecondsSQLExpression
public FieldTypeVisitor getCreateVisitor(java.lang.StringBuilder sb, java.util.List<java.lang.Object> args)
SQLContext
FieldTypeVisitor
used to generate table specifications.getCreateVisitor
in interface SQLContext
sb
- StringBuilder to add SQL fragments toargs
- List query parametersFieldTypeVisitor
public void close() throws java.sql.SQLException
SQLContext
close
in interface SQLContext
java.sql.SQLException
public AppContext getContext()
getContext
in interface Contexed
public SQLExpression<java.lang.String> hashFunction(Hash h, SQLExpression<java.lang.String> arg) throws CannotUseSQLException
SQLContext
hashFunction
in interface SQLContext
h
- Hash
algorithm to applyarg
- SQLExpression
to hashSQLExpression
CannotUseSQLException
public java.lang.String getConnectionHost()
SQLContext
getConnectionHost
in interface SQLContext
public DatabaseService getService()
SQLContext
DatabaseService
getService
in interface SQLContext
public boolean isReadOnly()
SQLContext
isReadOnly
in interface SQLContext