Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Call Picture into java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


hendra
Call Picture into java
1 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

July 26, 2012 at 10:46 AM


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

Java MS Access database connectivity

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
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
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
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
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
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 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
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
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 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
call dll from java - JSP-Servlet
call dll from java  Hello all how to call dll file methods in java
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
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
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
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 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 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
picture in background in a HTML
picture in background in a HTML  How is picture displayed in background in a HTML
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
make a picture a link
make a picture a link  hello, What is the way to make a picture a link?   hii, This is the tab for image linking <A HREF="http://www.roseindia.net"><IMG SRC="image.gif"></A>
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. Bright and Contrast: Go to Image
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
 

 

 

DMCA.com