我正在尝试连接到我在 SQL sever 2008 中创建的本地数据库,但我已经尝试了所有方法,但出现了同样的错误,我在数据库资源管理器中连接,但需要从我的应用程序连接到数据库以注册页面和登录。这是我的错误:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (classFileParser.cpp:3470), pid=5644, tid=5492
# Error: ShouldNotReachHere()
#
# JRE version: 7.0-b147
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0-b17 mixed mode windows-amd64 compressed oops)
# 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:
# C:\Users\christiej\workspace\MainActivity\hs_err_pid5644.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
这是我的代码:
public class Example
{
public static void main (String[] args) throws SQLException, ClassNotFoundException{
Class.forName("com.sqlserver.jdbc.Driver"); // Setup the connection with the DB
Connection connect = DriverManager.getConnection("jdbc:sqlserver://192.168.0.13:1433/Risk_ProfilingV2","sa","Dsolve01#");
// Statements allow to issue SQL queries to the database
java.sql.Statement statement = connect.createStatement();
// Result set get the result of the SQL query
ResultSet resultSet = null;
try {
resultSet = statement.executeQuery("select * from User_Table");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (resultSet.next()) { //retrieve data
String data = resultSet.getString("User_Name");
}
}
}