{"id":2158,"date":"2023-12-20T09:51:32","date_gmt":"2023-12-20T14:51:32","guid":{"rendered":"https:\/\/csimmons.dev\/blog\/?p=2158"},"modified":"2024-12-05T20:09:30","modified_gmt":"2024-12-06T01:09:30","slug":"how-to-use-the-microsoft-jdbc-driver-for-sql-server-in-coldfusion","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2023\/12\/how-to-use-the-microsoft-jdbc-driver-for-sql-server-in-coldfusion\/","title":{"rendered":"How to use the Microsoft JDBC Driver for SQL Server in ColdFusion"},"content":{"rendered":"<p>I recently had an issue where the datasources using the Microsoft SQL Server Driver in ColdFusion were failing.  The error was:<\/p>\n<p><code>java.sql.SQLException: Timed out trying to establish connection<\/code><\/p>\n<p>There was no change with the database server.  For some reason the driver was just not connecting.  This led to an exploration of connecting using JDBC both with the Adobe jar included with ColdFusion and by downloading the Microsoft JDBC Driver for SQL Server.<\/p>\n<h2>Using the Microsoft JDBC Driver for SQL Server<\/h2>\n<p>First you must obtain the driver and make it available to ColdFusion:<\/p>\n<ul>\n<li>Download Microsoft JDBC Driver for SQL Server from: <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/connect\/jdbc\/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16\" target=\"_blank\" rel=\"noopener\">https:\/\/learn.microsoft.com\/en-us\/sql\/connect\/jdbc\/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16<\/a><\/li>\n<li>Unzip the download and place the driver jar(s) into the following directory on the server (for Windows): <code>C:\\ColdFusion2021\\cfusion\\lib<\/code><\/li>\n<li>Restart the ColdFusion service<\/li>\n<\/ul>\n<p>To create a JDBC data source to connect to an MS SQL Server database in ColdFusion:<\/p>\n<ul>\n<li>Login to CFADMIN<\/li>\n<li>Navigate to the Data &amp; Services tab in CFADMIN<\/li>\n<li>Enter a Datasource Name: <code>developmentServerJDBC<\/code><\/li>\n<li>For Driver choose: <code>Other<\/code><\/li>\n<li>Click: <code>Add<\/code><\/li>\n<\/ul>\n<p>On the ensuing page enter the additional information (change to your info):<\/p>\n<ul>\n<li>CF Data Source Name: <code>developmentServerJDBC<\/code><\/li>\n<li>JDBC URL: <code>jdbc:sqlserver:\/\/developmentServer:databaseName=developmentDatabase;Port=1433;encrypt=false;<\/code><\/li>\n<li>Driver Class: <code>com.microsoft.sqlserver.jdbc.SQLServerDriver<\/code><\/li>\n<li>Driver Name: <code>mssql-jdbc<\/code><\/li>\n<li>User name: <code>developmentUser<\/code><\/li>\n<li>Password: <code>************<\/code><\/li>\n<li>Description (optional): <code>Uses Microsoft jar file<\/code><\/li>\n<\/ul>\n<h2>Using ColdFusion\u2019s Microsoft SQL Server Driver<\/h2>\n<p>To create a data source to connect to an MS SQL Server database in ColdFusion:<\/p>\n<ul>\n<li>Login to CFADMIN<\/li>\n<li>Navigate to the Data &amp; Services tab in CFADMIN<\/li>\n<li>Enter a Datasource Name: <code>developmentServer<\/code><\/li>\n<li>For Driver choose: <code>Microsoft SQL Server<\/code><\/li>\n<li>Click: <code>Add<\/code><\/li>\n<\/ul>\n<p>On the ensuing page enter the additional information (change to your info):<\/p>\n<ul>\n<li>CF Data Source Name: <code>developmentServer<\/code><\/li>\n<li>Database: <code>developmentDatabase<\/code><\/li>\n<li>Server: <code>developmentServer<\/code><\/li>\n<li>Port <code>1433<\/code><\/li>\n<li>User name: <code>developmentUser<\/code><\/li>\n<li>Password: <code>************<\/code><\/li>\n<li>Description (optional): <code>Uses ColdFusion's Microsoft SQL Server Driver<\/code><\/li>\n<\/ul>\n<h2>BONUS: Using ColdFusion\u2019s Microsoft SQL Server Driver with JDBC<\/h2>\n<p>To create a JDBC data source to connect to an MS SQL Server database in ColdFusion:<\/p>\n<ul>\n<li>Login to CFADMIN<\/li>\n<li>Navigate to the Data &amp; Services tab in CFADMIN<\/li>\n<li>Enter a Datasource Name: <code>developmentServerMicrosoftJDBC<\/code><\/li>\n<li>For Driver choose: <code>Other<\/code><\/li>\n<li>Click: <code>Add<\/code><\/li>\n<\/ul>\n<p>On the ensuing page enter the additional information (change to your info):<\/p>\n<ul>\n<li>CF Data Source Name: <code>developmentServerMicrosoftJDBC<\/code><\/li>\n<li>JDBC URL: <code>jdbc:sqlserver:\/\/developmentServer:databaseName=developmentDatabase;Port=1433;encrypt=false;<\/code><\/li>\n<li>Driver Class: <code>macromedia.jdbc.MacromediaDriver<\/code><\/li>\n<li>Driver Name: <code>macromedia-jdbc<\/code><\/li>\n<li>User name: <code>developmentUser<\/code><\/li>\n<li>Password: <code>************<\/code><\/li>\n<li>Description (optional): <code>Uses Adobe jar file<\/code><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I recently had an issue where the datasources using the Microsoft SQL Server Driver in ColdFusion were failing. The error was: java.sql.SQLException: Timed out trying to establish connection There was no change with the database server. For some reason the driver was just not connecting. This led to an exploration of connecting using JDBC both &#8230; <a title=\"How to use the Microsoft JDBC Driver for SQL Server in ColdFusion\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2023\/12\/how-to-use-the-microsoft-jdbc-driver-for-sql-server-in-coldfusion\/\" aria-label=\"Read more about How to use the Microsoft JDBC Driver for SQL Server in ColdFusion\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[48,12],"class_list":["post-2158","post","type-post","status-publish","format-standard","hentry","category-developer","tag-coldfusion","tag-developer"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-yO","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/2158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=2158"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/2158\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=2158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=2158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=2158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}