Skip to content

Commit 5bb48ae

Browse files
authored
Update sync.cs (#403)
Updated license, comments, and code.
1 parent d87bff8 commit 5bb48ae

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

samples/async/sync.cs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
using Oracle.ManagedDataAccess.Client;
2+
using System.Threading.Tasks;
23
using System.Threading;
34
using System;
45

5-
// This code sample demonstrates using synchronous ODP.NET (managed or core) and times its execution time.
6-
// This sample uses the Oracle HR sample schema.
6+
// This app uses synchronous ODP.NET (managed or core) APIs to open a connection,
7+
// execute a SQL statement, and read the results. It times how long these operations take.
8+
// To run this app, add your database's HR schema User Id, Password, and Data Source values
9+
// with ODP.NET 23ai or higher connecting to an Oracle Database 19c or higher.
10+
711

812
class ODPNET_Sync
913
{
1014
static void Main()
1115
{
1216
// Add password and data source to connect to your Oracle database
13-
string conString = @"User Id=hr;Password=<PASSWORD>;Data Source=<NET SERVICE NAME>;";
17+
string conString = "User Id=hr;Password=<PASSWORD>;Data Source=<DATA SOURCE>;";
1418

1519
using (OracleConnection con = new OracleConnection(conString))
16-
{
17-
// Measure time Open takes before next operation can start execution
20+
{
21+
//Time how long it takes to open a connection
1822
DateTime start_time = DateTime.Now;
1923
con.Open();
2024
DateTime end_time_open = DateTime.Now;
@@ -30,35 +34,36 @@ static void Main()
3034
reader.Read();
3135
}
3236
}
33-
// Measure time all the sync operations took
3437
DateTime end_time_all = DateTime.Now;
3538

36-
// Calculate connection open time and write result to console
39+
// Calculate connection open time
3740
TimeSpan ts_open = end_time_open - start_time;
3841
double ts_open1 = Math.Round(ts_open.TotalSeconds, 2);
3942
Console.WriteLine("Synchronous connection open time: " + ts_open1 + " seconds");
4043

41-
// Calculate overall operation time and write result to console
44+
// Calculate overall ODP.NET operation time
4245
TimeSpan ts_all = end_time_all - start_time;
4346
double ts_all1 = Math.Round(ts_all.TotalSeconds, 2);
44-
Console.WriteLine("Synchronous ODP.NET operations time: " + ts_all1 + " seconds");
47+
Console.WriteLine("Synchronous ODP.NET overall time: " + ts_all1 + " seconds");
4548
}
4649
}
4750
}
4851

49-
/* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. */
52+
/* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. */
5053

5154
/******************************************************************************
52-
* Licensed under the Apache License, Version 2.0 (the "License");
53-
* you may not use this file except in compliance with the License.
54-
* You may obtain a copy of the License at
5555
*
56-
* http://www.apache.org/licenses/LICENSE-2.0
56+
* You may not use the identified files except in compliance with The MIT
57+
* License (the "License.")
58+
*
59+
* You may obtain a copy of the License at
60+
* https://github.com/oracle/Oracle.NET/blob/master/LICENSE.txt
61+
*
62+
* Unless required by applicable law or agreed to in writing, software
63+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
64+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65+
*
66+
* See the License for the specific language governing permissions and
67+
* limitations under the License.
5768
*
58-
* Unless required by applicable law or agreed to in writing, software
59-
* distributed under the License is distributed on an "AS IS" BASIS,
60-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61-
* See the License for the specific language governing permissions and
62-
* limitations under the License.
63-
*
6469
*****************************************************************************/

0 commit comments

Comments
 (0)