Java 如何在数据库中显示存储为blob的图像?
这是我的数据库数据检索代码,这只能检索字符串数据,但我也想显示图像。怎么做Java 如何在数据库中显示存储为blob的图像?,java,mysql,jsp,Java,Mysql,Jsp,这是我的数据库数据检索代码,这只能检索字符串数据,但我也想显示图像。怎么做 <% try { connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/distributed","root",""); statement = connection.createStatement(); String sql = "s
<%
try {
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/distributed","root","");
statement = connection.createStatement();
String sql = "select * from product where id = '1'";
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
%>
<h3><%=resultSet.getString("name")%></h3>
<%=resultSet.getString("cost")%>
<%=resultSet.getString("description")%>
<%
}
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
如果数据库中有用于存储图像和音频等文件的字段。您应该使用BLOB数据类型 可能的重复: