如何在sqljdbc4.jar

时间:2016-01-29 14:51:33

标签: java jdbc kerberos

有没有人可以解释我使用sqljdbc4.jar配置Java Kerberos。 因为我第二次运行应用程序时出错,显示错误 com.microsoft.sqlserver.jdbc.SQLServerException:集成身份验证失败

(注意 - 错误显示仅针对servlet项目发生。我使用apache tomcat)

有关于Kerberos的教程here。但我不明白如何将它包括在我的措词中。

    public Connection Get_connection(PrintWriter out)
{
try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url = "jdbc:sqlserver://localhost:1433; databaseName = Colombo_Health; integratedSecurity=true; authenticationScheme=JavaKerberos";
            con = DriverManager.getConnection(url,"","");
            out.println("Connection Established"); 
        }
        catch (ClassNotFoundException e) 
        {

         out.println("Class not Found       " +e.toString()); 
        }
        catch (Exception e) 
        {
         out.println("Driver not Found    "+e.toString());
        }

            return con;

}
  1. 我在使用SQL Server 2014的Windows 10上。
  2. 我已将sqljdbc_auth.dll复制到系统32

2 个答案:

答案 0 :(得分:0)

假设您提供的信息量很大,我认为错误在于不设置您的连接属性。添加con.setServerName(value)con.setDatabaseName(value)以及可能适用的Other Properties

答案 1 :(得分:0)

好像您使用了错误的 authenticationScheme 。通过指定 JavaKerberos ,您可以告诉客户端使用Kerberos的Java实现。如果要使用 sqljdbc_auth.dll 进行身份验证,则应使用 NativeAuthentication 作为身份验证方案。

相关问题