Package samuelal.squelized
Class SQLConnection
- java.lang.Object
-
- samuelal.squelized.SQLConnection
-
- Direct Known Subclasses:
MySQLConnection
,PostgreSQLConnection
,SQLiteConnection
public abstract class SQLConnection extends java.lang.Object
Main class that represents and abstract SQL database connection. Allows for connection functionality to a variety of SQL servers plus basic query creation functionality.- Author:
- Samuel Alarco Cantos
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
VERSION
-
Constructor Summary
Constructors Constructor Description SQLConnection()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description processing.data.Table
getColumn(java.lang.String tableName, java.lang.String columnName)
Gets all the data in a specific table column and generates Processing Tableprocessing.data.Table
getColumns(java.lang.String tableName, java.lang.String[] columnNames)
Gets all the date of a table's specified columns and generates Processing Tableprotected abstract DatabaseType
getDatabaseType()
protected abstract java.sql.Connection
getSQLConnection()
processing.data.Table
getTable(java.lang.String tableName)
Gets all the data of a table and generates a Processing Table with itvoid
insertIntoColumns(java.lang.String tableName, java.lang.String[] columnNames, java.lang.Object[] data)
Inserts values into specified columns (inserts only one row)processing.data.Table
runQuery(java.lang.String query)
Runs SQL query through connection and returns Table object with results.void
updateQuery(java.lang.String query)
Runs an Update SQL query through connectionstatic java.lang.String
version()
Return the version of the Library.protected void
welcome()
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
welcome
protected void welcome()
-
getSQLConnection
protected abstract java.sql.Connection getSQLConnection()
-
getDatabaseType
protected abstract DatabaseType getDatabaseType()
-
runQuery
public processing.data.Table runQuery(java.lang.String query)
Runs SQL query through connection and returns Table object with results. Cannot be used to run Update Queries.- Parameters:
query
- (String) Query to be executed in database- Returns:
- results
-
updateQuery
public void updateQuery(java.lang.String query)
Runs an Update SQL query through connection- Parameters:
query
- (String) Update Query to be executed in database
-
getTable
public processing.data.Table getTable(java.lang.String tableName)
Gets all the data of a table and generates a Processing Table with it- Parameters:
tableName
- (String) Name of the table to display- Returns:
- results
-
getColumn
public processing.data.Table getColumn(java.lang.String tableName, java.lang.String columnName)
Gets all the data in a specific table column and generates Processing Table- Parameters:
tableName
- (String) Name of the table to displaycolumnName
- (String) Name of column to extract data from- Returns:
- results
-
getColumns
public processing.data.Table getColumns(java.lang.String tableName, java.lang.String[] columnNames)
Gets all the date of a table's specified columns and generates Processing Table- Parameters:
tableName
- (String) Name of the table to displaycolumnNames
- (String[]) Array containing names of the columns to extract data from- Returns:
- results
-
insertIntoColumns
public void insertIntoColumns(java.lang.String tableName, java.lang.String[] columnNames, java.lang.Object[] data)
Inserts values into specified columns (inserts only one row)- Parameters:
tableName
- (String) Name of the table to insert intocolumnNames
- (String[]) Array containing the columns into which insert data (same order as corresponding element)data
- (Object[]) Array containing data objects to insert into respective columns (same order as columns)
-
version
public static java.lang.String version()
Return the version of the Library.- Returns:
- VERSION
-
-