Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:48:13+00:00 2026-06-15T17:48:13+00:00

I have a desktop programm and I must to save image files with different

  • 0

I have a desktop programm and I must to save image files with different formats and different sizes in db. Any idea how can I do that? anyone can help me, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:48:15+00:00Added an answer on June 15, 2026 at 5:48 pm

    You can Save Image into Database by Converting it into binary as follow:

    public void saveImage(File file){
            try {
                String img_id=JOptionPane.showInputDialog("Enter Image ID");
                FileInputStream fis=null;
                String query="insert into image(image_id,image) values (?,?)";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con=DriverManager.getConnection("jdbc:odbc:image");
                PreparedStatement pstm=con.prepareStatement(query);
                fis=new FileInputStream(file);
                pstm.setString(1, img_id);       
                pstm.setBinaryStream(2, (InputStream)fis, (int)file.length());
                pstm.executeUpdate();
                JOptionPane.showMessageDialog(null, "Image Successfully Uploaded to Database");
                pstm.close();
                con.close();
    
            } catch (Exception ex) {
                System.out.println("Exception Occured: "+ex);
            }
        }
    

    And Retrieve it by again making Image from binary and Save it on some physical Location:

    public void getSavedImages(){
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:image");
                PreparedStatement pstm1 = con.prepareStatement("select * from image");
                ResultSet rs1 = pstm1.executeQuery();
                while(rs1.next()) {
                    InputStream fis1;
                    FileOutputStream fos;
                    String image_id;
                    try {
                        fis1 = rs1.getBinaryStream("image");
                        image_id=rs1.getString("image_id");
                        fos = new FileOutputStream(new File(Path to "C:\\" + (image_id) + "Your Extension(.jpg/.gif)"));
                        int c;
                        while ((c = fis1.read()) != -1) {
                            fos.write(c);
                        }
                        fis1.close();
                        fos.close();
    
                    } catch (Exception ex) {
                        System.out.println(ex);
                    }
                } 
                pstm1.close();
                con.close();
            } catch (Exception ex) {
                System.out.println("Exception Occured:"+ex);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a desktop app that has 65 modules, about half of which read
I have a desktop application that will 'sync' with an iPhone application. The sync
I have a desktop written with Winforms. Now I have requests that people want
I have a desktop application that needs to upload/download images to/from service computer over
I have a .NET Compact Framework app that can runs on three windows machines
I was shocked to learn that OpenMosix is closed . Can you suggest any
I have C# desktop application that loads plugins. the format it loads the plugins
Scenario: I have a WPF desktop application which will be distributed on different machines
Background I have a business idea, one component of which involves a client that
I am writing a desktop and j2me application. I have debug statements in program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.