2013-01-03 192 views
-1

我想连接到我在SQL服务器2008中创建的本地数据库,但我已经尝试了一切,但出现同样的错误,我在数据库浏览器中进行了连接,但需要从我的应用程序连接到注册页面登录。这是我的错误:不能连接JDBC到SQL服务器?

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

     } 
} 

}

+0

清理项目,右键单击项目,然后点击Runas选项,然后选择你的项目类型..我希望它能解决问题.. –

+0

什么是Android标签? – njzk2

+0

升级到Java 7更新10并重试。 –

回答