var common = require("./common")
	, odbc = require("../odbc.js")
	, db = new odbc.Database()
	, connectionString = common.connectionString
	, connections = []
	, connectCount = 500;

openConnectionsUsingPool(connections);

function openConnectionsUsingPool(connections) {
	for (var x = 0; x <= connectCount; x++) {
		
		(function (connectionIndex) {
			//setTimeout(function () {
			//console.error("Opening connection #", connectionIndex);
			
			pool.open(connectionString, function (err, connection) {
				//console.error("Opened connection #", connectionIndex);
				
				if (err) {
					console.error("error: ", err.message);
					return false;
				}
				
				connections.push(connection);
				
				if (connectionIndex == connectCount) {
					//closeConnections(connections);
				}
			});
			
			//}, x * 50);
		})(x);
	}
}

function openConnectionsUsingDB(connections) {
	for (var x = 0; x <= connectCount; x++) {
		
		(function (connectionIndex) {
			//console.error("Opening connection #", connectionIndex);
			var db = new Database();
			
			db.open(connectionString, function (err, connection) {
				//console.error("Opened connection #", connectionIndex);
				
				if (err) {
					console.error("error: ", err.message);
					return false;
				}
				
				connections.push(db);
				//connections.push(connection);
				
				if (connectionIndex == connectCount) {
					closeConnections(connections);
				}
			});
		})(x);
	}
}

function closeConnections (connections) {
	connections.forEach(function (connection, idx) {
		//console.error("Closing connection #", idx);
		connection.close(function () {
			//console.error("Closed connection #", idx);
		});
	});
}
@@ -61,18 +61,20 @@
 js%22)%0A%09, 
-db
+pool
  = new o
@@ -77,24 +77,20 @@
 ew odbc.
-Database
+Pool
 ()%0A%09, co
@@ -168,18 +168,17 @@
 Count = 
-50
+1
 0;%0A%0Aopen
@@ -1657,8 +1657,9 @@
 ;%0A%09%7D);%0A%7D
+%0A

fix pool test