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



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

Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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 Tutorials/Questions & Answers:
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
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
Advertisements
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
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
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
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
how to retrive
how to retrive  this my servlet page.. @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response
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
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
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
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
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
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
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
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 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
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
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
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
how to develop student details using springs
how to develop student details using springs  how to develop student details using springs
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
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
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
how to get the details of username&password of mysql - JDBC
how to get the details of username&password of mysql  Hi friends, i installed mysql 5.5 on my system successfully,but the thing is i forgotten the username and password .please tell me how to get those details . Thanks
How to extract details from XML? - JSP-Servlet
How to extract details from XML?  I want to extract details from http://service.openkapow.com/palanikumar/airportantigua.rest How can i extract details from this link?Here is my program... Airport
How to display gridview details to labels dynamically?
How to display gridview details to labels dynamically?  I am using SQLDataSource to connect to MySQL. I have a gridview that retrieves information... to display however, it always displays the details of the previously selected id
how retrive data from google analystics dashbord on the client machine
how retrive data from google analystics dashbord on the client machine   sir i am digvijay subj: retrive data from google analystics dashbord respected sir, According above subject i request you , i want retrive data from
How to retrive a particular record from database in php with mysql?
How to retrive a particular record from database in php with mysql?  ... names are username,password,email,firstname,lastname. But i want to retrive 3 rd record based on username and password. I dont know how to retrive in php with mysql
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
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
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
how to send email please give me details with code in jsp,servlet
how to send email please give me details with code in jsp,servlet  how to send email please give me details with code in jsp,servlet
How to put an image on a JButton?
How to put an image on a JButton?  How to put an image on a JButton
how to update image in php
how to update image in php  how to update image in php
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILES,IF I ENTER 4 EMPLOYEE DETAILS(NAME,ID,SALARY,EMAIL) ALL THE DETAILS OF 4
how to retrive the particular data from database in php with mysql?
how to retrive the particular data from database in php with mysql?  when am using mysqlfetcharray() that display the following error. the code look like this.. <?php $con = mysql_connect("localhost","root
How to Display Font Other than english
How to Display Font Other than english  How to display font other than english without using any files installed
how to insert image into server
how to insert image into server  how to insert an image into sql server and retrieve it using jSP
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
how to display image with listview
how to display image with listview  How can i display the list view with the related images from database
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database... through the following link How To Store Image Into MySQL Using Java
retrive values - JSP-Servlet
retrive values  how to get multiple values from html to jsp
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
How to write image in Jmagick
How to write image in Jmagick  hi, I am new in Java I am using the Jmagick library, how can I write an image in Jmagick ? Thanks.   hi, You can try this snippet into your code ImageInfo ii = new ImageInfo("abc.jpg
Jmagick how to add image on an existing image
Jmagick how to add image on an existing image  hi, I am using...) on an existing image. can any one explains how ? Thanks.   hi, In Jmagick you... you to understand how to use these methods and values in to adding an image
How to write text on image
How to write text on image  hi, I am using the Jmagick library. I want to write text on image, how is it possible ? Thanks.   hi, I am new in Jmagick but, I used the following code and it might also help you
Advertisements
 

 

 

DMCA.com