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



Home Answers Viewqa Java-Beginners Create Reports in Java with access database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sushant
Create Reports in Java with access database
1 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners


Hello Sir How to Create Reports of Any Type using Java when i submit data is stored in the MS access database,but when I click on PRINT Button then it will display it into either Text File or any type of Report and then i want to print it.
How I can Generate it plz help Me

Advertisement
View Answers

April 21, 2010 at 12:25 PM


Hi Friend,

We are providing you code that will display the data into textfile on clicking Print Button.

Try the following code:

import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame{

JButton ADD;
JPanel panel,pan;
JLabel label1,label2,label3,label4,label5;
final JTextField text1,text2,text3,text4,text5;
Form() {
label1 = new JLabel();
label1.setText("Employee Id:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Employee Name:");
text2 = new JTextField(20);

label3 = new JLabel();
label3.setText("Employee Designation:");
text3 = new JTextField(20);

label4 = new JLabel();
label4.setText("Employee Salary:");
text4 = new JTextField(20);

label5 = new JLabel();
label5.setText("Employee Address:");
text5 = new JTextField(20);

ADD=new JButton("Print");

panel=new JPanel(new GridLayout(6,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(label5);
panel.add(text5);
panel.add(ADD);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String id[]={text1.getText()};
String name[]={text2.getText()};
String des[]={text3.getText()};
String sal[]={text4.getText()};
String add[]={text5.getText()};

java.util.List<String> list = new ArrayList<String>();
for(int i = 0; i < id.length; i++) {
String line = id[i]+" "+name[i]+" "+des[i]+" "+sal[i]+" "+add[i];
list.add(line);
}
writeToFile(list, "Employee.txt");
JOptionPane.showMessageDialog(null,"Inserted into File");
text1.setText(" ");
text2.setText(" ");
text3.setText(" ");
text4.setText(" ");
text5.setText(" ");

}
});
}
private static void writeToFile(java.util.List<String> list, String path) {
BufferedWriter out = null;
try {
File file = new File(path);
out = new BufferedWriter(new FileWriter(file,true));
for (String s : list) {
out.write(s);
out.newLine();
}
out.close();
} catch(IOException e) {}
}
}
class InsertToFile{
public static void main(String arg[]) {
try
{
Form frame=new Form();
frame.setSize(300,300);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}

Thanks


Related Tutorials/Questions & Answers:
Create Reports in Java with access database - Java Beginners
Create Reports in Java with access database  Hello Sir How to Create Reports of Any Type using Java when i submit data is stored in the MS access database,but when I click on PRINT Button then it will display it into either Text
How to create and Attach MS Access Reports and Crystal Reorts in Java. - Java Beginners
How to create and Attach MS Access Reports and Crystal Reorts in Java.  How to create and Attach MS Access Reports and Crystal Reorts in Java WITH MS Access 2007 Database, plz Help Me Sir
Advertisements
How to Create and display Reports in Java with Database connectivity - Java Beginners
How to Create and display Reports in Java with Database connectivity  Hello Sir , I have Created Student Admission Form with Swing and MS Access 2007 Database Connection,when i will click on Print button it shows the report
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
How to Create any type of Reports in Java - Java Beginners
How to Create any type of Reports in Java  Hello Sir ,How I can create any type of Reports like Crystal Reports etc(Student Result Report) in Java Application,plz Help Me Sir
Reports in java - Swing AWT
How to create Reports in Java  How to create reports in java. The report should come from the access It should be displayed in the JTable and should be updated automatically when the user is saved a record in the JTable
Create Crystal reports with PHP
Create Crystal reports with PHP  I'm New to eclipse and php. I need to create a report using crystal report on php. is that possible. If it is, how could I install it to eclipse IDE. How to use
Create Crystal reports with PHP
Create Crystal reports with PHP  I'm New to eclipse and php. I need to create a report using crystal report on php. is that possible. If it is, how could I install it to eclipse IDE. How to use
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
creating reports in java
creating reports in java  how to create reports automatically in java and send it via mail by scheduling tine for weekly,monthly basis
how to access the MS ACCESS database with java - Java Beginners
how to access the MS ACCESS database with java  how can we insert,delete,update,search records of ms access with java
reports
reports  hi i want to create reports in my projects . plz give me some idea how to create reports in jsp
Jasper Reports - Java Beginners
/), it is free and based o JasperReports. It lets you create sophisticated reports...Jasper Reports  Hi, I'm new to Jasper Reports. Please help me by giving a simple example of Jasper report generating. Thank You, Umesh 
Problem with JRadioButton and Access Database - Java Beginners
in Access Databse, I want to store course type in to database and also other fields...Problem with JRadioButton and Access Database  Hello sir ,Here I have...(); JOptionPane.showMessageDialog(p1,"Data is successfully inserted into database."); con.close
cannot insert data into ms access database - Java Server Faces Questions
Microsoft Access Driver(*.mdb) 5. Select database name and Create the DSN name...cannot insert data into ms access database   go back   Hi Friend, You can use the following steps for creating DSN
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  Hi all my Friends I have below code which insert a picture into M.S. Access Database But i m still not able to open this picture through Java using M.S. Access
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend...(); } public SwingFrame(){ JFrame f = new JFrame("Frame in Java Swing
Connect database in Access to Netbean?
Connect database in Access to Netbean?  how to connect database in micrsoft access to Netbean?i know it can be connected by using JDBC-ODBC bridge, can i know the steps in connecting the database? Is there any source code
ACCESS DATABASE FROM HTML
ACCESS DATABASE FROM HTML  I want to access sql 2008 database in html page without help of ADODB connection.. because if access through ADODB means there is a security problem. so, Access database in html page(client side
How to Generate Reports in Java - Java Beginners
How to Generate Reports in Java  How to Display and Generate Reports in Java? Give Me Full Sample Code  Hi Friend, What do you want to display on reports.Please elaborate it. Thanks
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
How to Store Float Value into Access Database - Java Beginners
How to Store Float Value into Access Database  Hello sir,I want to Store Student Marks Percentage into Access Database in Float Value how i can Store.... To store the double value in Access database, you need to set the datatype
Problem with Double type Value in Access Database - Java Beginners
Mobile Number with MS access Database,plz Help Me Sir.   Hi Friend...Problem with Double type Value in Access Database  Hello sir I have store Double Type Value in MS Access Databse,but when I search Record
Add Items in JComboBox from Access Database - Java Beginners
Add Items in JComboBox from Access Database  Heelo Sir I want To add ittem in JComboBox which is stored in Access Database. plz Help Me Sir Database Column name -Course Items -MBA,MCA,MBA IT,MBA FINANCE I want Load Database
connecting to access database
Access Driver(*.mdb) Select database name and Create the DSN name (e.g access...connecting to access database  print("code sample");Hi I Write java... this there is no error but my data is not going to my Acess Database. There is working
Access 2007 database connectivity
Access 2007 database connectivity  i design an application form... source and destination. pls tell me the code of connectivity with access 2007 database using JComboBox.thanks
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try... SwingFrame(){ JFrame f = new JFrame("Frame in Java Swing"); f.getContentPane
link hibernate to MS ACCESS database
link hibernate to MS ACCESS database  how to link hibernate to ms access database instead of sql database
how to access database in applet
how to access database in applet  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system(same network)... but when its in the server, we r getting null values
how to store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
Applet database access - Applet
Applet database access  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system... but when its in the server, we r getting null values in the local system.. I
Advertisements
 

 

 

DMCA.com