|
|
|
|||||
|
create proxy and database
Hello,
In the following code snippet I create proxies to insert data in a database. The call TestPrx::checkedCast(base) invokes the constructor, that initializes my database-object with the primary key. for(int i = 1; i <= 100; i++) { QString primaryKey = QString("name%1").stripWhiteSpace().arg(i); Ice::ObjectPrx base = ic->stringToProxy((string) primaryKey + ":default -p 10000"); TestPrx proxy = TestPrx::checkedCast(base); ... proxy->connectToDB(user, pwd, db); //call set functions ... proxy->insertInDB(); proxy->disconnectFromDB(); } At the moment for every single object a database connection is opened, the object is inserted in the db and the connection is closed. Is there any possibility to open the database connection at the beginning and insert all the data within this connection? Thank you for your hint. |
|
||||||
|
If I understand correctly, your snippet represents an Ice client that calls an Ice server to insert some data (100 rows) in a database.
Your server would be more scalable and easier to use if the database connections were not exposed to the clients. If possible (from a permission/security point of view), I would recommend to create a pool of connections in the server: each time a request arrives, the servant picks a connection from this pool. You should also avoid lots of small "set" remote calls, since remote calls are not as fast as local calls. You could use batched one ways, but combining all your sets into insert parameters would be simpler. You could end up with something as simple as: TestPrx proxy = databaseProxy->insert(primaryKey, c1, c2, c3, c4); Cheers, Bernard |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| about create topic | rellik78 | Help Center | 3 | 09-27-2006 05:10 AM |
| I create two CommunicatorPtr,is your right? | klsmlzm | Help Center | 7 | 03-06-2006 03:24 AM |
| Create MFC DLL error | jyq | Help Center | 1 | 02-23-2006 12:13 AM |
| create static libraries | hiasl | Help Center | 1 | 08-03-2005 11:59 AM |
| Can ICE be used to create an Open OPC? | Jeff Holle | Comments | 5 | 10-07-2003 01:44 AM |