RowMapper returns different column Ordering - prepared-statement

I am implementing a row mapper to format the results from a specific query. When I query my DB through PG admin, or just using a simple jdbctemplate.queryforlist the columns return in one order but when running using my RowMapper it returns in a completely different order that is in no way related to how i run the other queries (example query: select * from blah.mytable). Any ideas why a RowMapper would cause the columns to return in a different order?

The issue is that I was using a HashMap instead of a LinkedHasMap when I returned my results.


Retain Column Order in Database Connector in Mule

How can i force the database connector to return LinkedHashMap to ensure that resultset is in same order as in db?
Though the DB resultset is unordered, we can still extract data from columns or map columns to the target we desire. So may i know in which scenario you're expecting the ordered resultset?
and the another question which struck me after seeing your question was, why the resultset is unordered in the first place?
#vijay dhanakodi The best way would be to use data weave once you get the result and that arrange it accordingly example
%dw 1.0
%output application/java
firstColumn: payload.keyName as :object {class:"java.util.LinkedHashMap"}
SQL drivers do not maintain or guarantee the order of columns in returned resultset. Why is order important? I had similar situation, see this question.

MSSQL Query should return same as MYSQL

I've MYSQL Query and working fine
select tst_type, count(tst_type) tot from tst_type where project='JupiQA';
The above Query returns single record If I'm adding GROUP BY tst_type in this query it returns multiple values.
The Query I tried in MSSQL without GROUP BY tst_type ,its showing Error
ERROR IS: Column 'tst_type.tst_type' is invalid in the select list
because it is not contained in either an aggregate function or the
GROUP BY clause.
After that added GROUP BY tst_type in MSSQL query,then working fine and returns multiple value.
But my requirement is it should return same as MYSQL without adding GROUP BY fn OR should return single value like MYSQL
MySQL allows this behavior, but I don't know of any other DBMS that lets it happen. If you want MySQL and MSSQL queries to behave the same, add the SQL Mode ONLY_FULL_GROUP_BY. MySQL will now throw the error properly.
Also check out this SO post:
Why does MySQL allow "group by" queries WITHOUT aggregate functions?
When doing a COUNT() as you're doing here, the GROUP BY is required to get the correct results. See the MySQL docs on the function
You can use a count(*) without any other fields to get a count of the total number of records. Otherwise, you must use GROUP BY.
IMHO your requirement for this query is backwards; aggregate functions require GROUP BY to behave properly/consistently when non-aggregate fields are included in the select. MSSQL is behaving properly, MySQL is not.

Multiple query results

I am currently running a query in MS Access where i am searching for matching fields, the only problem is is that it is returning multiple fields which are all identical, is there anyway of limiting the results if the are identical?
What you need is DISTINCT.
Try something like this.
FROM table

Creating SQL Server JSON Parsing/Query UDF

First of all before I get into the question, I'll preface this with the fact that I know that this is a "bad" idea. But for business reasons it is something that I have to come up with a solution to, and I'm hoping that someone, somewhere might have some ideas on how to go about this.
I have a SQL Server 2008 R2 table that has a "OtherProperties" column. This column contains various other, somewhat arbitrary additional pieces of information that relate to the records. There is a business need to create a UDF that we can use to query the results, for example.
FROM MyTable
WHERE MyUDFGetValue(myTable.OtherProperties, "LinkedOrder[0]") IS NOT NULL
This would find a record where there was an array of LinkedOrder entries that contained a value at index 0
FROM MyTable
WHERE MyUDFGetValue(myTable.OtherProperties, "SubOrder.OrderId") = 25
This would find a property "orderId" and use its value in a comparison.
Anyone seen an implementation of this? I've seen implementations of functions. Like this JSONParser that take the values into a table which just will not get us what we need query wise. Complexity wise, I don't want to write a full fledged JSON parser, but I can if I need to.
Not sure if this will suit your needs but I read about a CLR JSON serializer/deserializer. You can find it here,
It's been a long time since you asked your question but there is now a solution you can use - JSON Select which provides various functions for different datatypes, for example the JsonInt() function. From one of your examples (assuming OrderId is an int, if not you could use a different function):
FROM MyTable
WHERE dbo.JsonInt(myTable.OtherProperties, 'SubOrder.OrderId') = 25
I am the author of JSON Select, and as such have an interest in you using it :)
If you cannot use SQL Server 2016 with built-in JSON support, you would need to use CLR e.g. JSONselect, json4sql, or custom code such as, etc.

Crystal Reports using multiple results from a Stored Procedure

I have a stored proc in sql-server and one of the parameters it returns is a string with the query parameters. I display those query parameters at the top of the report. That works great if something is found, not so great if nothing was found.
We have tried returning two query results, one the data set that I will make the report from (which includes the query parameters), the other the query parameter string. Crystal appears to only see the first data set, and this very old discussion ( says that is not something that will work. But that was over 5 years ago, and I'm hoping things have changed.
The problem, is if nothing is returned, the report is so blank that the person doesn't even know what query parameters they used. If they could see that they queried something that doesn't return any results, that would be useful.
So, if I have at the end of my stored proc:
SELECT * FROM [#ResultSet]
select #SearchCriteria as SearchCriteria
I'd like to be able to display the SearchCriteria even if there is nothing in the #ResultSet. Can it be done with this version of Crystal? Is there another way to do this?
Unless as stated by the first answer the results of one procedure have the same number of columns of another procedure (this includes type), if this is the case you can UNION the results or UNION ALL the results (if you want duplicates) to get ONE resultant set.
If the types or columns are not the same then you cannot do this. The only other option you can do is to merge all the relevant data into a temp table and then return the results from that temp table (SELECT * FROM #temp)
How are you currently able to display the parameters when results are found?
You haven't mentioned how you are using the Crystal Report in your environment.
Typically, I've done criteria display by passing the parameters to the Crystal Report as Report Parameters, and then using them in fields. This assumes you are calling it from a client application in some way.
Another option is to load the results into client datatables and binding to that as a datasource, it's certainly possible to handle the multiple result sets that way.