
alex29555
New User
Aug 15, 2012, 5:20 PM
Post #1 of 5
(1070 views)
|
|
Spawning multiple DB connections
|
Can't Post
|
|
Hi experts - I'm a newbie when it comes to Perl. I'm attempting to spawn thousands of DB sessions by looping through and establishing DB connections. I never see more than a single session being spawned. One single session is created and it doesn't exit until the Perl script completes. I would assume that every connect would be a separate session until it disconnects or the Perl script ends, but I only notice one being spawned during the run of the loop. I pasted the current code I'm using below. Any help or insight would be appreciated. Thank you for (my $i = 0; $i < 5000; $i++) { $dbh = DBI->connect("dbi:Oracle:host=esg-db2;sid=cga2-1", 'build','build123', {RaiseError => 1, AutoCommit => 1}) or die "Can't connect to database $DBI::errstr\n"; my $sql = 'select * from tab'; # Instead you could do $dbh->do($sql) or execute $sth = $dbh->prepare($sql); $sth->execute; } sleep 10000
|