gpt4 book ai didi

java.sql.SQLException : Before start of result set. 结果集循环内的查询如何?

转载 作者:可可西里 更新时间:2023-11-01 07:49:49 25 4
gpt4 key购买 nike

<分区>

我试图在结果集循环中创建查询,但我不断收到错误“结果集开始前”。我尝试了很多不同的方法,但它们总是出现相同的错误。

有人可以帮我吗?

String insertSQL = "INSERT INTO MonthlyReportTable VALUES(NULL,"; //Primary Key.

String PlannetSchemeCode = "";
int ResponcibleAuthorityID = 0;

Statement stmt = ConnectionDetails.getNewConnectionPPARSDB().createStatement();
ResultSet resultsSet = stmt.executeQuery("SELECT * FROM planning_scheme");

Statement insideStatement = ConnectionDetails.getNewConnectionPPARSDB().createStatement();

//Loop though each planning scheme and create the data for each field.
while (resultsSet.next())
{
PlannetSchemeCode = "'" + resultsSet.getString("ps_code") + "'";

//Planning Scheme Primary Key
insertSQL += PlannetSchemeCode + ",";

/*
//Responsible Authority ID
insertSQL += "'" + String.valueOf(
ResponcibleAuthorityID = MySQLUtil.getResults(
ConnectionDetails.Database_Connection_PPARSDB,
"SELECT resp_authority_id " +
"FROM resp_authority_to_ps " +
"WHERE ps_code = " + PlannetSchemeCode
)
.getInt("resp_authority_id")
) + "'";
*/

ResultSet insideResultsSet =
insideStatement.executeQuery(
"SELECT resp_authority_id " +
"FROM resp_authority_to_ps " +
"WHERE ps_code = " + PlannetSchemeCode
);

//ERROR HERE, some reason results set is getting set wrong??
//Error here, this current results set is resetting the Results set.
ResponcibleAuthorityID = insideResultsSet.getInt("resp_authority_id");

//Total_Received_CM

//Add the rest of the values temporary.
int FeildsAdded = 3;
for(int i = 1 + FeildsAdded; i < 458; i++)
{
insertSQL += String.valueOf(0) + ",";
}

//Insert date and end SQL string.
insertSQL += "NOW()";
insertSQL += ")";

System.out.println(insertSQL);

//Do Insert in PPARS.
//stmt.executeQuery(insertSQL);
//Reset the SQL String for the new Row.
insertSQL = "INSERT INTO MonthlyReportTable VALUES(NULL,";
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com