{"id":13671,"date":"2015-07-01T10:00:00","date_gmt":"2015-07-01T17:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/dataplatforminsider\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/"},"modified":"2024-01-22T22:50:14","modified_gmt":"2024-01-23T06:50:14","slug":"preview-the-new-jdbc-4-2-for-sql-server-driver","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/","title":{"rendered":"Preview the new JDBC 4.2 for SQL Server Driver"},"content":{"rendered":"

Today we are pleased to announce availability of the Community Technology Preview (CTP) of the Microsoft JDBC 4.2 Driver for SQL Server<\/a>! The driver provides robust data access to Microsoft SQL Server and Microsoft Azure SQL Database for Java-based applications.<\/p>\n

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. <\/b>There are several additional enhancements available with the driver.\u00a0 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.<\/p>\n

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.\u00a0 The sample code below illustrates how the new class works:<\/p>\n

\/\/ Obtain data from the source by connecting and loading it into a ResultSet<\/span><\/p>\n

Connection sourceConnection = DriverManager.getConnection<\/i>(connectionUrl);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

String SQL = “SELECT * FROM SourceTable”;<\/span><\/p>\n

Statement stmt = sourceConnection.createStatement();<\/span><\/p>\n

ResultSet resultSet = stmt.executeQuery(SQL);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

\/\/ Prepare for SQL Bulk Copy Operation<\/span><\/p>\n

Connection destConnection = DriverManager.getConnection<\/i>(connectionUrl);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

\/\/ Default options are shown here<\/span><\/p>\n

SQLServerBulkCopyOptions options = new<\/b> SQLServerBulkCopyOptions();<\/span><\/p>\n

options.setBatchSize(0);<\/span><\/p>\n

options.setBulkCopyTimeout(30);<\/span><\/p>\n

options.setCheckConstraints(false<\/b>);<\/span><\/p>\n

options.setFireTriggers(false<\/b>);<\/span><\/p>\n

options.setKeepIdentity(false<\/b>);<\/span><\/p>\n

options.setKeepNulls(false<\/b>);<\/span><\/p>\n

options.setTableLock(true<\/b>);<\/span><\/p>\n

options.setUseInternalTransaction(false<\/b>);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

SQLServerBulkCopy operation = new<\/b> SQLServerBulkCopy(destConnection, options);<\/span><\/p>\n

operation.setDestinationTableName(“DestinationTable”);<\/span><\/p>\n

operation.addColumnMapping(1, 1);<\/span><\/p>\n

operation.addColumnMapping(2, “test2”);<\/span><\/p>\n

operation.addColumnMapping(“test3”, 3);<\/span><\/p>\n

operation.addColumnMapping(“test4”, “test4”);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

\/\/ Perform the copy<\/span><\/p>\n

operation.writeToServer(resultSet);<\/span><\/p>\n

\u00a0<\/span><\/p>\n

\/\/ Finished<\/span><\/p>\n

operation.close();<\/span><\/p>\n

For more details about what is currently supported in the bulk copy feature preview, please refer to What\u2019s New in the JDBC driver<\/a>.<\/p>\n

The JDBC driver is part of SQL Server and the Microsoft Data Platform\u2019s wider interoperability program, with drivers for PHP 5.6<\/a>, Node.js<\/a>,\u00a0JDBC<\/a>, ODBC and ADO.NET already available.\u00a0<\/p>\n

You can download the JDBC 4.2 driver preview <\/strong>here<\/a>.\u00a0 <\/strong>We invite you to explore the latest the Microsoft Data Platform has to offer via a trial of Microsoft Azure SQL Database<\/a> <\/strong>or by trying the new SQL Server 2016 CTP<\/a>. We look forward to hearing your feedback about the new driver. Let us know what you think on Microsoft Connect<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

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.<\/p>\n","protected":false},"author":1457,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","footnotes":""},"post_tag":[],"product":[],"content-type":[2448],"topic":[],"coauthors":[2487],"class_list":["post-13671","post","type-post","status-publish","format-standard","hentry","content-type-updates"],"yoast_head":"\nPreview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Preview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog\" \/>\n<meta property=\"og:description\" content=\"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.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft SQL Server Blog\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/sqlserver\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-01T17:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-23T06:50:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2018\/08\/cropped-microsoft_logo_element.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"SQL Server Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SQLServer\" \/>\n<meta name=\"twitter:site\" content=\"@SQLServer\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SQL Server Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 min read\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\"},\"author\":[{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/author\/sql-server-team\/\",\"@type\":\"Person\",\"@name\":\"SQL Server Team\"}],\"headline\":\"Preview the new JDBC 4.2 for SQL Server Driver\",\"datePublished\":\"2015-07-01T17:00:00+00:00\",\"dateModified\":\"2024-01-23T06:50:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\"},\"wordCount\":387,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\",\"name\":\"Preview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#website\"},\"datePublished\":\"2015-07-01T17:00:00+00:00\",\"dateModified\":\"2024-01-23T06:50:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Preview the new JDBC 4.2 for SQL Server Driver\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#website\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/\",\"name\":\"Microsoft SQL Server Blog\",\"description\":\"Official News from Microsoft\u2019s Information Platform\",\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization\",\"name\":\"Microsoft SQL Server Blog\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png\",\"width\":259,\"height\":194,\"caption\":\"Microsoft SQL Server Blog\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"http:\/\/www.facebook.com\/sqlserver\",\"https:\/\/x.com\/SQLServer\",\"https:\/\/www.youtube.com\/user\/MSCloudOS\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Preview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/","og_locale":"en_US","og_type":"article","og_title":"Preview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog","og_description":"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.","og_url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/","og_site_name":"Microsoft SQL Server Blog","article_publisher":"http:\/\/www.facebook.com\/sqlserver","article_published_time":"2015-07-01T17:00:00+00:00","article_modified_time":"2024-01-23T06:50:14+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2018\/08\/cropped-microsoft_logo_element.png","type":"image\/png"}],"author":"SQL Server Team","twitter_card":"summary_large_image","twitter_creator":"@SQLServer","twitter_site":"@SQLServer","twitter_misc":{"Written by":"SQL Server Team","Est. reading time":"2 min read"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#article","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/"},"author":[{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/author\/sql-server-team\/","@type":"Person","@name":"SQL Server Team"}],"headline":"Preview the new JDBC 4.2 for SQL Server Driver","datePublished":"2015-07-01T17:00:00+00:00","dateModified":"2024-01-23T06:50:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/"},"wordCount":387,"commentCount":1,"publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/","url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/","name":"Preview the new JDBC 4.2 for SQL Server Driver - Microsoft SQL Server Blog","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#website"},"datePublished":"2015-07-01T17:00:00+00:00","dateModified":"2024-01-23T06:50:14+00:00","breadcrumb":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/07\/01\/preview-the-new-jdbc-4-2-for-sql-server-driver\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/"},{"@type":"ListItem","position":2,"name":"Preview the new JDBC 4.2 for SQL Server Driver"}]},{"@type":"WebSite","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#website","url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/","name":"Microsoft SQL Server Blog","description":"Official News from Microsoft\u2019s Information Platform","publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#organization","name":"Microsoft SQL Server Blog","url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png","contentUrl":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-content\/uploads\/2019\/08\/Microsoft-Logo.png","width":259,"height":194,"caption":"Microsoft SQL Server Blog"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/#\/schema\/logo\/image\/"},"sameAs":["http:\/\/www.facebook.com\/sqlserver","https:\/\/x.com\/SQLServer","https:\/\/www.youtube.com\/user\/MSCloudOS"]}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/posts\/13671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/users\/1457"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/comments?post=13671"}],"version-history":[{"count":0,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/posts\/13671\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/media?parent=13671"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/post_tag?post=13671"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/product?post=13671"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/content-type?post=13671"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/topic?post=13671"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/wp-json\/wp\/v2\/coauthors?post=13671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}