class DBManager extends DBManagerDDL with JsonFormatted
- Alphabetic
- By Inheritance
- DBManager
- JsonFormatted
- DBManagerDDL
- DBManagerDML
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new DBManager(table: Table)(implicit dbConfig: TraitDBConfig = DefaultDBConfigFromFile)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addForeignKey(link: Link): Int
- Definition Classes
- DBManagerDDL
- def aggregateBigDecimal(aggregates: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- def aggregateDouble(select: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- def aggregateGroupBigDecimal(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
- def aggregateGroupBigInt(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
- def aggregateGroupDouble(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
-
def
aggregateGroupHaving[T](aggregates: Aggregates, wheres: Wheres, groupByIntervals: GroupByIntervals, havings: Havings, func: (ResultSet, String) ⇒ T)(implicit func2: (String) ⇒ T = ???, optConn: OptConn = None): List[Array[Any]]
- Attributes
- protected[sh.db]
- Definition Classes
- DBManagerDML
- def aggregateGroupInt(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
-
def
aggregateGroupInto(db: DBManager, aggregates: Aggregates, wheres: Wheres, groupByIntervals: GroupByIntervals, havings: Havings)(implicit optConn: OptConn = None): Int
- Definition Classes
- DBManagerDML
- def aggregateGroupLong(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
- def aggregateGroupString(aggregates: Aggregates, wheres: Wheres, groups: GroupByIntervals = Array(), havings: Havings = Array()): List[Array[Any]]
- def aggregateInt(select: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- def aggregateLong(aggregates: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- def aggregateString(select: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
connection: Connection
- Definition Classes
- DBManager → DBManagerDML
- def countAllRows: Long
- def countRows(where: Where): Long
-
def
countRows(wheres: Wheres)(implicit optConn: OptConn = None): Long
counts all rows in the table matching the select criteria given by wheres
counts all rows in the table matching the select criteria given by wheres
- wheres
is an Array of Where (the criteria (Col, Op, Value)) for the cols to search in.
- Definition Classes
- DBManagerDML
- lazy val createString: String
- implicit val dbConfig: TraitDBConfig
- implicit val dbDML: DBManagerDML
-
def
delete(wheres: Wheres)(implicit optConn: OptConn = None): Int
Deletes rows matching the searchCol criteria.
Deletes rows matching the searchCol criteria.
- returns
the number of rows deleted
- Definition Classes
- DBManagerDML
- def deleteAll: Int
- def dropTable: Int
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def exists(wheres: Where*): Boolean
- def exists(wheres: Wheres): Boolean
- def exportAllEncrypted(file: String, secretKey: String): Int
- def exportAllToCSV(file: String): Int
- def exportEncrypted(file: String, secretKey: String, wheres: Where*): Int
- def exportToCSV(file: String, aggregates: Aggregates, wheres: Wheres, groupByIntervals: GroupByIntervals, havings: Havings): Int
- def exportToCSV(file: String, cols: Cols, wheres: Wheres): Int
- def exportToCSV(file: String, wheres: Wheres): Int
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
getAggregateGroupRS[T](aggregates: Aggregates, wheres: Wheres, groupByIntervals: GroupByIntervals, havings: Havings, getSQLString: (Aggregates, Wheres, GroupByIntervals, Havings) ⇒ String, doSQLQuery: (PreparedStatement, Aggregates) ⇒ T)(implicit optConn: OptConn): T
- Attributes
- protected[sh.db]
- Definition Classes
- DBManagerDML
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getConfig: TraitDBConfig
- def getTable: Table
- def getTableID: String
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def importEncrypted(file: String, secretKey: String): Int
- def importFromCSV(file: String): Int
- def incrementColTx(where: Where, increment: Increment): Int
-
def
incrementColsTx(wheres: Wheres, increments: Increments)(implicit optConn: OptConn = None): Int
Updates the table by incrementing integer value cols (updateCols) by the values specified in incrementValues (which can be negative integers) The row(s) matching the wheres will be incremented.
Updates the table by incrementing integer value cols (updateCols) by the values specified in incrementValues (which can be negative integers) The row(s) matching the wheres will be incremented.
This is just a wrapper that reads, adds data and then updates. (the standard way) A more efficient way (read and update in one step) is given in the deprecated @incrementCols
- wheres
is an Array of Where (the criteria (Col, Op, Value)) for the cols to search in.
- returns
the number of rows updated The caller should ensure that the colType of each element of updateCols is INT.
- Definition Classes
- DBManagerDML
-
def
incrementColsTxWithLastValue(wheres: Wheres, increments: Increments)(implicit optConn: OptConn = None): (Int, Array[Any])
- Definition Classes
- DBManagerDML
-
def
insertArray(data: Array[Any])(implicit optConn: OptConn = None): Long
- Definition Classes
- DBManagerDML
- def insertList(data: List[Any]): Long
-
def
insertRS[T](rs: ResultSet): Int
Inserts an entry (row) into the table
Inserts an entry (row) into the table
- returns
the number of rows affected by the query
-
lazy val
insertString: String
- Definition Classes
- DBManagerDML
- def isEmpty: Boolean
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isNonEmpty: Boolean
-
def
isPostGreSQL: Boolean
Inserts an entry (row) into the table
Inserts an entry (row) into the table
- returns
the number of rows affected by the query
- Attributes
- protected
- Definition Classes
- DBManagerDML
-
val
keys: Array[String]
- Definition Classes
- DBManager → JsonFormatted
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
removeForeignKey(link: Link): Int
- Definition Classes
- DBManagerDDL
-
def
removeIndexIfExists(cols: Col*): Int
- Definition Classes
- DBManagerDDL
-
def
selectCols[T](wheres: Wheres, cols: Cols, func: (Array[Any]) ⇒ T)(implicit orderings: Orderings = Array(), limit: Int = 0, offset: Long = 0, optConn: OptConn = None): List[T]
Searches table and returns a list of objects of generic type T matching the colToSearch criteria.
Searches table and returns a list of objects of generic type T matching the colToSearch criteria.
Some code from http://www.roseindia.net/jdbc/Jdbc-functions.shtml
- wheres
is an Array[Where] (the criteria for the cols to search in).
- func
is a function that maps any array (i.e., Array[Any]) to type T. The input to the function will be the array containing the data for the cols contained in selectCols. The output can be any type the user wants. The subtype of the elements of the input array is determined by the type of cols contained in where: INT ---> Int ; VARCHAR ---> String ; VARBINARY ---> Array[Byte] ; TIMESTAMP ---> String. For instance: If searchCols is Array(RealValueCol, ImaginaryValueCol), where RealValueCol and ImaginaryValueCol are of type INT each, then the input to the function is an Array[Any] containing two Int elements. The function can, for instance, map this array as follows def func(ar:Array[Any]) = new ComplexNumber(ar(0).asInstanceOf[Int], ar(0).asIntanceOf[Int])
- returns
a list of type T
- Definition Classes
- DBManagerDML
-
def
selectInto(db: DBManager, cWheres: Wheres, cCols: Cols)(implicit cOrderings: Orderings = Array(), limit: Int = 0, offset: Long = 0, optConn: OptConn = None): Int
- Definition Classes
- DBManagerDML
-
def
selectRS[T](wheres: Wheres, cols: Cols, func: (ResultSet) ⇒ T)(implicit orderings: Orderings = Array(), limit: Int = 0, offset: Long = 0, optConn: OptConn = None): T
- Definition Classes
- DBManagerDML
-
def
setData(data: Array[(Any, DataType)], startCtr: Int, st: PreparedStatement, startDebugString: String): (Int, String)
- Attributes
- protected[sh]
- Definition Classes
- DBManagerDML
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- val table: Table
- val tableID: String
-
def
toString(): String
- Definition Classes
- JsonFormatted → AnyRef → Any
- def updateCol(where: Where, update: Update[Any]): Int
-
def
updateCols(wheres: Wheres, updates: Updates[Any])(implicit optConn: Option[Connection] = None): Int
Updates certain cols (columns) of the rows matching searchCol == searchData.
Updates certain cols (columns) of the rows matching searchCol == searchData.
- wheres
is an Array of Where (the criteria (Col, Op, Value)) for the cols to search in.
- updates
is an array of Update giving the cols and data to update
- returns
the number of rows updated
- Definition Classes
- DBManagerDML
- def updatePassword(newPass: String): String
-
def
usingOpt[A <: AnyRef { def close(): Unit }, B](optA: Option[A], getA: ⇒ A)(f: (A) ⇒ B): B
- Definition Classes
- DBManagerDML
-
val
vals: Array[Any]
- Definition Classes
- DBManager → JsonFormatted
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
Deprecated Value Members
-
def
aggregateBigInt(aggregates: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- Annotations
- @deprecated
- Deprecated
(Since version 22 Oct 2016) use aggregateBigDecimal as this may result in loss of precision
-
def
aggregateBigIntOld(aggregates: Aggregates, wheres: Wheres, havings: Havings = Array()): Array[Any]
- Annotations
- @deprecated
- Deprecated
(Since version 22 Oct 2016) use aggregateBigDecimal as this may result in loss of precision
-
def
aggregateGroupHavingOld[T](aggregates: Aggregates, wheres: Wheres, groupByIntervals: GroupByIntervals, havings: Havings, func: (ResultSet, String) ⇒ T)(implicit func2: (String) ⇒ T = ???, optConn: OptConn = None): List[Array[Any]]
protected def is used because this will need to be overridden in SecureDBManager
protected def is used because this will need to be overridden in SecureDBManager
http://stackoverflow.com/a/197300/243233
- Attributes
- protected[sh.db]
- Definition Classes
- DBManagerDML
- Annotations
- @deprecated
- Deprecated
(Since version kept for testing) will be removed
-
def
copyTo(dest: DBManager): Long
this is inefficient.
this is inefficient. It inserts one row at a time
- Annotations
- @deprecated
- Deprecated
-
def
incrementCol(where: Where, increment: Increment): Int
- Annotations
- @deprecated
- Deprecated
-
def
incrementCols(wheres: Wheres, increments: Increments)(implicit optConn: OptConn = None): Int
This attempts to provide ACID via the DB's update with x = x + 1 feature (see http://stackoverflow.com/a/15987873/243233http://stackoverflow.com/a/15987873/243233) However, it depend's on the DBMS's check statement to ensure that unsigned numbers never go below 0.
This attempts to provide ACID via the DB's update with x = x + 1 feature (see http://stackoverflow.com/a/15987873/243233http://stackoverflow.com/a/15987873/243233) However, it depend's on the DBMS's check statement to ensure that unsigned numbers never go below 0.
(Why incrementCols is used instead of a combination of read and then update?) This is due to concurrency issues and "lost updates". See: http://dba.fyicenter.com/Interview-Questions/RDBMS-FUNDAMENTALS/RDBMS_FUNDAMENTALS_Lost_Update_Problem.html http://cisnet.baruch.cuny.edu/holowczak/classes/3400/dbms_functions/
The solution used here (increment the col before read) is based on the suggestion at the following links http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html The same links also suggest an alternate fix - to use "SELECT FOR UPDATE". However, in our case, this seems to be the most convenient fix.
Note that MySQL does not support check. Hence this is insecure/unreliable in MySQL. For this reason, do not use this at all. Use incrementColTx instead which performs an ACID update (read, increment, update in a transaction) If not using H2 or Postgresql, this is fine to use.
- Definition Classes
- DBManagerDML
- Annotations
- @deprecated
- Deprecated
-
def
indexBy(cols: Col*): Int
- Definition Classes
- DBManagerDDL
- Annotations
- @deprecated
- Deprecated
(Since version 21 Nov 2017) Index reduces performance