使用此代码时,我的jdbc连接失败:
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());
}
}
这是我得到的错误:
Java Runtime Environment检测到致命错误:
EXCEPTION_ACCESS_VIOLATION(0xc0000005)at pc = 0x000000006e17d115,pid = 4296,tid = 5312
JRE版本:Java(TM)SE运行时环境(8.0_66-b18)(版本1.8.0_66-b18) Java VM:Java HotSpot(TM)64位服务器VM(25.66-b18混合模式windows-amd64压缩oops) 有问题的框架: V [jvm.dll + 0x13d115]
无法编写核心转储。默认情况下,在Windows的客户端版本
上未启用小型转储包含更多信息的错误报告文件保存为: E:\爪哇\ Project_App \ BTL_CNPM \ hs_err_pid4296.log
如果您想提交错误报告,请访问: http://bugreport.java.com/bugreport/crash.jsp
答案 0 :(得分:-1)
此错误发生在JVM的本机部分。我想有些.dll文件已损坏。重新安装新的虚拟机可能会帮助您摆脱这个......