English 中文(简体)
此正确查询是否要发送到甲骨文
原标题:Is this right query to be sent to Oracle

显示我表单的 SET Col_1=?,COL_2=? COL_3=? COL_3=? 和COL_4=?

我将阵列的精确值数数发送到声明(我的情况:4) 中,这样我就有例外了: 缺少 IN 或 ERU 参数(指数: 4) 。

注意:我认为我们不能做 SET Col_1=?,COL_2=? 我们需要做 SET Col_1= DESIRED_value,COL_2= DESIRED_value 这是我的误解吗?

Java 代码

StringBuilder updateQuery=new StringBuilder("UPDATE MY_TABLE SET COL_1=?, COL_2=? where BOOKMARKID_ACT=? AND DIMID_ACT=?");         
ArrayList<Object> alObjectData=new ArrayList<Object>();
alObjectData.add("VALUE1");
alObjectData.add("VALUE2");
alObjectData.add("VALUE3");
alObjectData.add("VALUE4");
dpQuery.executeUpdate(connTemp, updateQuery.toString(), alObjectData);
最佳回答

我认为您想要创建一个 准备声明 。 它应该是这样看的 :

// con is your active connection

String sqlStatement = "UPDATE MY_TABLE SET COL_1=?, COL_2=? where BOOKMARKID_ACT=? AND DIMID_ACT=?";
PreparedStatement prest = con.prepareStatement(sqlStatement);
prest.setString(1, valueFirstParam);
prest.setString(2, valueSecondParam);
prest.setString(3, valueThirdParam);
prest.setString(4, valueFourthParam);
prest.executeUpdate();

您也应该在类的顶端添加此行

import java.sql.*;

准备声明避免您输入 sql 代码。

http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/prepared Statement.html”更多关于这一链接

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签