public class SQLiteUtil
extends java.lang.Object
Date.getSQLString(),
Time.getSQLString()| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
fullPath |
int |
vectorInitialSize |
| Constructor and Description |
|---|
SQLiteUtil()
Open a connection at memory
|
SQLiteUtil(Connection con)
Use the given connection in all operations
|
SQLiteUtil(java.lang.String table)
Open a connection at the given table
|
SQLiteUtil(java.lang.String path,
java.lang.String table)
Open a connection at the given path and table
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(ResultSet rs) |
Connection |
con()
Returns the connecton with the parameters passed in the constructor
|
ResultSet |
executeQuery(java.lang.String s) |
static boolean |
existsIndex(java.lang.String tableName,
java.lang.String indexName,
Connection connection)
Check if the index with the name exists in this table
|
void |
finishTransaction() |
static java.lang.String |
fixQuote(java.lang.String s,
boolean toSqlite)
Handles single quote when inserting or retrieving data from Sqlite.
|
static Date |
fromSqlDate(java.lang.String sqldate)
Changes a date in format 2014-02-19 00:00:00:000 to a totalcross.util.Date.
|
int |
getColCount(ResultSet rs) |
int |
getColumnType(ResultSetMetaData md,
int col)
SQLite has a problem (not sure if its a bug) where it returns DATE for both
DATE and DATETIME types, so this method returns the correct correspondence:
DATE for date and TIME for DATETIME (remember that in TotalCross, a Time object also
contains the date).
|
int |
getInt(ResultSet rs) |
int |
getInt(java.lang.String sql) |
int |
getRowCount(java.lang.String table) |
int |
getShort(ResultSet rs) |
int |
getShort(java.lang.String sql) |
java.lang.String |
getString(java.lang.String sql) |
java.lang.String[][] |
getStrings(ResultSet rs) |
java.lang.String[][] |
getStrings(ResultSet rs,
Vector v) |
java.lang.String[][] |
getStrings(ResultSet rs,
Vector v,
int[] decimalPlaces) |
java.lang.String[][] |
getStrings(java.lang.String sql) |
java.lang.String[] |
getStrings1(ResultSet rs) |
java.lang.String[] |
getStrings1(java.lang.String sql) |
boolean |
isNotEmpty(ResultSet rs) |
boolean |
isNotEmpty(java.lang.String sql) |
java.lang.String[] |
listAllTables() |
PreparedStatement |
prepareStatement(java.lang.String sql) |
void |
rollback() |
void |
shrinkDB()
Rebuild and shrink the entire database, like the old Litebase's
purge method,
but in this case it applies to all tables. |
void |
startTransaction() |
boolean |
tableExists(java.lang.String tab) |
public int vectorInitialSize
public java.lang.String fullPath
public SQLiteUtil(java.lang.String table)
throws java.sql.SQLException
java.sql.SQLExceptionpublic SQLiteUtil(java.lang.String path,
java.lang.String table)
throws java.sql.SQLException
java.sql.SQLExceptionpublic SQLiteUtil()
throws java.sql.SQLException
java.sql.SQLExceptionpublic SQLiteUtil(Connection con)
public Connection con() throws java.sql.SQLException
java.sql.SQLExceptionpublic void close()
public boolean tableExists(java.lang.String tab)
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean isNotEmpty(java.lang.String sql)
public boolean isNotEmpty(ResultSet rs)
public int getColCount(ResultSet rs) throws java.sql.SQLException
java.sql.SQLExceptionpublic ResultSet executeQuery(java.lang.String s) throws java.sql.SQLException
java.sql.SQLExceptionpublic void close(ResultSet rs)
public java.lang.String[] getStrings1(java.lang.String sql)
public java.lang.String[] getStrings1(ResultSet rs)
public int getColumnType(ResultSetMetaData md, int col) throws java.sql.SQLException
md - The ResultSetMetaData obtained with ResultSet.getMetaData.col - The column, starting from 1.java.sql.SQLExceptionpublic java.lang.String[][] getStrings(ResultSet rs, Vector v) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String[][] getStrings(ResultSet rs, Vector v, int[] decimalPlaces) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String[][] getStrings(ResultSet rs) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String[][] getStrings(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getString(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getInt(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getInt(ResultSet rs) throws java.sql.SQLException
java.sql.SQLExceptionpublic int getShort(java.lang.String sql)
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getShort(ResultSet rs) throws java.sql.SQLException
java.sql.SQLExceptionpublic int getRowCount(java.lang.String table)
public void startTransaction()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void finishTransaction()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void rollback()
throws java.sql.SQLException
java.sql.SQLExceptionpublic PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String[] listAllTables()
public static java.lang.String fixQuote(java.lang.String s,
boolean toSqlite)
String s = SQLiteUtil.fixQuote("'",true); // returns ''
String s = SQLiteUtil.fixQuote("''",false); // returns '
public static Date fromSqlDate(java.lang.String sqldate) throws InvalidDateException
InvalidDateExceptionpublic void shrinkDB()
throws java.sql.SQLException
purge method,
but in this case it applies to all tables.java.sql.SQLExceptionpublic static final boolean existsIndex(java.lang.String tableName,
java.lang.String indexName,
Connection connection)
throws java.sql.SQLException
tableName - to checkindexName - to checkconnection - with the databasejava.sql.SQLException