Example #1
0
        private void Initialize()
        {
            var port = PortUtility.GetFreeTcpPort();

            // TODO : Need to move Execute logic to J2NET
            var classPaths = string.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ";" : ":", jarPath, DriverPath);

            _process = JavaRuntime.Execute($"-XX:G1PeriodicGCInterval=5000 -cp \"{classPaths}\" com.chequer.jdbcnet.bridge.Main -p {port}");
            PortUtility.WaitForOpen(port);

            _channel = new Channel($"{host}:{port}", ChannelCredentials.Insecure);

            Driver    = new DriverService.DriverServiceClient(_channel);
            Reader    = new ReaderService.ReaderServiceClient(_channel);
            Statement = new StatementService.StatementServiceClient(_channel);
            Database  = new DatabaseService.DatabaseServiceClient(_channel);

            var loadDriverResponse = Driver.loadDriver(new LoadDriverRequest
            {
                ClassName = DriverClass
            });

            DriverMajorVersion = loadDriverResponse.MajorVersion;
            DriverMinorVersion = loadDriverResponse.MinorVersion;
        }