Call Picture into java

Call Picture into java

Morning sir,

I want to view my picture(longblob) from My DB Mysql, I have a code like this.

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:hyt","root","hayatinew"); Statement stat = con.createStatement(); ResultSet res = stat.executeQuery("select * from karyawan_ft where nik ='"+jTextField35.getText()+"'"); if (res.next()) { //jTextField35.setText(res.getString("nik")); eGambar.setText(foto(jTextField35.getText())); Blob blob1 = res.getBlob("foto"); jLabel38.setIcon(new javax.swing.ImageIcon(blob1.getBytes(1, (int) (blob1.length())))); }else{ JOptionPane.showMessageDialog(null,"aaa"); } } catch (Exception e) { JOptionPane.showMessageDialog(null,""+e); }

But i have error, Java.Lang.UnsupportedOPertaionException. Please help me, Thank you

View Answers

July 26, 2012 at 10:47 AM

Here is a code that displays the name, address and image of a person on the jframe.

Follow these steps:

1)Go to the start->Control Panel->Administrative Tools-> data sources.

2)Click Add button and select the driver Microsoft Access Driver(*.mdb).

3)After selecting the driver, click finish button.

4)Then give Data Source Name and click ok button.

5)Your DSN will get created.

6)Create a table 'user' in MS access database and add following fields to it.

id of Autonumber type
name of Text type
address of Text type
image of OLE Object type.

6) Restart your compiler and compile your java code.

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class RetrieveImage{
    public static void main(String[] args)throws Exception{
        JFrame f=new JFrame();
        f.setLayout(null);
        JLabel lab1=new JLabel();
        JLabel lab2=new JLabel("Name");
        JTextField text1=new JTextField(20);
        JLabel lab3=new JLabel("Address");
        JTextField text2=new JTextField(20);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection conn = DriverManager.getConnection("jdbc:odbc:student");

        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from user where id=1");
        byte[] bytes = null;
        if(rs.next()){
            String name=rs.getString("name");
            text1.setText(name);
            String address=rs.getString("address");
            text2.setText(address);  
            bytes = rs.getBytes("image");
            Image image = f.getToolkit().createImage(bytes);
            ImageIcon icon=new ImageIcon(image);
            lab1.setIcon(icon);
        }
        lab1.setBounds(150,10,100,100);
        lab2.setBounds(10,120,100,20);
        text1.setBounds(150,120,100,20);

        lab3.setBounds(10,150,100,20);
        text2.setBounds(150,150,100,20);
        f.add(lab1);
        f.add(lab2);
        f.add(text1);
        f.add(lab3);
        f.add(text2);
        f.setVisible(true);
        f.setSize(350,200);
    }
}









