public class MySQLDatabase extends Database
Database d=new MySQLDatabase("user","password","database");
d.queryColumn("SELECT foodname FROM food WHERE origin=\"Italy\"")
-> [ "Pizza Romana", "Spaghetti alla Bolognese", "Saltimbocca"]
Database.describe(d.query("SELECT * FROM food WHERE origin=\"Italy\"")
-> foodname |origin |calories |
------------------------------
Pizza Rom|Italy |10000 |
Spaghetti|Italy |8000 |
Saltimboc|Italy |8000 |
| Modifier and Type | Class and Description |
|---|---|
static class |
MySQLDatabase.ANSIvarcharBin
a VARCHAR BINARY type, making sure we are case-sensitive in varchar fields
(currently we assume case-sensitive collation is used by default,
however, the method 'enforceCaseSensitivity' can replace the normal VARCHAR
representation by this one, so if the database collation is not case-sensitive
case-sensitive applications can use this sqltype on demand)
|
static class |
MySQLDatabase.Blob
BLOB/TEXT type for MySQL
|
static class |
MySQLDatabase.MysqlVarchar
VARCHAR type for MySQL
|
Database.CommitTransactionSQLException, Database.ConnectionBrokenSQLException, Database.InitTransactionSQLException, Database.Inserter, Database.RollbackTransactionSQLException, Database.StartAutoCommitSQLException, Database.TransactionSQLException| Modifier and Type | Field and Description |
|---|---|
static MySQLDatabase.ANSIvarcharBin |
ansivarcharbin |
static MySQLDatabase.Blob |
blob |
static MySQLDatabase.MysqlVarchar |
mysqlvarchar |
connection, description, driver, fetchsize, inserters, java2SQL, MINCOLUMNWIDTH, resultSetConcurrency, resultSetType, SCREENWIDTH, type2SQL| Constructor and Description |
|---|
MySQLDatabase() |
MySQLDatabase(String user,
String password,
String database,
String host,
String port)
Constructs a new MySQLDatabase from a user and a password,
all other arguments may be null
|
| Modifier and Type | Method and Description |
|---|---|
String |
autoincrementColumn()
Produces an SQL fragment representing column properties for an autoincrementing integer column
s.t.
|
String |
cast(String value,
String type)
Produces an SQL fragment casting the given value to the given type *
|
void |
connect()
connects to the database specified
|
void |
enforceCaseSensitivity(boolean enable)
allows to make sure VARCHAR column field based queries are case-sensitive
even when the underlying table has a case-insensitive collation
|
String |
getSQLStmntIFNULL(String a,
String b)
returns the database system specific expression for ifnull functionality
i.e.
|
boolean |
jarAvailable()
TRUE if the required JAR is there
|
void |
lockTableReadAccess(Map<String,String> tablesAndAliases)
Locks a table in read mode, i.e.
|
void |
lockTableWriteAccess(Map<String,String> tablesAndAliases)
Locks a table in write mode, i.e.
|
static void |
main(String[] args) |
void |
releaseLocksAndEndTransaction()
releases all locks the connection holds, commits the current transaction and ends it
switches back to autocommit mode
|
appendFixedLen, attemptReconnect, close, close, close, close, commitTransaction, connected, createIndex, createIndexCommand, createIndices, createPrimaryKey, createTable, createView, describe, describe, dumpCSV, dumpQueryAsCSV, endTransaction, endTransaction, executeQuery, executeUpdate, executeUpdateQuery, exists, existsTable, finalize, flush, format, formatNullToNull, getConnection, getFetchsize, getResultSetConcurrency, getResultSetType, getSQLType, getSQLType, getSQLType, getValidityCheckTimeout, indexName, isAutoReconnectingOnSelect, isAutoReconnectingOnUpdate, limit, loadCSV, makeCSV, makeCSVForQuery, newInserter, newInserter, newInserter, offset, prepareQuery, query, query, query, query, queryValue, reconnect, resetTransaction, runInterface, setAutoReconnectOnSelect, setAutoReconnectOnUpdate, setFetchsize, setResultSetConcurrency, setResultSetType, setValidityCheckTimeout, startTransaction, toStringpublic static MySQLDatabase.MysqlVarchar mysqlvarchar
public static MySQLDatabase.Blob blob
public static MySQLDatabase.ANSIvarcharBin ansivarcharbin
public MySQLDatabase(String user, String password, String database, String host, String port) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
public MySQLDatabase()
public void enforceCaseSensitivity(boolean enable)
public void connect()
throws SQLException
connect in class DatabaseSQLExceptionpublic boolean jarAvailable()
DatabasejarAvailable in class Databasepublic void lockTableWriteAccess(Map<String,String> tablesAndAliases) throws SQLException
lockTableWriteAccess in class DatabaseSQLExceptionpublic void lockTableReadAccess(Map<String,String> tablesAndAliases) throws SQLException
lockTableReadAccess in class DatabaseSQLExceptionpublic void releaseLocksAndEndTransaction()
throws SQLException
releaseLocksAndEndTransaction in class DatabaseSQLExceptionpublic String getSQLStmntIFNULL(String a, String b)
getSQLStmntIFNULL in class Databasepublic String cast(String value, String type)
public String autoincrementColumn()
autoincrementColumn in class DatabaseCopyright © 2018. All rights reserved.