[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 1.8. The sample connects to an Azure SQL Database by using the JDBC driver.
- Microsoft JDBC Driver for SQL Server - SQL JDBC 4.
- Any operating system platform that runs Java Development Kit 1.8.
- An existing database on SQL Azure. See the Get Started topic to learn how to create a sample database and retrieve your connection string.
The Java code example in this topic assumes the following test table already exists in your Azure SQL Database database.
CREATE TABLE Person
(
id INT PRIMARY KEY IDENTITY(1,1),
firstName VARCHAR(32),
lastName VARCHAR(32),
age INT
);
The code sample creates a Connection object by using a connection string. You can find the connection string by using the Azure preview portal. For details about finding the connection string, see Create your first Azure SQL Database.