بتاريخ: 27 نوفمبر 201510 سنة comment_268104 أنا عندي مشكلة عرض الصور المخزنة في قاعدة البيانات على صفحة ADF , استخدمت ShowImage Servlet لعمل ذلك ولكن للأسف الصور لاتظهر كود السيرفلت هو كالتالي : public class showImage extends HttpServlet { private static final String CONTENT_TYPE = "image/gif; charset=utf-8"; public void init(ServletConfig config) throws ServletException { super.init(config); } 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(); conn = getOracleConnection(); PreparedStatement statement = conn.prepareStatement("SELECT Employee_id,pic " + "FROM Employees " + "WHERE Employee_id = ?"); statement.setInt(1, new Integer(imageId)); ResultSet rs = statement.executeQuery(); if (rs.next()) { Blob blob = rs.getBlob("PIC"); 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, ; } os.close(); } } catch (Exception e) { System.out.println(e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException sqle) { System.out.println("SQLException error"); } } } public static Connection getOracleConnection() throws Exception { String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:xe"; String username = "hr"; String password = "hr"; Class.forName(driver); // load Oracle driver Connection conn = DriverManager.getConnection(url, username, password); return conn; } } تقديم بلاغ
بتاريخ: 28 نوفمبر 201510 سنة كاتب الموضوع comment_268108 الصورة لاتظهر في الصفحة مع أني عدلت على خاصية source تقديم بلاغ
بتاريخ: 28 نوفمبر 201510 سنة كاتب الموضوع comment_268109 شكرًا مهندس ماجد هل ممكن أرسل المثال اللي عملته على الايميل علما بانه على إسكيمة HR فقط أضفت عمودين pic و notes على جدول الموظفين تقديم بلاغ
بتاريخ: 28 نوفمبر 201510 سنة comment_268118 wedada imageId تم تعريفه بالأعلى على أنه String إذن الخطأ في السطر التالي لم تتعامل معه كـ String statement.setInt(1, new Integer(imageId)); الصحيح هو statement.setString(1,(imageId)); تأكدت من الكود بعد التعديل الذي ذكرته أعلاه وتم التفيذ عندي بشكل صحيح تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.