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



Home Answers Viewqa Swing-AWT java to excel connectivity
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raman
java to excel connectivity
1 Answer(s)      4 years and 5 months ago
Posted in : Swing AWT


give me source code to stored the value entered by user in a text field(such as name, age, sex, add. of the user etc.) that are on the jpanel to the database created in MSEXCEL 2007. actually i am making project on bank and i want to stored the information of customer to my database on the excel.

Advertisement
View Answers

July 23, 2010 at 1:23 PM


Hi Friend,

Follow these steps:

1. Open Data Sources (Start->Settings->Control Panel->Administrative Tool->Data Sources(ODBC)

2. Open User DSN tab
3. Add a user DSN
4. Select Microsoft Excel Driver(*.xls)
5. Select work book or excel file and Create the DSN name (e.g excel)
6. Click "Ok" and restart your compiler.
7. Compile the following java code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class InsertToExcelDatabase extends JFrame {
JButton ADD;
JPanel panel;
JFrame f;

InsertToExcelDatabase(){
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);

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

ADD=new JButton("Insert");
ADD.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String v1=text1.getText();
String v2=text2.getText();
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection c = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:/database.xls; readOnly= false");
Statement stmnt = c.createStatement();
String insertSql = "Insert into [Excel Sheet$] (Name,Address) values ('"+v1+"', '"+v2+"')";
int insertSuccess = stmnt.executeUpdate(insertSql);
}
catch(Exception ex){}
}
});
f=new JFrame();
panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(ADD);
f.add(panel,BorderLayout.CENTER);
f.setTitle("FORM");
f.setVisible(true);
f.pack();
}
public static void main(String[]args){
InsertToExcelDatabase ff=new InsertToExcelDatabase();
}
}

Thanks


Related Tutorials/Questions & Answers:
java to excel connectivity - Swing AWT
java to excel connectivity  give me source code to stored the value... excel) 6. Click "Ok" and restart your compiler. 7. Compile the following java... database on the excel.  Hi Friend, Follow these steps: 1. Open Data
java connectivity
java connectivity  hi........ Can u help me to do connectivity between java and weka??????? weka is a data mining tool which allows to do prediction, classification etc.... i want to do connectivity between weka and java can u
Advertisements
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
java connectivity
java connectivity  i am trying to add dyanamic rows in the jsp page, when i add the new row the dropdown control value is not coming from database..please help me to overcome this problem
JAVA EXCEL
JAVA EXCEL  How to read the contents of an excel, perform some calculation and wrote the calculated values to another excel using poi
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
JAVA_EXCEL
JAVA_EXCEL  I need to read the all the contents of excel which has... content another excel. For example if I have three tabs in an excel with some contents. The contents from all the three tabs has to be read by java program and has
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void... with sql server connectivity at the background to save the data. Now, after... the connectivity wrong. Kindly help me resolve this issue ASAP. Thank you
database connectivity in java - JDBC
database connectivity in java  import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; class Project implements ActionListener { JFrame f; JPanel p1,p2,p3; JTabbedPane
Java database connectivity
Java database connectivity  Hi sir I need a code to create an application where user enter name in text box and that should be stored in database. Plz help me out its very urgent.   import java.sql.*; import java.awt.
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
DataBase connectivity in java with Microsoft sql server2000 - JDBC
DataBase connectivity in java with Microsoft sql server2000  How i can achieve database connectivity with Microsoft sql server2000 in my java source code
connectivity
connectivity  how to connect java with database
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
Excel file Handling in Java
Excel file Handling in Java  Hello Sir, I am new to Java, I have Started Java Core by myself. I want to make a project which include 3-4 Excel file...://www.roseindia.net/tutorial/java/poi/readExcelFile.html   Now to create an excel file
reading excel sheet in java
reading excel sheet in java  can anyone tell me a proper java code to read excel sheet using poi   Here is a java code that reads an excel file using POI api and display the data on the console. import java.io.
Java vs Oracle Connectivity - JDBC
Java vs Oracle Connectivity  Write a java program to establish connection with oracle database?  Hi Friend, Use Oracle with Java Follow these steps: 1) Import the following packages in your java file
To read a excel with chart - Java Beginners
To read a excel with chart   Hi, I need to read the data in an excel which is in chart format using java. when I directly change the extention of excel file to CSV i am not getting the data in the chart.Please help me
Java and excel - JDBC
Java and excel  i want to retrive records from my database to a Jtable from where i can export to excel, i will like to format the column headers in excel using code. plz i nd help becos it is my project, as a serious student i
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same excel file as required. i am writing my code on notepad and have successfully
export java to excel - Java Beginners
export java to excel  How do you export java to excel?  You mean to say accessing Microsoft files in java? Then you can go for Apache POI. Its an API to access MS-Office files.Try using it. - Ramesh A.V
ODCB-EXCEL - Java Beginners
ODCB-EXCEL  Hi, i would like to extract data from an excel file. my excel file name is: TEST.xls the worksheet name is : qas i have configure...: "java.sql.SQLException: [Microsoft][Pilote ODBC Excel] Not enough parameters 1
Excel file wriring using java
Excel file wriring using java  i have one predefined bill format in excel i want to append values in it using java apche POI or Jexcel i tried it but it overwrites file and lost previous contents what can i do
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
JDBC Connectivity Code In Java
JDBC Connectivity Code In Java       In this Tutorial we want to describe you a code that helps you in understanding JDBC Connectivity Code in Java. In this program, the code
Help me on database connectivity in J2ME - Java Beginners
Help me on database connectivity in J2ME  i want help in J2ME. i want code for database connection with MySQL. spcl to fecth and insert data from databse. please help me
Creating Excel sheets - Java Beginners
Creating Excel sheets  Hi, I want the java code for creating excels sheets with two workbooks using POI, and to find the difference between the particular value of one cell and others. asuming the contents of teh files adn
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
 

 

 

DMCA.com