C# – Connecting to SQL Server on Ubuntu20.04 -VS Code No.104

This blog provides instructions on how to connect to and run a select query in SQL Server on Ubuntu 20.04 using .NET Data Provider for SQL Server (SqlClient). ▼1. Connecting to SQL Server on Ubuntu by C# In the past, this blog demonstrated how to connect to SQL Server on Ubuntu and execute a query using Python and Java. However, in this case, C# will be used instead. (As of 2022/12) ▼2. Prerequisites 2-1. Installing Ubuntu 20.04.2 LTS https://releases.ubuntu.com/20.04/ 2-2. Installing Visual Studio Code https://code.visualstudio.com/docs/setup/linux 2-3. Installing C# extension To install the C# extension, press the Ctrl+P keys and type “ext install ms-dotnettools.csharp” in the search box, then press Enter. … Continue reading “C# – Connecting to SQL Server on Ubuntu20.04 -VS Code No.104”

Python – Create Sample data in SQL Server on Ubuntu v2 No.97

How to create sample data in SQL Server on Ubuntu using Python is shown in this blog. ▼1. Creating sample data using Python In the past, how to create sample data using the insert query that is created by python code was provided below in this case, this insert query was executed using sqlcmd utility. but this blog all of steps is executed by python without sqlcmd. Python – Creating sample data in SQL Server on Ubuntu No.62 ▼2. Prerequisites How to build an environment using Python is shown below. Python – How to connect to SQL Server on Ubuntu No.92 ▼3. Bulk create sample data in SQL Sever 3-1. … Continue reading “Python – Create Sample data in SQL Server on Ubuntu v2 No.97”

Python -Save data in SQL Server into Azure Blob Storage No96

How to save the results of select statement into Azure Blob Storage after connecting to SQL Server on Ubuntu through pyodbc using python is shown in this blog. ▼1. Saving data in SQL Server on Ubuntu into Azure Blob Storage Based on the previous blog using Java as below, pyhon code is shown to save the results of select statement into Azure Blob Storage. Java – Save the results of select query on SQL Server into Azure Blob Storage No.75 ▼2. Prerequisites How to build an environment using Python is shown below. Python – How to connect to SQL Server on Ubuntu No.92 ▼3. Developing Python code to save the … Continue reading “Python -Save data in SQL Server into Azure Blob Storage No96”

Python – Save data in SQL Server on Ubuntu into a file No.95

How to save the results of select statement into a file after connecting to SQL Server on Ubuntu through pyodbc using python is shown in this blog. ▼1. Saving data in SQL Server on Ubuntu into a file Based on the previous blog using Java as below, pyhon code is shown to save the results of select statement into a file. Java – Put SQL Server select results into a csv file No.70 ▼2. Prerequisites How to build an environment using Python is shown below. Python – How to connect to SQL Server on Ubuntu No.92 ▼3. Developing Python code to save the results of select query in SQL Server … Continue reading “Python – Save data in SQL Server on Ubuntu into a file No.95”

Python -Run a transactional query SQL Server on Ubuntu No.94

How to execute commit or rollback for a transactional query using python and pyodbc in SQL Server on Ubuntu is shown in this blog. ▼1. Run a transactional query in SQL Server on Ubuntu Regarding Java, how to execute a transactional query was shown in this past blog as below. this blog is written to implement it by Python. the autocommit of pyodbc is true. it is meant to commit a transaction automatically by default. ▼2. Creating Python code to insert data with False of “autocommit” Table “sampletb” has columns “c1” and “c2”. the value (10,10) is inserted using transaction and then select is executed to get data. after that, this … Continue reading “Python -Run a transactional query SQL Server on Ubuntu No.94”

Python -Error handling & Retry in SQL Server on Ubuntu No.93

How to implement the error handling and retry with some interval in SQL Server on Ubuntu by Python is shown in this blog. ▼1. Why do we need an error handling and an retry logic? We often use a cloud service and a remote service through the network. if the network intermittently cause something problems, the client application cannot access these services and will stop. to avoid this case, we need to add an error handling and an retry logic in an client application. ▼2. Prerequisites An error handling and a retry logic will be added into the code that was shown in the following blog. Python – How to … Continue reading “Python -Error handling & Retry in SQL Server on Ubuntu No.93”

Java – Run a transactional query in SQL Server on Ubuntu No9

How to execute a transactional query in SQL Server on Ubuntu using Java is shown in this blog. ▼1. How to execute a transactional query in SQL Server on Linux Commit or Rollback by transaction can keep consistency of data when the query fails in the middle of the process. setAutoCommit method of SQLServerConnection class in JDBC Driver can use commit and rollback to implement a transactional query. ▼2. Implement insert query using transaction in SQL Server on Linux 2-1. Creating Java code Transactional insert query will add (6,7) and (7,8) into the table “t1”. after the transaction get started, an insert query is executed and then commit is executed. … Continue reading “Java – Run a transactional query in SQL Server on Ubuntu No9”

Java – Error handling & Retry in SQL Server on Ubuntu No.6

How to implement the error handling and retry with some interval in SQL Server on Ubuntu by Java is shown in this blog. ▼1. An error handling and a retry logic with interval are mandatory When we connect to cloud services, we often experience the intermittent network issue. in this case, an error handling and a retry logic with some interval are mandatory to keep application working on. ▼2. Creating Java code to implement Error handling & Retry logic 2-1. Creating a Java code This Java code implements 3 retries with 30 seconds interval using while after a connection failure. To cause the connection failure, listening port of SQL Server … Continue reading “Java – Error handling & Retry in SQL Server on Ubuntu No.6”

Java -AutoRetry connection by JDBC Driver for SQLServer No53

How to implement auto retry with some internal by Java is shown in this blog. the connection string using Microsoft JDBC Driver for SQL Server “Connection String” has a feature of auto retry with some internal. ▼1. Auto retry with some interval feature of Connection String of Microsoft JDBC Driver for SQL Server (Version 9.4 以上) As the mandatory setting for a cloud service, the following retry with some interval in a connection string can be used after “Microsoft JDBC Driver 9.4 for SQL Server”. ▼2. Writing Java code to implement auto-retry when failing to connect to SQL Server 2.1. Creating a Java code for auto-retry connection This code uses … Continue reading “Java -AutoRetry connection by JDBC Driver for SQLServer No53”

Java – Execute a Select query in SQL Server on Ubuntu No.8

How to run a select query in SQL Server on Ubuntu using Java is shown in this blog. ▼1. Prerequisites Creating a table “t1” in a database “TestDB” and inserting data intho this table are executed by sqlcmd utility. “sa” user is used in this sample. ▼2. Executing a query in SQL Server on Ubuntu by Java 2-1. Creating Java code to execute Select query 1-2. Results of this code Current Timestamps: 2020-05-26 06:52:10.564 [main] INFO ExecuteQSQLSvr – Connect to SQL Server successfully retrieve c1    c2 for t1 table 1    2 2    3 3    4 4    5 5    6 Current Timestamps: 2020-05-26 06:52:11.83 [main] INFO ExecuteQSQLSvr – The connection is … Continue reading “Java – Execute a Select query in SQL Server on Ubuntu No.8”