Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-03-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
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.
Reply With Quote
  #2 (permalink)  
Old 09-03-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,771
I'm not sure I understand the question. Is this related to Ice? When you open and close database connections is part of your server code, isn't it?

As for the code below, I don't understand why you have so many Ice objects. Also, what is "insertInDB()" doing? It doesn't have any arguments, so what does it insert?

Sorry, but I'm a bit confused by the design below I suggest to read the various examples in the Ice documentation in detail.
Reply With Quote
  #3 (permalink)  
Old 09-03-2003
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 760
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
Reply With Quote
  #4 (permalink)  
Old 09-04-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
Bernard, you've solved the riddle ;-).
Sorry, the code snippet was a little bit confusing. I will try the batched one ways.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -4. The time now is 07:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.