Preview the new JDBC 4.2 for SQL Server Driver
From Data Platform Blog:
Today we are pleased to announce availability of the Community Technology Preview (CTP) of the Microsoft JDBC 4.2 Driver for SQL Server! The driver provides robust data access to Microsoft SQL Server and Microsoft Azure SQL Database for Java-based applications.
The JDBC Driver for SQL Server is a Java Database Connectivity (JDBC) type 4 driver that implements full compliance with the JDBC specifications 4.1 and 4.2 and supports Java Development Kit (JDK) version 1.8. There are several additional enhancements available with the driver. The updated XA Transaction feature includes new timeout options for automatic rollback of unprepared transactions. And, the new SQLServerBulkCopy class enables developers to quickly copy large amounts of data into tables or views in SQL Server and Azure SQL Database databases from other databases.
To use the SQLServerBulkCopy class, the basic flow is: connect to the source, then connect to the destination SQL Server or Azure SQL Database, create the SQLServerBulkCopy object and call WriteToServer. The sample code below illustrates how the new class works:
// Obtain data from the source by connecting and loading it into a ResultSet
Connection sourceConnection = DriverManager.getConnection(connectionUrl);
String SQL = “SELECT * FROM SourceTable”;
Statement stmt = sourceConnection.createStatement();
ResultSet resultSet = stmt.executeQuery(SQL);
// Prepare for SQL Bulk Copy Operation
Connection destConnection = DriverManager.getConnection(connectionUrl);
// Default options are shown here
SQLServerBulkCopyOptions options = new SQLServerBulkCopyOptions();
SQLServerBulkCopy operation = new SQLServerBulkCopy(destConnection, options);
// Perform the copy
For more details about what is currently supported in the bulk copy feature preview, please refer to What’s New in the JDBC driver.
You can download the JDBC 4.2 driver preview here. We invite you to explore the latest the Microsoft Data Platform has to offer via a trial of Microsoft Azure SQL Database or by trying the new SQL Server 2016 CTP. We look forward to hearing your feedback about the new driver. Let us know what you think on Microsoft Connect.
Source: Data Platform Insiders