D
D
ddddd tttt2017-01-02 12:54:13
Java
ddddd tttt, 2017-01-02 12:54:13

How to get images from MSSQL DB in ImageView?

void tableSelectPhoto(ResultSet r)
    {
        try {
           if(r.next()) {
               Blob bl = r.getBlob(1);
               InputStream inputStream = bl.getBinaryStream();
               Image image = new Image(inputStream);
               imageView.setImage(image);
           }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

If you receive images like this, then the imageView is empty. How to get an image correctly?
The image shows a query in MSSQL.
a5f65db9f7ca49d8880c75dc874e81c3.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
al_gon, 2017-01-02
@pashaa

www.java2s.com/Code/Java/Database-SQL-JDBC/ReadBLO...

D
d-stream, 2017-01-02
@d-stream

Just byte[] image

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question