<pre name="code" class="java">public static String getJoke() {
String jokeContent = "";
String sql = "select m_joke_content from m_joke order by rand() limit 0,1";
MySQLUtil mysqlUtil = new MySQLUtil();
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = mysqlUtil.getConn();
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
if (rs.next()) {
jokeContent = rs.getString("m_joke_content");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 释放资源
mysqlUtil.releaseResources(conn, ps, rs);
}
return jokeContent;
}
1111
最新推荐文章于 2021-08-19 21:07:47 发布