Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在数据库中显示存储为blob的图像?_Java_Mysql_Jsp - Fatal编程技术网

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数据类型

可能的重复: