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
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 javaCall 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 javaCall 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 BeginnersProblem 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 BeginnersProblem 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 BeginnersProblem 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-ServletJava 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 - JavaMailcall 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 Beginnerscall 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 BeginnersJava-
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 Beginnersjava 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 Beginnerscall 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 Beginnersfunction
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 Questionscall 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 Call dll from java - JSP-ServletCall 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
remote procedure call using java - JSP-Servletremote 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-Servlethow 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-Servlethow 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 linkmake 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>
Upload the picture - JSP-ServletUpload 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 accessinserting
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
how to call an exe file from java - Java Beginnershow 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
conference callconference 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 callconference 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 callconference 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