Skip to content

Commit e73bce8

Browse files
committed
update sorma2
1 parent 8a84b4d commit e73bce8

1 file changed

Lines changed: 78 additions & 1 deletion

File tree

android-refimpl-app/app/src/main/java/com/zoffcc/applications/sorm/OrmaDatabase.java

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class OrmaDatabase
2323
{
2424
private static final String TAG = "sorm.OrmaDatabase";
25-
public static final String OrmaDatabaseVersion = "1.0.1";
25+
public static final String OrmaDatabaseVersion = "1.0.2";
2626

2727
final static boolean ORMA_TRACE = false; // set "false" for release builds
2828
final static boolean ORMA_LONG_RUNNING_TRACE = false; // set "false" for release builds
@@ -768,6 +768,83 @@ public static String run_query_for_single_result(String sql_query)
768768
return text_result;
769769
}
770770

771+
public static long run_query_for_single_result_l(String sql_query)
772+
{
773+
long long_result = 0L;
774+
775+
orma_global_sqlfreehand_lock.lock();
776+
try
777+
{
778+
Statement statement = null;
779+
try
780+
{
781+
statement = sqldb.createStatement();
782+
statement.setQueryTimeout(10); // set timeout to x sec.
783+
}
784+
catch (Exception e)
785+
{
786+
Log.i(TAG, "ERR:QSLL:001:" + e.getMessage());
787+
}
788+
789+
try
790+
{
791+
if (ORMA_TRACE)
792+
{
793+
Log.i(TAG, "sql=" + sql_query);
794+
}
795+
ResultSet rs = statement.executeQuery(sql_query);
796+
if (rs.next())
797+
{
798+
long_result = rs.getLong(1);
799+
}
800+
rs.close();
801+
}
802+
catch (Exception e)
803+
{
804+
Log.i(TAG, "ERR:QSLL:002:" + e.getMessage());
805+
}
806+
807+
try
808+
{
809+
statement.close();
810+
}
811+
catch (Exception e)
812+
{
813+
Log.i(TAG, "ERR:QSLL:003:" + e.getMessage());
814+
}
815+
}
816+
catch (Exception e)
817+
{
818+
Log.i(TAG, "ERR:QSLL:004:" + e.getMessage());
819+
}
820+
finally
821+
{
822+
orma_global_sqlfreehand_lock.unlock();
823+
}
824+
825+
return long_result;
826+
}
827+
828+
public static String now_datetime_utc()
829+
{
830+
return run_query_for_single_result("select datetime('now')");
831+
}
832+
833+
public static String now_datetime_localtime()
834+
{
835+
return run_query_for_single_result("select datetime('now','localtime')");
836+
}
837+
838+
public static long now_unixepoch_utc()
839+
{
840+
return run_query_for_single_result_l("select unixepoch('now')");
841+
}
842+
843+
public static long now_unixepoch_localtime()
844+
{
845+
return run_query_for_single_result_l("select unixepoch('now','localtime')");
846+
}
847+
771848
public static boolean set_bindvars_where(final PreparedStatement statement,
772849
final int bind_where_count,
773850
final List<OrmaBindvar> bind_where_vars)

0 commit comments

Comments
 (0)