Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The first two hsql db statements work successfully however when we query a third statement the code gives an error saying it can not detect the database for that query. The database is connected and it will only allow two queries. Each statement is individually closed as you can see in the code. Any solutions so we are able to have as many queries as we need? Below are the queries that are being run. Is anyone familiar with the amount of queries allowed in HSQLDB? Thanks in advance.
C
//find the driver e_id
	cp = "SELECT \"E_ID\" FROM \"nameable\" WHERE \"dtype\" = 'GasTurbine'";
	detect = detectOdbcFailure(SQLExecDirect(stmt, (SQLCHAR*)cp.c_str(), SQL_NTS), conn,
		"Non-parameter query failed");
	// Would return SQL_NO_DATA if no rows inserted.
	// Don't need to bind until before fetches are performed.
	if (detect) return detect;
	detect = detectOdbcFailure(
		SQLBindCol(stmt, 1, SQL_C_SLONG, &e_id, 0, NULL), conn,
		"Bind of 'E_ID' output failed");
	if (detect) return detect;

	while ((odbcret = SQLFetch(stmt)) != SQL_NO_DATA) {
		if (detectOdbcFailure(odbcret, conn, "Fetch failed")) return detect;
		printf("%d\n", e_id);
	}
	// Close cursor for re-use
	detect = detectOdbcFailure(SQLCloseCursor(stmt), conn,
		"Failed to close Cursor for re-use");
	if (detect) return detect;


	//get a list of components in driver
	cp = "SELECT \"E_ID\" FROM \"nameable\" WHERE \"E_CONTAINER\" = " + std::to_string(e_id);
	detect = detectOdbcFailure(SQLExecDirect(stmt, (SQLCHAR*)cp.c_str(), SQL_NTS), conn,
		"Non-parameter query failed");
	// Would return SQL_NO_DATA if no rows inserted.
	// Don't need to bind until before fetches are performed.
	if (detect) return detect;
	detect = detectOdbcFailure(
		SQLBindCol(stmt, 1, SQL_C_SLONG, &e_id, 0, NULL), conn,
		"Bind of 'E_ID' output failed");
	if (detect) return detect;
	while ((odbcret = SQLFetch(stmt)) != SQL_NO_DATA) {
		if (detectOdbcFailure(odbcret, conn, "Fetch failed")) return detect;
		printf("%d\n", e_id);
	  }
		// Close cursor for re-use
		detect = detectOdbcFailure(SQLCloseCursor(stmt), conn,
			"Failed to close Cursor for re-use");
		if (detect) return detect;


	cp = "SELECT \"E_ID\" FROM \"nameable\" WHERE \"dtype\" = 'Inlet'";
	detect = detectOdbcFailure(SQLExecDirect(stmt, (SQLCHAR*)cp.c_str(), SQL_NTS), conn,
			"Third query failed");
		// Would return SQL_NO_DATA if no rows inserted.
		// Don't need to bind until before fetches are performed.
		if (detect) return detect;
		detect = detectOdbcFailure(
			SQLBindCol(stmt, 1, SQL_C_SLONG, &e_id, 0, NULL), conn,
			"Bind of 'E_ID' output failed");
		if (detect) return detect;

		while ((odbcret = SQLFetch(stmt)) != SQL_NO_DATA) {
			if (detectOdbcFailure(odbcret, conn, "Fetch failed")) return detect;
			printf("%d\n", e_id);
		}
		// Close cursor for re-use
		detect = detectOdbcFailure(SQLCloseCursor(stmt), conn,
			"Failed to close Cursor for re-use");
		if (detect) return detect;
	}


What I have tried:

I tried closing each individual statement as well as looking through all the .config files. I combed through the HSQL DB user guide as well.
Posted
Updated 4-Mar-21 20:53pm
v2
Comments
Rick York 4-Mar-21 15:20pm    
I recommend that you look at the right side of this page in the "Related Questions" section. There is a list of similar questions that have been asked previously. You might find your answer in one of them.
Member 15090304 4-Mar-21 15:38pm    
You're talking about these questions?

Related Questions
Is mono similar to ms C# and does C# code runs successfully in mono. ?
RUN SQL STATEMENT nth times
How Do I Rollback Operation If First Two Transaction Occurs Successfully But Third Transaction Cannot Be Successful
RUN SQL STATEMENT IN DATASET by match case
Am trying to run a code for data extraction between two date but my codes are not working, can u help me please
Run window service in linux
Why a class not run that have 6120 lines code
When I delete txt file, and when it run first, data is not visible.
Vb.net check DB for value then run IF statement
How to compare two consecutive rows values in SQL.

No, none of these questions are related to my use case. Any ideas would be appreciative. I am just trying to query three consecutive HSQL statements through .cpp and after the first and second statement returns the statement as expected. I run into the issue on the third statement(as you can see in the code snippet).
Thanks anyways.
RedDk 7-Mar-21 14:27pm    
You say two of the three queries are successful ... if you show some/(all) of the return for those two, that would be helpful. HSQL, as I've seen it used, requires some java installation and since there is no connection string in either of the two "good" queries I'm wondering how you managed to get anything at all without a reference.
Richard MacCutchan 5-Mar-21 5:16am    
Which statement causes the error, and what is the exact text of the error message?
Member 15090304 5-Mar-21 11:13am    
It is not a statement specifically. It is more that HSQL cannot execute more than two queries at a time(I have three in a row in the example, all closed out after each statement). I am not sure if it is an known issue and there is an easy solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900