View Photo From Db MySql
Good Morning Sir,
Please help me, I make a small code but i have a error. I want to make viewer photo from database MySql into my project in netbeans.
this is my code :
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:hyt","root","");
Statement stat = con.createStatement();
ResultSet res = stat.executeQuery("select * from kar where nik ='"+jTextField1.getText()+"'");
if (res.next())
{
jTextField1.setText(res.getString("nik"));
jTextField9.setText(res.getString("nm_kary"));
jComboBox6.setSelectedItem(res.getString("jns_klmin"));
jComboBox2.setSelectedItem(res.getString("jabatan"));
jTextField3.setText(res.getString("cab"));
jComboBox7.setSelectedItem(res.getString("pend"));
jTextField20.setText(res.getString("nm_scul"));
jDateChooser2.setDate(res.getDate("tgl_msk"));
eGambar.setText(foto(jTextField1.getText()));
Blob blob2 = res.getBlob("poto");
jLabel24.setIcon(new javax.swing.ImageIcon(blob2.getBytes(1, (int) (blob2.length()))));
//
jPanel9.setVisible(true);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null,"error "+e);
}
i have error : error java.lang.UnsupportedOpertionException
please help me,
Thank you,
regards,
Hendra
View Answers
June 25, 2012 at 12:56 PM
The given code accept the id from the user and display the image, name and address corresponding to the id.
import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class RetrieveImageWithData{
public static void main(String[] args)throws Exception{
final JFrame f=new JFrame();
f.setLayout(null);
final JLabel lab=new JLabel("Enter ID: ");
final JTextField text=new JTextField(20);
final JButton b=new JButton("Display");
final JLabel lab1=new JLabel();
final JLabel lab2=new JLabel("Name");
final JTextField text1=new JTextField(20);
final JLabel lab3=new JLabel("Address");
final JTextField text2=new JTextField(20);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int id=Integer.parseInt(text.getText());
lab1.setVisible(true);
lab2.setVisible(true);
text1.setVisible(true);
lab3.setVisible(true);
text2.setVisible(true);
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from data where id="+id+"");
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);
}
}
catch(Exception ex){
System.out.println(ex);
}
}
});
lab.setBounds(10,10,100,20);
text.setBounds(150,10,100,20);
b.setBounds(250,10,100,20);
lab1.setBounds(150,40,100,70);
lab2.setBounds(10,120,100,20);
text1.setBounds(150,120,100,20);
lab3.setBounds(10,150,100,20);
text2.setBounds(150,150,100,20);
lab1.setVisible(false);
lab2.setVisible(false);
text1.setVisible(false);
lab3.setVisible(false);
text2.setVisible(false);
f.add(lab);
f.add(text);
f.add(b);
f.add(lab1);
f.add(lab2);
f.add(text1);
f.add(lab3);
f.add(text2);
f.setVisible(true);
f.setSize(350,200);
}
}
July 3, 2012 at 7:11 AM
Hello,
Thank you for your help.
How to function this code, i already used that but cannot view anything. can you help me again. thank you
regards,
hendra
Related Tutorials/Questions & Answers:
View Photo From Db MySqlView Photo From Db MySql Good Morning Sir,
Please help me, I make a small code but i have a error. I want to make viewer
photo from database
MySql into my project in netbeans.
this is my code :
try
Advertisements
iPhone Pick images from Photo Library iPhone Pick images
from Photo Library
In this example application we are going to show you how to pick an image
from photo library.
To choose the
photo from the
photo library we required to call three different delegates
fat image from db fat image
from db <%@ page import="java.sql.*"%>
<...("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:
mysql://localhost... = stmt.executeQuery("select image
from regimg where id ='45'");
if (rs.next
fat image from db fat image
from db <%@ page import="java.sql.*"%>
<...("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:
mysql://localhost... = stmt.executeQuery("select image
from regimg where id ='45'");
if (rs.next
fat image from db fat image
from db <%@ page import="java.sql.*"%>
<...("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:
mysql://localhost... = stmt.executeQuery("select image
from regimg where id ='45'");
if (rs.next
fat image from db fat image
from db <%@ page import="java.sql.*"%>
<...("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:
mysql://localhost... = stmt.executeQuery("select image
from regimg where id ='45'");
if (rs.next
photo viwerphoto viwer i need coding for
photo viewer using jsp
mysql
Please visit the following link:
http://www.roseindia.net/jsp/downloadimage.shtml
How to view a list of MySQL users and their privileges?How to
view a list of
MySQL users and their privileges? Hi,
How to
view a list of
MySQL users and their privileges? It want to
view these two... command to
view list of users and their privileges in
MySQL database.
If you have
upload csv to mysql db using jsp uploadupload csv to
mysql db using jsp upload Hello all,
Please give me the code to uplad .csv
from jsp page and insert values into
MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
view data from jTextArea to jtableview data
from jTextArea to jtable good night
Please help senior java all, I want to make a brief program of reading data in the text area and then on the show to the j table.
I created a new scrip like below but it does
How to map MySQL View and Hibernate frameworkHow to map
MySQL View and Hibernate framework I found the following while trying to access
MySQL View via Hibernate.
HTTP Status 500 -
java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr
How to map MySQL View and Hibernate frameworkHow to map
MySQL View and Hibernate framework I found the following while trying to access
MySQL View via Hibernate.
HTTP Status 500 -
java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr
schema extraction from mysqlschema extraction
from mysql hi i am completely new to
MySql. i need...) and password?
2)how do i export schema
from existing table?
3) how do i use GUI for
mysql?(still iam working in
mysql console
upload photo in xcodeupload
photo in xcode how can i upload a
photo in a
view in xcode? i am a beginner in xcode please help me
Saving image and text in mysql db using spring? Saving image and text in
mysql db using spring? Hii,
My requirement is to save the employee details(including image) into
mysql db.i want to save the image location in
db .And actual image(binary formate) should save
Mysql DB backup size increases rapidlyMysql DB backup size increases rapidly we are using
mysql 5.1 with jboss application server. recently database size increases rapidly. it goes upto 8GB. how can we optimize the
DB? or shall we delete any log files? let me know
same thing i want but from db..same thing i want but
from db.. http://www.roseindia.net/tutorial/javascript/dynamicCombo.html
same thing i want but
from db update the selected records from view immediatlyupdate the selected records
from view immediatly Hi
I am extracting data form sql
view to Excel(2007). I want update the Flag field (CHAR 1)in one Table as soon as i get the data form the
view to excel.
Is there any way I can
View the mysql querys by and my Php WebAppView the
mysql querys by and my Php WebApp i need to debug a php web application. The problem is somewhere in the
mysql query section. I need... by the
mysql database. How can i do that ? Is there some script like phpmyadmin has
retrieving from db - JSP-Servletretrieving
from db hello'
I am trying to write my first application...: rst=stmt.executeQuery("select *
from books_details");
27: %>
28...; Hi
Retrive value
from database
Retrive data
from Image retrieval from mysql - JSP-ServletImage retrieval
from mysql Hai friends,
I used the following code to insert image into
mysql db.
Db data type is blob.
Database connection codings are in different file which is to be included
Photo upload, Download that this
photo photo can be accessed in all of the machines
from server side...
Photo upload, Download Hi
I am using NetBeans IDE for developing application for java(Swings). And i am using
MySQL as backend database.
My
retrieve data from mysql databaseretrieve data
from mysql database hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data
from mysql...;
db ("test");
$term = $_POST['term'];
$sql =
mysql_query("select
photo albumphoto album while syncing photos to my
photo album in my iphone, the
photo albumj ust got crashed i guess. Under photos option i just have the camera roll option now!! What should i do to get the
photo album back
photo uploadingphoto uploading i want the code upload the image in oracle database
Upload Photo to ServerUpload
Photo to Server Hi
I am using NetBeans IDE for developing application for java(Swings). And i am using
MySQL as backend database.
My... i am loading
photo.
(adsbygoogle = window.adsbygoogle || []).push
retrieving info from DB using struts?retrieving info
from DB using struts? Hi. I was looking info about retrieving info
from a database using struts.
I need a .java that I suppose connects to a database and show the info on a jsp.
Somebody could help me
Mysql Date from Date Mysql Date
from Date
Mysql Date
from Date Time in
Mysql return the Current ... an example
from 'DateTime in
Mysql'. To grasp this
example, we use date(current
How to access data yearly from DB in C# ?How to access data yearly
from DB in C# ? how to access data yearly
from database in C#.
I have code but i m not able to retrieve data yearly
from DB table.
string date1 = dateTimePicker1.Value.Date.ToString("dd/MMM/yyyy