Related Tutorials/Questions & Answers:
Call Picture into java
Call Picture into java  Morning sir, I want to view my picture(longblob) from My DB Mysql, I have a code like this. try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
Call Picture into java
Call Picture into java  Morning sir, I want to view my picture(longblob) from My DB Mysql, I have a code like this. try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
Advertisements
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System... (MSSQL), i make the registrar to be able to upload the student picture from the System picture Folder and display it on the User Interface. Now, i want the registrar
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System... (MSSQL), i make the registrar to be able to upload the student picture from the System picture Folder and display it on the User Interface. Now, i want the registrar
Problem with picture - Java Beginners
Problem with picture   Hi, I Develope a School Automated System... (MSSQL), i make the registrar to be able to upload the student picture from the System picture Folder and display it on the User Interface. Now, i want the registrar
I need add my java program with a picture.
I need add my java program with a picture.  Good evng Frnds Friends i created 1 jar file in my desktop. I need add this program with 1 picture. Whenever the user double clicking on that picture The program must start instead
How to capture picture from webcam using java
How to capture picture from webcam using java  i want catch the image from web-cam using jsp, If anyone knows please answer me
Java to insert picture to database - JSP-Servlet
Java to insert picture to database  Hi Guys, Please assist me on this. Below is the code I wanted to use to insert picture into Ms Sql server 2000 but after the insertion, I got this in the database (back-end
call from java - JavaMail
call from java  Hi, how i will call servlet from java.. plz its urgent.. Thanks Narendra  Hi Narendra, You can use the java.net package to call a servlet from the java code
call frame - Java Beginners
call frame   dear java, I want to ask something about call frame...(browse) then view FrameB. In FrameB i fill JTextfield1(FrameB) with "JAVA... it because after i fill JTextfield1(FrameB) with "JAVA" then click button(FrameB
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  ... Database But i m still not able to open this picture through Java using M.S. Access and i wants to open this Picture On Web Browser using Java Servlet anybody can
Java-call by value - Java Beginners
Java-call by value  Why java is called strictly "call by value" and not "call by reference" ?Please explain with example?  Hi Friend, The Java programming language does not pass objects by reference; it passes
java call by reference - Java Beginners
java call by reference  in java do we have ane term like call... affect the caller?s original variables. Java never uses call by reference. Java... you call a method by reference, the callee sees the caller?s original variables
call frame again - Java Beginners
call frame again  d, thank's for your answer, but i can't combine... read from jbutton1 in FrameA to FrameB,then i write "JAVA" in Jtextfield1(FrameB),then i click jbutton1 in FrameB. "JAVA" is a word i'am write in Jtexfield1
function call in javascript - Java Beginners
function call in javascript  hi all, i've written a javascript , but i m unable to call a function getExpression.i dont know why getExpression function is not being called. heres my code : function
call a function - Java Interview Questions
call a function  Please i want to call the function union via main How I can do it??? Here you find my code With my best Regards... call it } }   Hi Friend, Please post your problem
Change Background Picture of Slide Using Java
Change Background Picture of Slide Using Java  ...; In this example we are going to create a slide then change background picture of the slide. In this example we are creating a slide. In this slide we are inserting a picture
picture in background in a HTML
picture in background in a HTML  How is picture displayed in background in a HTML
cant call cmd from java - Java Beginners
cant call cmd from java   How can I call this from java to be executed by cmd ? ConvertXLS.EXE /S "C:\Extracto\*.CSV"/T "C:\Extracto\*.XLS" /C-4143 /F6 /M2 /R /V
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
call dll from java - JSP-Servlet
call dll from java  Hello all how to call dll file methods in java
Call dll from java - JSP-Servlet
Call dll from java  Any one tell me how to call dll from java. Basically , i want read the cash m/c parameters(4,i.e i want to read the cash count) in java .For this i want to call a dll from java . Also any one have
how to call from pc to telephone in java - MobileApplications
how to call from pc to telephone in java  Hi, presently I am working on "make a call from pc to telephone" in java. I am unable to procceed how to start. I am new this technoloy.Please give me some valuable suggestions how
remote procedure call using java - JSP-Servlet
remote procedure call using java  what is the romote procedure call and related coding in java?  Hi Friend, The RPC (Remote Procedure Call) is a mechanism that enables a remote procedure call from a client
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java class in a jsp.can anyone please help me with this query
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java class in a jsp.can anyone please help me with this query
make a picture a link
make a picture a link  hello, What is the way to make a picture a link?   hii,ADS_TO_REPLACE_1 This is the tab for image linking <A HREF="http://www.roseindia.net"><IMG SRC="image.gif"></A>
How to convert a picture into a shape, convert a picture into a shape, picture shape
How to convert a picture into a shape       If you want to use a picture shape but you are not able for that, don't worry. You will learn easily to convert a picture into shape. Take
How to convert a picture to drawing, convert a picture to drawing, picture to drawing
How to convert a picture to drawing       Learn here a simple processing to make a color picture.... Picture: Take a picture to modify.ADS_TO_REPLACE_1 Filter effect: Go to Filter
How to make a enhance picture, make a enhance picture, enhance picture
How to make a enhance picture       In this example you will learn a easy way to make a enhance picture effect. Picture: Take a picture to modify.ADS_TO_REPLACE_1 Bright
How to make frame of the picture, make frame of the picture, frame of the picture
How to make frame of the picture   ..., I have mention here all the steps to make this effect. Take picture: First take a picture to framed.ADS_TO_REPLACE_1 Selection: Make selection
Upload the picture - JSP-Servlet
Upload the picture  Dear Sir, How to upload the picture in the database a webpage and i want to show that picture another page. what i have to do ? plz tell me with an example. Regards Sanjeev Rai 
inserting picture in ms access
inserting picture in ms access  hi i am sanatan, how to insert picture in ms access by jsp.   <%@page import="java.sql.*,java.io.*"%> <% try{ InputStream sImage; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
ModuleNotFoundError: No module named 'mdx_picture'
ModuleNotFoundError: No module named 'mdx_picture'  Hi, My Python... 'mdx_picture' How to remove the ModuleNotFoundError: No module named 'mdx_picture' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'picture-cutter'
ModuleNotFoundError: No module named 'picture-cutter'  Hi, My... named 'picture-cutter' How to remove the ModuleNotFoundError: No module named 'picture-cutter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'The-Big-Picture'
ModuleNotFoundError: No module named 'The-Big-Picture'  Hi, My... named 'The-Big-Picture' How to remove the ModuleNotFoundError: No module named 'The-Big-Picture' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangocms-picture'
ModuleNotFoundError: No module named 'djangocms-picture'  Hi, My... named 'djangocms-picture' How to remove the ModuleNotFoundError: No module named 'djangocms-picture' error? Thanks   Hi, In your
Applet program for drawing picture and graph - Applet
Applet program for drawing picture and graph  Please send me the program(code) of drawing picture and graph in Applet.  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java
how to call java script function through java class file
how to call java script function through java class file  how to call jframe in java script
How to make a high contrast picture, make a high contrast picture, high contrast picture
How to make a high contrast picture       Make a fade picture to high contrast by this example, it has a new way to make it so follow now. Picture: Take a picture to modify, I have
how to call an exe file from java - Java Beginners
how to call an exe file from java  hi, how to call exe file with some parameters from java and save the output of the exe file in a specified path. Please let me know immediately..its urgent!!! Thanks in advance
How to make a glossy picture effect, make a glossy picture effect, glossy picture effect
How to make a enhance picture       If you have any problem to make glossy picture effect, you should follow my this example because I have made it with some easy steps. Picture
How to make a curl corner of the picture, make a curl corner of the picture, curl corner of the picture
How to make a curl corner of the picture   ... of the picture, it is very easy by the help of this example. Picture: Take a picture to curl the corner of the picture.ADS_TO_REPLACE_1 Selection: Make
Diff ways to call a EJB from Servlet, JSP - Java Interview Questions
Diff ways to call a EJB from Servlet, JSP  How can I call EJB from Servlet or JSP
How to make a bright and contrast picture, make a bright and contrast picture, bright and contrast picture
How to make a bright and contrast picture       If any picture has darkness and you... a technique to reduce the darkness so let's try. Take a Picture: Take
How to make a golden effect on the picture, make a golden effect on the picture, golden effect on the picture
How to make a golden effect on the picture   ... to make a golden effect on the picture. New file: Insert a picture to modify, I am using here a monkey picture to modify.ADS_TO_REPLACE_1 Blur effect: Make
How I call the function union from the main - Java Interview Questions
How I call the function union from the main  Please, from public static void main(String[] args) I would like to call the function union and I...}, }; //calling the function union : paramtere to pass is mat //how i call
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first

Ads