-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");
}
}
}
清理項目,右鍵單擊項目,然後點擊Runas選項,然後選擇你的項目類型..我希望它能解決問題.. –
什麼是Android標籤? – njzk2
升級到Java 7更新10並重試。 –