Problem retrieving data from multiple databases [message #1355132] |
Wed, 14 May 2014 15:38 |
Bertin Kiekebosch Messages: 330 Registered: August 2011 |
Senior Member |
|
|
Hi I have a service in which I have to retrieve data from 3 different databases. Therefore I have created 3 AbstractSqlServices. The configuration of the databases is done through the ini file. The data is in one physical database but spread over three identical schemas. A little simplified my code looks like this:
public Object[][] getCustomers{
AbstractSqlService mpx1SqlService = SERVICES.getService(Mpx1SqlService.class);
AbstractSqlService mpx2SqlService = SERVICES.getService(Mpx2SqlService.class);
AbstractSqlService mpx3SqlService = SERVICES.getService(Mpx3SqlService.class);
String statement = "Select lastname, firstname, postalcode, city from customer";
Object[][] resultdb1 = mpx1SqlService.select(statement);
Object[][] resultdb2 = mpx2SqlService.select(statement);
Object[][] resultdb3 = mpx3SqlService.select(statement);
Object[][] totalResult = new Object[resultdb1.length + resultdb2.length + resultdb3.length][];
System.arraycopy(resultdb1, 0, totalResult, 0, resultdb1.length);
System.arraycopy(resultdb2, 0, totalResult, resultdb1.length, resultdb2.length);
System.arraycopy(resultdb3, 0, totalResult, resultdb1.length + resultdb2.length, resultdb3.length);
return totalresult[];
}
What I expected are the customer form three databases but I got the customers from database 1 en twice the customers from database 2.
I verified that the configuration is correct. I did some test to first copy the data in a temporary list but that also does not work. In the SQL Server activity monitor I can see that all three databases are queried so this assures that the configuration is OK.
If I skipp the database 2 then I get the results from database 3.
I suspect somewhere in Scout the results are messed up. Maybe I have to do something extra because I am working with multiple connections.
Regards Bertin
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04680 seconds