Created
April 10, 2014 15:05
-
-
Save kevinhillinger/10391868 to your computer and use it in GitHub Desktop.
Try to open sql connections against sqlfire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Dapper; | |
using VMware.Data.SQLFire; | |
namespace sqlfire._112 | |
{ | |
class Program | |
{ | |
const string connString = "Server=localhost:1527;user=appuser;password=swys;Minimum Pool Size={0}; Maximum Pool Size=100"; | |
static void Main(string[] args) | |
{ | |
const int minPoolSize = 0; | |
const int minConnectionCount = 50; //anything above 20 connections. starts to throw. | |
Func<int, IDbConnection> connFactory = (index) => | |
{ | |
var conn = new SQLFClientConnection(string.Format(connString, minPoolSize)); | |
Console.WriteLine("Connection " + index + " created."); | |
return conn; | |
}; | |
foreach (var index in Enumerable.Range(1, 2)) | |
{ | |
var connections = Enumerable.Range(1, minConnectionCount).Select(j => | |
{ | |
var conn = connFactory(j); | |
try | |
{ | |
conn.Open(); | |
} | |
catch | |
{ | |
Console.WriteLine("Error creation connection {0} of iteration {1}", j, index); | |
throw; | |
} | |
return conn; | |
}); | |
//attempt to execute the connections | |
foreach (var conn in connections) | |
{ | |
conn.Execute("SELECT 1 FROM SYSIBM.SYSDUMMY1;"); | |
// Console.WriteLine("Used Connection State: " + conn.State); | |
} | |
} | |
Console.WriteLine("Test complete. Please press Enter to end"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also getting:
SQLState(08006) Severity(Session) An error occurred during connect reset and the connection has been terminated. See chained exceptions for details.
Inner Exception:
SQLState(XJ001) Severity(NoneApplicable) DisconnectException 08006: An error occurred during connect reset and the connection has been terminated. See chained exceptions for details.
Stack Trace:
b__1(Program.cs:36)at com.vmware.sqlfire.internal.client.am.Connection.reset(Connection.java:2557)
at com.vmware.sqlfire.internal.client.ClientPooledConnection.getConnection(ClientPooledConnection.java:262)
... 9 more
(SQLExceptionFactory40.java:77)
at com.vmware.sqlfire.internal.client.am.SqlException.getSQLException(SqlException.java:401)
at com.vmware.sqlfire.internal.client.ClientPooledConnection.getConnection(ClientPooledConnection.java:276)
at cli.VMware.Data.SQLFire.Driver.GetConnection(SQLFConnectionPool.cs:396)
at cli.VMware.Data.SQLFire.SQLFClientConnection.Open(SQLFClientConnection.cs:185)
at cli.VMware.Data.SQLFire.SQLFConnection.Open(SQLFConnection.cs:227)
at cli.sqlfire._112.Program$$$003C$$003Ec__DisplayClass6.
at cli.System.Linq.Enumerable$WhereSelectEnumerableIterator$$00602.MoveNext(Unknown Source)
at cli.sqlfire._112.Program.Main(Program.cs:47)
at cli.System.AppDomain._nExecuteAssembly(Unknown Source)
at cli.System.AppDomain.ExecuteAssembly(Unknown Source)
at cli.Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly(Unknown Source)