Skip to content

Commit

Permalink
sorma: fix missing bind vars
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Apr 11, 2024
1 parent a48eefe commit abc2a07
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 6 deletions.
36 changes: 34 additions & 2 deletions src/main/java/com/zoffcc/applications/sorm/FriendList.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,21 @@ public void execute()
final String sql = this.sql_start + " " + this.sql_set + " " + this.sql_where;
if (ORMA_TRACE)
{
Log.i(TAG, "sql=" + sql + " bindvar count=" + bind_set_count);
Log.i(TAG, "sql=" + sql + " bindvar count=" + (bind_set_count + bind_where_count));
if (bind_set_count > 0)
{
for(int jj=0;jj<bind_set_count;jj++) {
Log.i(TAG, "bindvar ?" + (jj + BINDVAR_OFFSET_SET) +
Log.i(TAG, "bindvar set ?" + (jj + BINDVAR_OFFSET_SET) +
" = " + bind_set_vars.get(jj).value);
}
}
if (bind_where_count > 0)
{
for(int jj=0;jj<bind_where_count;jj++) {
Log.i(TAG, "bindvar where ?" + (jj + BINDVAR_OFFSET_WHERE) +
" = " + bind_where_vars.get(jj).value);
}
}
}
PreparedStatement statement = sqldb.prepareStatement(sql);
statement.clearParameters();
Expand Down Expand Up @@ -413,6 +420,31 @@ public void execute()
e.printStackTrace();
}
}
if (bind_where_count > 0)
{
try {
for (int jj = 0; jj < bind_where_count; jj++) {
int type = bind_where_vars.get(jj).type;
if (type == BINDVAR_TYPE_Int) {
statement.setInt((jj + BINDVAR_OFFSET_WHERE),
(int) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Long) {
statement.setLong((jj + BINDVAR_OFFSET_WHERE),
(long) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_String) {
statement.setString((jj + BINDVAR_OFFSET_WHERE),
(String) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Boolean) {
statement.setBoolean((jj + BINDVAR_OFFSET_WHERE),
(boolean) bind_where_vars.get(jj).value);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
statement.executeUpdate();

try
Expand Down
36 changes: 34 additions & 2 deletions src/main/java/com/zoffcc/applications/sorm/GroupMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,21 @@ public void execute()
final String sql = this.sql_start + " " + this.sql_set + " " + this.sql_where;
if (ORMA_TRACE)
{
Log.i(TAG, "sql=" + sql + " bindvar count=" + bind_set_count);
Log.i(TAG, "sql=" + sql + " bindvar count=" + (bind_set_count + bind_where_count));
if (bind_set_count > 0)
{
for(int jj=0;jj<bind_set_count;jj++) {
Log.i(TAG, "bindvar ?" + (jj + BINDVAR_OFFSET_SET) +
Log.i(TAG, "bindvar set ?" + (jj + BINDVAR_OFFSET_SET) +
" = " + bind_set_vars.get(jj).value);
}
}
if (bind_where_count > 0)
{
for(int jj=0;jj<bind_where_count;jj++) {
Log.i(TAG, "bindvar where ?" + (jj + BINDVAR_OFFSET_WHERE) +
" = " + bind_where_vars.get(jj).value);
}
}
}
PreparedStatement statement = sqldb.prepareStatement(sql);
statement.clearParameters();
Expand Down Expand Up @@ -411,6 +418,31 @@ public void execute()
e.printStackTrace();
}
}
if (bind_where_count > 0)
{
try {
for (int jj = 0; jj < bind_where_count; jj++) {
int type = bind_where_vars.get(jj).type;
if (type == BINDVAR_TYPE_Int) {
statement.setInt((jj + BINDVAR_OFFSET_WHERE),
(int) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Long) {
statement.setLong((jj + BINDVAR_OFFSET_WHERE),
(long) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_String) {
statement.setString((jj + BINDVAR_OFFSET_WHERE),
(String) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Boolean) {
statement.setBoolean((jj + BINDVAR_OFFSET_WHERE),
(boolean) bind_where_vars.get(jj).value);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
statement.executeUpdate();

try
Expand Down
37 changes: 35 additions & 2 deletions src/main/java/com/zoffcc/applications/sorm/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,21 @@ public void execute()
final String sql = this.sql_start + " " + this.sql_set + " " + this.sql_where;
if (ORMA_TRACE)
{
Log.i(TAG, "sql=" + sql + " bindvar count=" + bind_set_count);
Log.i(TAG, "sql=" + sql + " bindvar count=" + (bind_set_count + bind_where_count));
if (bind_set_count > 0)
{
for(int jj=0;jj<bind_set_count;jj++) {
Log.i(TAG, "bindvar ?" + (jj + BINDVAR_OFFSET_SET) +
Log.i(TAG, "bindvar set ?" + (jj + BINDVAR_OFFSET_SET) +
" = " + bind_set_vars.get(jj).value);
}
}
if (bind_where_count > 0)
{
for(int jj=0;jj<bind_where_count;jj++) {
Log.i(TAG, "bindvar where ?" + (jj + BINDVAR_OFFSET_WHERE) +
" = " + bind_where_vars.get(jj).value);
}
}
}
PreparedStatement statement = sqldb.prepareStatement(sql);
statement.clearParameters();
Expand Down Expand Up @@ -535,6 +542,32 @@ public void execute()
e.printStackTrace();
}
}
if (bind_where_count > 0)
{
try {
for (int jj = 0; jj < bind_where_count; jj++) {
int type = bind_where_vars.get(jj).type;
if (type == BINDVAR_TYPE_Int) {
statement.setInt((jj + BINDVAR_OFFSET_WHERE),
(int) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Long) {
statement.setLong((jj + BINDVAR_OFFSET_WHERE),
(long) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_String) {
statement.setString((jj + BINDVAR_OFFSET_WHERE),
(String) bind_where_vars.get(jj).value);
} else if (type == BINDVAR_TYPE_Boolean) {
statement.setBoolean((jj + BINDVAR_OFFSET_WHERE),
(boolean) bind_where_vars.get(jj).value);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

statement.executeUpdate();

try
Expand Down

0 comments on commit abc2a07

Please sign in to comment.