Skip to content

Commit 2ac0bd1

Browse files
committed
update sorma2
1 parent e0c1c5f commit 2ac0bd1

File tree

2 files changed

+156
-2
lines changed

2 files changed

+156
-2
lines changed

sorma2/gen/com/zoffcc/applications/sorm/OrmaDatabase.java

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

2525
final static boolean ORMA_TRACE = false; // set "false" for release builds
2626
final static boolean ORMA_LONG_RUNNING_TRACE = false; // set "false" for release builds
@@ -762,6 +762,83 @@ public static String run_query_for_single_result(String sql_query)
762762
return text_result;
763763
}
764764

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

sorma2/o1.txt

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.zoffcc.applications.sorm.Log;
2020
public class OrmaDatabase
2121
{
2222
private static final String TAG = "sorm.OrmaDatabase";
23-
public static final String OrmaDatabaseVersion = "1.0.1";
23+
public static final String OrmaDatabaseVersion = "1.0.2";
2424

2525
final static boolean ORMA_TRACE = false; // set "false" for release builds
2626
final static boolean ORMA_LONG_RUNNING_TRACE = false; // set "false" for release builds
@@ -762,6 +762,83 @@ public class OrmaDatabase
762762
return text_result;
763763
}
764764

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

0 commit comments

Comments
 (0)