Java 在转盘项目中显示图像
我正在使用ADF,需要在旋转木马中显示图像。我们已经在servlet中编写了以下代码,但在页面加载时,它会分配值weblogic.jdbc.wrapper.Blob\u oracle\u sql_BLOB@xxx xxx-如果数据库中存在用于获取特定记录的图像,则blob对象的某些字母数字值 链接已提交-Java 在转盘项目中显示图像,java,blob,carousel,oracle-adf,binarystream,Java,Blob,Carousel,Oracle Adf,Binarystream,我正在使用ADF,需要在旋转木马中显示图像。我们已经在servlet中编写了以下代码,但在页面加载时,它会分配值weblogic.jdbc.wrapper.Blob\u oracle\u sql_BLOB@xxx xxx-如果数据库中存在用于获取特定记录的图像,则blob对象的某些字母数字值 链接已提交- 如果您使用的是数据源,而Weblogic Server中的配置正在包装数据类型,则可能会出现问题 在浏览器中打开Weblogic Server管理控制台服务器:端口/控制台 转到服务->数据源
如果您使用的是数据源,而Weblogic Server中的配置正在包装数据类型,则可能会出现问题 在浏览器中打开Weblogic Server管理控制台服务器:端口/控制台 转到服务->数据源->数据源->连接轮询->高级 取消选中属性包装数据类型 希望对你有帮助
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
String imageId = request.getParameter("id");
OutputStream os = response.getOutputStream();
Connection conn = null;
try {
Context ctx = new InitialContext();
//Datasource as defined in <res-ref-name> element of weblogic.xml
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/HrXEDS");
conn = ds.getConnection();
PreparedStatement statement =
conn.prepareStatement("SELECT image_id, image_blob " +
"FROM hr_image_table " +
"WHERE image_id = ?");
statement.setInt(1, new Integer(imageId));
ResultSet rs = statement.executeQuery();
if (rs.next()) {
Blob blob = rs.getBlob("IMAGE_BLOB");
System.out.println("-- blob --" + blob);
BufferedInputStream in =
new BufferedInputStream(blob.getBinaryStream());
int b;
byte[] buffer = new byte[10240];
while ((b = in.read(buffer, 0, 10240)) != -1) {
os.write(buffer, 0, b);
}
os.close();
}
} catch (Exception e) {
System.out.println(e);
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException sqle) {
System.out.println("SQLException error");
}
}
}