// Use the JDBC driver
import java.sql.*;
import com.microsoft.sqlserver.jdbc.*;

	public class SQLDatabaseTest {

		// Connect to your database.
		// Replace server name, username, and password with your credentials
		public static void main(String[] args) {
			String connectionString =
				"jdbc:sqlserver://your_server.database.windows.net:1433;"
				+ "database=your_database;"
				+ "user=your_user@your_server;"
				+ "password={your_password};"
				+ "encrypt=true;"
				+ "trustServerCertificate=false;"
				+ "hostNameInCertificate=*.database.windows.net;"
				+ "loginTimeout=30;";

			// Declare the JDBC objects.
			Connection connection = null;
			Statement statement = null;
			ResultSet resultSet = null;
			PreparedStatement prepsInsertPerson = null;
			
			try {
				connection = DriverManager.getConnection(connectionString);

				// Create and execute a SELECT SQL statement.
				String selectSql = "SELECT Title, FirstName, MiddleName, LastName from SalesLT.Customer";
				statement = connection.createStatement();
				resultSet = statement.executeQuery(selectSql);

				// Print results from select statement
				while (resultSet.next()) {
					System.out.println(resultSet.getString(2) + " "
						+ resultSet.getString(3)
						+ resultSet.getString(4));
					}

				// Create and execute an INSERT SQL prepared statement.
				String insertSql = "INSERT INTO SalesLT.Customer (FirstName, LastName, CompanyName) VALUES "
					+ "('Bill', 'Gates', 'Microsoft'), "
					+ "('Steve', 'Ballmer', 'Microsoft');";

				prepsInsertPerson = connection.prepareStatement(
					insertSql,
					Statement.RETURN_GENERATED_KEYS);
				prepsInsertPerson.execute();
				// Retrieve the generated key from the insert.
				resultSet = prepsInsertPerson.getGeneratedKeys();
				// Print the ID of the inserted row.
				while (resultSet.next()) {
					System.out.println("Generated: " + resultSet.getString(1));
					}
			}
			catch (Exception e) {
				e.printStackTrace();
			}
			finally {
				// Close the connections after the data has been handled.
				if (prepsInsertPerson != null) try { prepsInsertPerson.close(); } catch(Exception e) {}
				if (resultSet != null) try { resultSet.close(); } catch(Exception e) {}
				if (statement != null) try { statement.close(); } catch(Exception e) {}
				if (connection != null) try { connection.close(); } catch(Exception e) {}
			}
		}
	}

@@ -93,22 +93,14 @@
 ass 
-SQLDatabaseTes
+connec
 t %7B%0A
@@ -307,16 +307,20 @@
 r_server
+name
 .databas
@@ -360,21 +360,22 @@
 ase=
-your_database
+AdventureWorks
 ;%22%0A%09
@@ -394,16 +394,20 @@
 our_user
+name
 @your_se
@@ -410,16 +410,20 @@
 r_server
+name
 ;%22%0A%09%09%09%09+
@@ -433,17 +433,16 @@
 assword=
-%7B
 your_pas
@@ -446,17 +446,16 @@
 password
-%7D
 ;%22%0A%09%09%09%09+
@@ -717,16 +717,48 @@
 = null;%0A
+%09%09%09ResultSet resultSet2 = null;%0A
 %09%09%09Prepa
@@ -782,21 +782,22 @@
 sInsertP
-erson
+roduct
  = null;
@@ -956,16 +956,23 @@
 %22SELECT 
+TOP 10 
 Title, F
@@ -984,20 +984,8 @@
 ame,
- MiddleName,
  Las
@@ -1273,39 +1273,8 @@
 g(3)
-%0A%09%09%09%09%09%09+ resultSet.getString(4)
 );%0A%09
@@ -1388,142 +1388,145 @@
 sLT.
-Customer (FirstName, LastName, CompanyName) VALUES %22%0A%09%09%09%09%09+ %22('Bill', 'Gates', 'Microsoft'), %22%0A%09%09%09%09%09+ %22('Steve', 'Ballmer', 'Microsoft
+Product (Name, ProductNumber, Color, StandardCost, ListPrice, SellStartDate) VALUES %22%0A%09%09%09%09%09+ %22('Bike', 'B1', 'Blue', 50, 120, '2016-01-01
 ');%22
@@ -1544,21 +1544,22 @@
 sInsertP
-erson
+roduct
  = conne
@@ -1653,21 +1653,22 @@
 sInsertP
-erson
+roduct
 .execute
@@ -1735,16 +1735,17 @@
 esultSet
+2
  = preps
@@ -1751,21 +1751,22 @@
 sInsertP
-erson
+roduct
 .getGene
@@ -1831,32 +1831,33 @@
 while (resultSet
+2
 .next()) %7B%0A%09%09%09%09%09
@@ -1892,32 +1892,33 @@
 d: %22 + resultSet
+2
 .getString(1));%0A
@@ -2079,21 +2079,22 @@
 sInsertP
-erson
+roduct
  != null
@@ -2117,13 +2117,90 @@
 ertP
-erson
+roduct.close(); %7D catch(Exception e) %7B%7D%0A%09%09%09%09if (resultSet != null) try %7B resultSet
 .clo
@@ -2238,32 +2238,33 @@
 %09%09%09if (resultSet
+2
  != null) try %7B 
@@ -2264,32 +2264,33 @@
  try %7B resultSet
+2
 .close(); %7D catc
@@ -2473,8 +2473,9 @@
 %0A%09%09%7D%0A%09%7D%0A
+%0A

Update sample_java.java