Home Answers Viewqa Swing-AWT how to retrive other details with an image

 
 


neelam
how to retrive other details with an image
1 Answer(s)      3 years and 6 months ago
Posted in : Swing AWT

View Answers

December 5, 2009 at 1:02 PM


Hi Friend,

We are providing you a code where we have retrieved three values from database i.e, name,address and photograph. We have created a table data(id,name,address,image.

import java.sql.*;
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.ImageIO;

public class RetrieveData extends JFrame{
JLabel l1,l2,l3;
JLabel l;
JTextField t1,t2;
JTextArea area;
JScrollPane pane;
JPanel p;

RetrieveData(){
l1=new JLabel("Name");
l2=new JLabel("Address");
l3=new JLabel("Photograph");
t1=new JTextField(20);
t2=new JTextField(20);
p=new JPanel(new GridLayout(3,2));
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test";, "root", "root");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select name,address,image from data where id='2'");
byte[] bytes=new byte[1024];
String value1="";
String value2="";
if (rs.next()) {
value1=rs.getString("name");
value2=rs.getString("address");
bytes = rs.getBytes("image");
}
rs.close();
stmt.close();
con.close();
t1.setText(value1);
t2.setText(value2);
if (bytes != null) {
File f=new File("photograph.jpg");
InputStream in = new ByteArrayInputStream(bytes);
BufferedImage image = ImageIO.read(in);
ImageIO.write(image, "jpg", f);
String path=f.getName();
ImageIcon icon = createImageIcon(path,"a pretty but meaningless splat");
l = new JLabel(icon);
}
} catch (Exception e) {
}
p.add(l1);
p.add(t1);
p.add(l2);
p.add(t2);
p.add(l3);
p.add(l);
add(p);
setVisible(true);
setSize(400,200);
}
public static void main(String[]args){
RetrieveData data=new RetrieveData();
}
protected static ImageIcon createImageIcon(String path,String description) {
java.net.URL imgURL = RetrieveData.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
}
Thanks









