{"id":1879,"date":"2012-01-31T12:04:05","date_gmt":"2012-01-31T17:04:05","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=1879"},"modified":"2012-02-01T10:18:24","modified_gmt":"2012-02-01T15:18:24","slug":"connecting-to-sql-server-using-internal-authentication","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2012\/01\/31\/connecting-to-sql-server-using-internal-authentication\/","title":{"rendered":"Connecting to SQL Server using internal authentication"},"content":{"rendered":"<p>We use java for a lot of our jobs, and using it to access SQL Server is no exception.  We wanted to have controlled access, and avoid &#8220;user sprawl&#8221; across servers.  As such, we use Windows authentication from our java programs.  Below is an example:<\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport java.sql.*;\r\nimport com.microsoft.sqlserver.jdbc.*;\r\n\r\npublic class connSqlServer {\r\n  public static void main(String[] args) {\r\n    try {\r\n      Connection con = DriverManager.getConnection(\"jdbc:sqlserver:\/\/STSQL01.fake_domain:1433;databaseName=MSDB;integratedSecurity=true;\");\r\n      Statement stm = con.createStatement();\r\n      ResultSet rst = stm.executeQuery(\"select * from msdb.dbo.backupset\");\r\n      while (rst.next()) {\r\n        System.out.println(rst.getString(\"database_name\"));\r\n      }\r\n    }\r\n    catch (Exception e) {\r\n      e.printStackTrace();\r\n    }\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We use java for a lot of our jobs, and using it to access SQL Server is no exception. We wanted to have controlled access, and avoid &#8220;user sprawl&#8221; across servers. As such, we use Windows authentication from our java&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2012\/01\/31\/connecting-to-sql-server-using-internal-authentication\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,34],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1879"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1879"}],"version-history":[{"count":5,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1879\/revisions"}],"predecessor-version":[{"id":1884,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1879\/revisions\/1884"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1879"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}