0
votes

My jdbc connection failes when using this code:

package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author Li.Kudo
 * @version 1.0
 * @since 2015
 */
public class DatabaseConnection {

    private String connectionString;
    private Connection connection;

    public String getConnectionString() {
        return connectionString;
    }

    public void setConnectionString(String connectionString) {
        this.connectionString = connectionString;
    }

    public Connection getConnection() {
        return connection;
    }

    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    /**
     * @return boolean
     * @exception sql exception
     * @author Li.Kudo
     */
    public boolean makeConnection() {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            this.connection = DriverManager.getConnection(connectionString);
            return true;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return false;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static void main(String[] args) {
        DatabaseConnection a=new DatabaseConnection();
        a.setConnectionString("jdbc:sqlserver://localhost;integratedSecurity=true;");
        a.makeConnection();
        System.out.println(a.getConnection());
    }
}

Here's the error I get:

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006e17d115, pid=4296, tid=5312

JRE version: Java(TM) SE Runtime Environment (8.0_66-b18) (build 1.8.0_66-b18) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b18 mixed mode windows-amd64 compressed oops) Problematic frame: V [jvm.dll+0x13d115]

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: E:\Java\Project_App\BTL_CNPM\hs_err_pid4296.log

If you would like to submit a bug report, please visit: http://bugreport.java.com/bugreport/crash.jsp

1
You have correct version of auth dll in your java.library.path? Where do you have it, which version did you use, how is java.library.path set? - Jan
Check the JDBC library version whether it is compatible with your JVM version - S.K. Venkat

1 Answers

-1
votes

This error happens on the native part of the JVM. Some .dll file is corrupted i guess. Reinstall the fresh virtual machine may help you to get out of this...