Related Pages:
how to retrive other details with an image - Swing AWT
how to retrive other details with an image  hello I m trying to retrive an image as well as some other values from database.. but only image..... followingis my code..plz advice me how to get both values as well as image at a same
image retrive into DataBase - JDBC
image retrive into DataBase  Dear Deepak Sir, How to retrive the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi... shows you how to retrieve image from database using a servlet and then show
store and retrive image from the database
store and retrive image from the database  please provide me with the code and the explanation of what each line does for the below query. -how to store and retreive images from sql database using sql commands -how to store
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image...("Insert Image Example!"); String driverName = "com.mysql.jdbc.Driver"; String
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
jsp retrive image - JSP-Interview Questions
jsp retrive image  How to Display Images in JSP retrieved from MYSQL database? plz help me..  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
how to access the details - Java Beginners
how to access the details  how to access the detailsclass E { String name; String no;string place; E(String n,String n,String p) { ... ... .... } public String... no)and retrive all the details of the person which is not given
how to convert image into bytes and also retrive the image from that bytes - Java Beginners
how to convert image into bytes and also retrive the image from that bytes  how to convert image into bytes and also retrive the image from... = st1.executeQuery("select image from pictures where id='5'"); String imgLen
how to retrive
how to retrive  this my servlet page.. @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help me out..... in file create project i am entering proj details such as id name... if user enters any one of the feild such as id name cost and manager the full details
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
How to retrive an inmage from database and displaying it in imgae box ...? I want to retrive an image from database and to display it in a small imagebox or pane in a JFrame.. is this possible? can you plz help tell me how we can do
Java Programming: Other Features of Java
Appendix 1: Other Features of Java THIS TEXTBOOK does not claim... can contain images, sounds, and other resource files needed by a program. It's fairly easy to load such resources into a program. An image resource
Retrieval column details into respective JComboboxs
Retrieval column details into respective JComboboxs   Hello sir... in there respective comboboxs.. and if i select other name name in the PNAME(shruthi... in there respective comboboxs.. how to achive it,plz help me in this regard through by code
details of my program - Java Beginners
details of my program  hi 1- allow the customer to order any thing... of Scanner coz i need to read integers numbers or any other kind of data from...:"); int x ; x=in.nextInt(); int y; System.out.print ("How
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp  i ve creted... the submit button,how can v store the data in db, n hw can v retrive the data frm
Show Other Image Effects
Show Other Image Effects       This section illustrates you some other image effects To show image effects like sharpen, blur, show edge, reset ,etc, we have create
scjp details
scjp details  SCJP fees details abou scjp? What are the best books for preparing to scjp? How many time scjp exam's are conducted for one year
student details
student details  hi sir/madam i have a doubt in PHP how to insert student details using mysql with php..   Have a look at the following link: PHP Mysql insert
image retreival
image retreival  I ve stored the path of image and audio in mysql database. how to retrive it and display... Can u pls help me out
retrive the result of a serach string from other sites - JSP-Servlet
retrive the result of a serach string from other sites  Sir, suppose i have create my own websites, and i want to search an item in my sites and as well as from other search sites and i want to show all the search result in my
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  How to copy an image from one folder to another folder using jsp
retrive values - JSP-Servlet
retrive values  how to get multiple values from html to jsp
How can I write a GUI stack program by Java to push Image files instead of other data type items?
How can I write a GUI stack program by Java to push Image files instead of other data type items?   How can I write a GUI stack program by Java to push Image files instead of other data type items? for the push instruction I
How to move a file from a directory to other directory
How to move a file from a directory to other directory  I tried the above example it will move the folder to other directory but it does not move the image file or other file to a specified directory. Can anyone help me? Thanks
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  hello, i am creating photo gallery where from admin side i allow admin to browse... be in my image folder...so,How to copy an jpeg image from one folder to other
upload file and insert other details to database using a single form
upload file and insert other details to database using a single form   hi.. I have problem with uploading a file and insert other user datas together... but my other details seem to be null
JDBC: Get Column Details Example
JDBC: Get Column Details Example In this tutorial, we are describing how to get column details of a table using JDBC API. Get Column details : For displaying details of table columns, You can use "SHOW COLUMNS table_name"
retrive mails - Java Beginners
retrive mails   hi how to retrive mails using mysql in java not using pop3 or imap directly from database i am using dbfile system in james server.header should be store in database and message in file system thanks bala
retrive values - JSP-Servlet
retrive values  how to retrive multiple values from html to jsp  Hi Friend, Try the following code: 1)calljsp.html: Enter Name: Enter Address: Gender:MF Qualification: Btech MBA MCA MSC
login page with image
consists of a image and the login details... how to write a java program using frames... used multiple frames to design but the position of image is changing when program is moved to other systems... help me.... thanks
Get specific item details by clicking on hyperlink
Get specific item details by clicking on hyperlink  sir, I am... and corresponding image with a hyperlink on it from the database to a jsp page. -If I click on the image or item name I should get total datails from the database
Other Java Resources
to this as they program to see the details of classes, method, parameters, etc. The Java... articles, news, and discussion threads on JavaBeans, Servlets, JDBC and other Java... - Good reviews of Java packages, etc. Links to other interesting Java info
image
image  how to add the image in servlet code
how to code-updating some details n some details r unchanged
how to code-updating some details n some details r unchanged  i have created a page with empty text boxes,details are.... house... : bloodgroup : my requirement is to update the details of user. and i had written
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
searching inside a file for details
searching inside a file for details  i created a file with name,country,state etc...when i'm searching for the name, i have to get other details like country,state etc...please do help
insert user session into other oracle database table
comments then how i can retrive his user id using session and store id into comments...insert user session into other oracle database table   hello i am a doing my project in jsp-servlet. i have doubt that when a user login to his
bank details - JSP-Servlet
bank details  hi i just need a coding for bank details... since iam... is first to set the user account details in database, and the to create a login......no other changes shoud be done by the user..... this is my task... what
how to develop student details using springs
how to develop student details using springs  how to develop student details using springs
how to retrive data grom database in jsp pages.
how to retrive data grom database in jsp pages.  sir, i have problem to retrieve data from table of the database on the html web pages , so would yuo please help me about this. please post me solution on my email id
how to insert the physical path of an image in database - JDBC
, the image column is of varchar datatype.. plz can you tell me how to insert image's path.. and also how to retrive that image path and show that picture in a small...how to insert the physical path of an image in database  hello I m
Other
Other      ... be useful to other developers as well. Currently there are: * com.nightlabs.ant... focus on what to print instead of how to print it.    
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg:I have three tables in database,and in jsp page if i select courseid in select
image displaying from database with some other information
image displaying from database with some other information  hi, in the following section of code when i am not displaying the image it is working properly but when i tried to display the image nothing is displayed on browser
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.