From 8117c045901625773df726ad69266c49c5ab1fdb Mon Sep 17 00:00:00 2001 From: Andrea Lam Date: Fri, 18 Nov 2016 12:39:56 -0800 Subject: [PATCH] Add README for main Java and Node.js folders --- samples/tutorials/java/README.md | 23 ++++------- samples/tutorials/java/connect.java | 60 ----------------------------- samples/tutorials/node.js/README.md | 10 ++++- 3 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 samples/tutorials/java/connect.java diff --git a/samples/tutorials/java/README.md b/samples/tutorials/java/README.md index cbec597a..320c8c84 100644 --- a/samples/tutorials/java/README.md +++ b/samples/tutorials/java/README.md @@ -1,18 +1,9 @@ -# Connect to SQL Database by using Java with JDBC on Windows +# Developing applications with Java and SQL Server -[Java code sample] (sample_java.java) that you can use to connect to Azure SQL Database. The Java sample relies on the Java Development Kit (JDK) version 8. The sample connects to an Azure SQL Database by using the JDBC driver. +Pick a platform below to get started: +* [macOS](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/java/macos) +* [RHEL](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/java/rhel) +* [Ubuntu](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/java/ubuntu) +* [Windows](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/java/windows) - -## Requirements - - -- [Microsoft JDBC Driver for SQL Server - SQL JDBC 6.0](http://www.microsoft.com/download/details.aspx?displaylang=en&id=11774). - - Download the latest JDBC Driver 6.0 Package *sqljdbc_6.0.7507.100_enu.exe* OR *sqljdbc_6.0.7507.100_enu.tar.gz* - - For guidance on which jar file to use based on your Java version, please see the [System Requirements for the JDBC Driver](https://msdn.microsoft.com/en-us/library/ms378422(v=sql.110).aspx) -- Any operating system platform that runs [Java Development Kit 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). -- An existing database on SQL Azure. See the [Get Started topic](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and retrieve your connection string. - - -## Create a database, retrieve your connection string - -The Java sample relies on the AdventureWorks sample database. If you do not already have AdventureWorks, you can see how to create it at the following topic: [Create your first Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) +Please visit our [getting started tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/) \ No newline at end of file diff --git a/samples/tutorials/java/connect.java b/samples/tutorials/java/connect.java deleted file mode 100644 index 728ecd18..00000000 --- a/samples/tutorials/java/connect.java +++ /dev/null @@ -1,60 +0,0 @@ -// Use the JDBC driver -import java.math.BigDecimal; -import java.sql.*; -import java.time.LocalDate; - -public class connect { - - // Connect to your database. - // Replace server name, username, and password with your credentials - public static void main(String[] args) throws SQLException { - String connectionString = - "jdbc:;" - + "database=;" - + "user=;" - + "password=;" - + "encrypt=true;" - + "trustServerCertificate=false;" - + "loginTimeout=30;"; - - try (Connection connection = DriverManager.getConnection(connectionString)) { - - // Create and execute a SELECT SQL statement. - String selectSql = "SELECT TOP 10 Title, FirstName, LastName from SalesLT.Customer"; - try (Statement statement = connection.createStatement(); - ResultSet resultSet = statement.executeQuery(selectSql)) { - - // Print results from select statement - while (resultSet.next()) { - System.out.println(resultSet.getString(2) + " " - + resultSet.getString(3)); - } - } - - // Create and execute an INSERT SQL prepared statement. - String insertSql = "INSERT INTO SalesLT.Product (Name, ProductNumber, Color, StandardCost, ListPrice, SellStartDate) VALUES " - + "(?, ?, ?, ?, ?, ?);"; - - try (PreparedStatement prepsInsertProduct = connection.prepareStatement( - insertSql, - Statement.RETURN_GENERATED_KEYS)) { - - prepsInsertProduct.setString(1, "Bike"); - prepsInsertProduct.setString(2, "B1"); - prepsInsertProduct.setString(3, "Blue"); - prepsInsertProduct.setBigDecimal(4, new BigDecimal(50)); - prepsInsertProduct.setBigDecimal(5, new BigDecimal(120)); - prepsInsertProduct.setObject(6, LocalDate.of(2016, 1, 1).atStartOfDay()); - prepsInsertProduct.executeUpdate(); - // Retrieve the generated key from the insert. - try (ResultSet generatedKeys = prepsInsertProduct.getGeneratedKeys()) { - // Print the ID of the inserted row. - while (generatedKeys.next()) { - System.out.println("Generated: " + generatedKeys.getString(1)); - } - } - } - } - } -} - diff --git a/samples/tutorials/node.js/README.md b/samples/tutorials/node.js/README.md index 1928789e..5a4c18b5 100644 --- a/samples/tutorials/node.js/README.md +++ b/samples/tutorials/node.js/README.md @@ -1,3 +1,9 @@ -# Node.js samples +# Developing applications with Node.js and SQL Server -Simple Node.js applications to connect to Microsoft SQL databases, including SQL Server, Azure SQL Database, and Azure SQL Data Warehouse. Samples for operating systems including Linux, Windows, and macOS. +Pick a platform below to get started: +* [macOS](https://github.com/Microsoft/sql-server-samples/blob/master/samples/tutorials/node.js/macos) +* [RHEL](https://github.com/Microsoft/sql-server-samples/blob/master/samples/tutorials/node.js/rhel) +* [Ubuntu](https://github.com/Microsoft/sql-server-samples/blob/master/samples/tutorials/node.js/java/ubuntu) +* [Windows](https://github.com/Microsoft/sql-server-samples/blob/master/samples/tutorials/node.js/windows) + +Please visit our [getting started tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/) \ No newline at end of file