0
我的Java插件出現問題 - 當沒有找到結果時說它結果集是空的。有人能告訴我如何檢測結果集是否爲空?空的結果集非法操作 - 如何檢查它是否爲空?
String url = "jdbc:mysql://" + host + ":" + port + "/" + database + "";
Connection conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement();
ResultSet rs;
String p = pp.getName();
rs = stmt.executeQuery("SELECT * FROM " + table + " WHERE username='"
+ p + "' AND recieved=0 ORDER BY id DESC");
rs = stmt.getResultSet();
有什麼確切的問題?你如何使用'ResultSet'? – 2013-04-06 12:54:26
請參閱:http://sscce.org/並將您的文章更新爲更易於理解的問題。 – xQuare 2013-04-06 12:57:18
那是我的代碼: String url =「jdbc:mysql://」+ host +「:」+ port +「/」+ database +「」; Connection conn = DriverManager.getConnection(url,username,password); Statement stmt = conn.createStatement(); ResultSet rs; String p = pp.getName(); rs = stmt.executeQuery(「SELECT * FROM」+ table +「WHERE username ='」+ p +「'AND recieved = 0 ORDER BY id DESC」); – 2013-04-06 12:58:24