Java运行时环境 - Microsoft SQL Server检测到致命错误

时间:2014-12-24 20:12:43

标签: java sql-server fatal-error

我在java中有一个应该连接到Microsoft SQL Server的应用程序..我使用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
#

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

这是我使用的代码:

    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");
    }

1 个答案:

答案 0 :(得分:0)

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

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

应该是:

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

(注意instanceName,而不是实例)

另外....

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

希望有所帮助