Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sorma: fix missing bind vars #207

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading