【问题标题】:A fatal error has been detected by the Java Runtime Environment - Microsoft SQL ServerJava 运行时环境检测到致命错误 - Microsoft SQL Server
【发布时间】:2014-12-24 20:12:43
【问题描述】:

我有一个应该连接到 Microsoft SQL Server 的 Java 应用程序。我使用 JRE 1.8 和 sqljdbc4-2.0.jar。当我尝试运行时:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006f41dd27, pid=8404, tid=8960
#
# JRE version: Java(TM) SE Runtime Environment (8.0_25-b18) (build 1.8.0_25-b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V  [jvm.dll+0x5dd27]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions   of Windows
#
# An error report file with more information is saved as:
# D:\eclipse\workspace\Website\hs_err_pid8404.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

我在网上搜索了这个错误,但我找不到任何东西..

这是我使用的代码:

    try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
        String connectionUrl = "jdbc:sqlserver://localhost:1433;instance=SQLEXPRESS;databaseName=Mydatabase;integratedSecurity=true";
        con = DriverManager.getConnection(connectionUrl);
        System.out.println("Connected");
    } catch (ClassNotFoundException e) {
        throw new Exception("Driver Not Found");
    }

【问题讨论】:

  • 我们可以看看你的代码吗?我们不能告诉你任何事情。
  • 我添加了代码.. :)
  • 我猜你不能使用integratedSecurity=true。也许您应该寻找另一个 JDBC 驱动程序。
  • D:\eclipse\workspace\Website\hs_err_pid8404.log 是否显示任何其他信息?
  • 我建议改用jTDS JDBC Driver

标签: java sql-server fatal-error


【解决方案1】:

根据此站点Building the Connection URL,您的连接字符串可能有问题。

jdbc:sqlserver://localhost:1433;instance=SQLEXPRESS;databaseName=Mydatabase;integratedSecurity=true

应该是:

jdbc:sqlserver://localhost;instanceName=SQLEXPRESS;databaseName=Mydatabase;integratedSecurity=true

(注意instanceName,而不是instance)

还有……

为了获得最佳连接性能,您应该在连接到命名实例时设置 portNumber。这将避免往返服务器以确定端口号。 如果同时使用 portNumber 和 instanceName,则 portNumber 将优先,instanceName 将被忽略。

希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    相关资源
    最近更新 更多