public class SQLManipulator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
MYSQL_DRIVER |
Constructor and Description |
---|
SQLManipulator(String dbHost,
String dbName,
String dbUser,
String dbPassword) |
Modifier and Type | Method and Description |
---|---|
int |
deleteFromDB(String table,
String column,
String value) |
void |
disconnect() |
Connection |
getConnection() |
Statement |
getStatement() |
int |
insertIntoDB(String table,
Object[] values)
Inserts a new entry in a databse table.
|
int |
insertIntoDB(String table,
String[] names,
Object[] values)
Inserts a new entry in a database table
|
boolean |
isConntected() |
ResultSet |
readFromDB(String table,
int entryNo) |
ResultSet |
readFromDB(String returnColumn,
String table,
int entryNo) |
ResultSet |
readFromDB(String table,
String selectionColumn,
String value) |
ResultSet |
readFromDB(String returnColumn,
String table,
String selectionColumn,
String value) |
int |
updateDBEntry(String table,
String whereCond,
String[] names,
Object[] values)
Updates several columns in the specified database entries.
|
int |
updateDBEntry(String table,
String whereCond,
String name,
String value)
Updates one column in the specified database entries.
|
int |
updateDBEntry(String table,
String columnName,
String columnValue,
String[] names,
Object[] values)
Updates several columns in the specified database entries.
|
int |
updateDBEntry(String table,
String columnName,
String columnValue,
String name,
String value)
Updates one column in the specified database entries.
|
public static final String MYSQL_DRIVER
public SQLManipulator(String dbHost, String dbName, String dbUser, String dbPassword)
public boolean isConntected()
public Statement getStatement() throws SQLException
SQLException
public Connection getConnection()
public void disconnect() throws SQLException
SQLException
public int insertIntoDB(String table, Object[] values) throws SQLException
table
- the table to insert the new entryvalues
- the values of the entry (the values have to have the same order as
their columns have in the table)SQLException
public int insertIntoDB(String table, String[] names, Object[] values) throws SQLException
table
- the table to insert the new entrynames
- the column namesvalues
- the values for the columnsSQLException
public int updateDBEntry(String table, String columnName, String columnValue, String name, String value) throws SQLException
table
- the table which contains the entrycolumnName
- the name of the column by which the entry shall be identifiedcolumnValue
- the value of the column by which the entry shall be identifiedname
- the name of the column which shall be updatedvalue
- the value which shall be placed in the specified columnSQLException
public int updateDBEntry(String table, String whereCond, String name, String value) throws SQLException
table
- the table which contains the entrywhereCond
- the condition placed after the WHERE
-keyword in the SQL-queryname
- the name of the column which shall be updatedvalue
- the value which shall be placed in the specified columnSQLException
public int updateDBEntry(String table, String columnName, String columnValue, String[] names, Object[] values) throws SQLException
table
- the table which contains the entrycolumnName
- the name of the column by which the entry shall be identifiedcolumnValue
- the value of the column by which the entry shall be identifiednames
- a list of the names of the columns which shall be updatedvalues
- a list of the values which shall be placed in the specified columnsSQLException
public int updateDBEntry(String table, String whereCond, String[] names, Object[] values) throws SQLException
table
- the table which contains the entrywhereCond
- the condition placed after the WHERE
-keyword in the SQL-querynames
- a list of the names of the columns which shall be updatedvalues
- a list of the values which shall be placed in the specified columnsSQLException
public int deleteFromDB(String table, String column, String value) throws SQLException
SQLException
public ResultSet readFromDB(String table, String selectionColumn, String value) throws SQLException
SQLException
public ResultSet readFromDB(String returnColumn, String table, String selectionColumn, String value) throws SQLException
SQLException
public ResultSet readFromDB(String table, int entryNo) throws SQLException
SQLException
public ResultSet readFromDB(String returnColumn, String table, int entryNo) throws SQLException
SQLException