简体   繁体   中英

Not Fetching All Data From MySQL (java)

So I was writing a method that retrieves information on my updates in a game and so far it retrieved all the information needed for revision 1.0. I proceeded to input 1.1 and it came back with an empty string.

public String getRevision(float revision, String revisionName) {
    try {
        String txt = "\t\t\t\t\t\t\t#e---===Revision Log "+revision+"===---#n\r\n\r\n";
        Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT information FROM revisions_log WHERE revisionName = ? AND revision = ?");
        ps.setString(1,  revisionName);
        ps.setFloat(2, revision);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            txt += rs.getString("information") + "\r\n";
        }
        ps.close();
        rs.close();
        return txt;
    } catch (Exception e) {

    }
    return "No logs were found!";
}

The db in the database is set with a string for its revisionName and a float for its revisions. I also definitely updated the DB with the correct revision number as well.

Here:

DB的图像

Query:

SELECT information FROM maplesolaxia.revisions_log WHERE revisionName = "prealpha" AND revision = 1.1;

Running the SAME query but with 1.0 instead works.

Here's how my table is set up. 图片

这是一个奇怪的解决方案,但是我将“修订”的数据值从FLOAT更改为DECIMAL(3,1),并且似乎可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM