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

  • Home
  • SEARCH
  • 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 6766875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:53:01+00:00 2026-05-26T14:53:01+00:00

I’m trying to create image from SQLite database in Java Swing application. But it

  • 0

I’m trying to create image from SQLite database in Java Swing application. But it shows me errors. I’m using JDK 1.6, Java 6, SQLite 3, sqlitejdbc-v056.jar for connection SQLite and Ubuntu 11.04. I’m get sqlite connector from here. Here is the my code:

pos.res = pos.statement.executeQuery("select * from customer where card_id = "+card_id+";");

            while(pos.res.next()){
                if(pos.defaultParams != null){
                    pos.defaultParams.remove("pricelist_id");
                }else{
                    pos.defaultParams = new HashMap<String, Object>();
                }
                pos.defaultParams.put("pricelist_id", pos.res.getString("pricelist"));
                pos.jTextPane6.setText(pos.res.getString("name").toString());
                pos.customderId = Integer.parseInt(pos.res.getString("customer_id"));
                pos.jTextPane7.setText(pos.res.getString("department").toString());
                byte[] byt = pos.res.getString("photo").toString().getBytes();
                InputStream in = new ByteArrayInputStream(byt);
                BufferedImage image = ImageIO.read(in);
                ImageIO.write(image, "jpg",new File("/home/foo/Desktop/jj.jpg"));
                Graphics2D g = (Graphics2D)pos.jPanel4.getGraphics(); 
                g.drawImage(resize(image, 111, 100), null, 0, 0);
            }


private static BufferedImage resize(BufferedImage image, int width, int height) {
        BufferedImage resizedImage = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = resizedImage.createGraphics();
        g.drawImage(image, 0, 0, width, height, null);
        g.dispose();
        return resizedImage;
    }

I get following errors:

Nov 2, 2011 4:12:04 PM pointofsale.setCustomer set
SEVERE: null
java.lang.IllegalArgumentException: image == null!
1819 [AWT-EventQueue-0] DEBUG pointofsale.PointOfSaleView  - endting setCustomer.set func
    at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:1038)
    at javax.imageio.ImageIO.getWriter(ImageIO.java:1581)
    at javax.imageio.ImageIO.write(ImageIO.java:1510)
    at pointofsale.setCustomer.set(setCustomer.java:65)
    at pointofsale.PointOfSaleView.focusGained(PointOfSaleView.java:1032)
    at java.awt.AWTEventMulticaster.focusGained(AWTEventMulticaster.java:220)
    at java.awt.Component.processFocusEvent(Component.java:6092)
    at java.awt.Component.processEvent(Component.java:5959)
    at java.awt.Container.processEvent(Container.java:2105)
    at java.awt.Component.dispatchEventImpl(Component.java:4564)
    at java.awt.Container.dispatchEventImpl(Container.java:2163)
    at java.awt.Component.dispatchEvent(Component.java:4390)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1881)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:936)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:551)
    at java.awt.Component.dispatchEventImpl(Component.java:4434)
    at java.awt.Container.dispatchEventImpl(Container.java:2163)
    at java.awt.Component.dispatchEvent(Component.java:4390)
    at sun.awt.X11.XWindow$1.run(XWindow.java:378)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:647)
    at java.awt.EventQueue.access$000(EventQueue.java:96)
    at java.awt.EventQueue$1.run(EventQueue.java:608)
    at java.awt.EventQueue$1.run(EventQueue.java:606)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:617)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

Please help me?

  • 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-05-26T14:53:02+00:00Added an answer on May 26, 2026 at 2:53 pm

    Your problem is that ImageIO.read() fails. This is probably due to this code:

    pos.res.getString("photo").toString().getBytes();
    

    Never use the type String for binary data and never ever use getBytes() – it depends on your platform default encoding. This means: It will take the Unicode characters in the String and turn them into whatever your computer thinks as good. That will destroy your binary data.

    The correct solution is to use a BLOB column. See this answer how to write with BLOBs into sqlite: cannot save image as blob to sqlite

    The code for reading is similar.

    If that isn’t an option, then use the encoding ISO-8859-1 which is a 1:1 mapping if you don’t have Unicode characters (anything with a code point > 255) in your String.

    Don’t forget to write some unit tests to make sure your code works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.