connect jdbc to an Excel spreadsheet

Ads
 

connect jdbc to an Excel spreadsheet

hello,

How can I connect to an Excel spreadsheet file using jdbc?

View Answers

October 26, 2010 at 11:14 AM

Hello 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.sql.*;

public class JDBCExcel { public static void main(String args[]) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:excel","", ""); Statement st = conn.createStatement(); String query = "select * from [Excel sheet$]"; ResultSet rs = st.executeQuery(query); while(rs.next()){ System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3)); } } catch(Exception e){} } }

Note: 'Excel sheet' is the sheet name of the selected excel file in the query.

Thanks

Ads









Related Tutorials/Questions & Answers:
JDBC to EXcel
JDBC to EXcel  How to insert data in excel sheet from java
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
Advertisements
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
How to insert rows from Excel spreadsheet into database by browsing the excel file?
How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i... the excel file using file browsing dialogue through form in JSP. How can i select
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database  I imported an excel spreadsheet using sql developer into my... table for each spreadsheet but I want to obtain the path and filename of each
not able to connect to mysql using.. jdbc
not able to connect to mysql using.. jdbc   i am not able to connect to mysql using jdbc .. is there any classpath that i need to set..because i am using mysql-connector-java jar file..to connect to mysql.. Pls provide the steps
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... used JDBC ODBC to read from excel file. i am not able to append it using
how to connect jdbc
how to connect jdbc  package com.tcs.ilp.Try.Controller; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
what is ment by jdbc and how to connect with database?
what is ment by jdbc and how to connect with database?  i want answer for this question
export data from database to excel sheet - JDBC
export data from database to excel sheet  I am facing a problem about exporting required data from database table to ms-excel sheet.i mean whenever I execute a query then result will be display in MS-EXCEL sheet. please give me
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  Can any please help it is very urgent. I tried to read excel sheet using ODBC..."); Connection conn = DriverManager.getConnection("jdbc:odbc:excel
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please ans me why it is not connect i use netbeans IDE7.0 Jdk 1.7 i also add... support for JDBC 4.0. i try Avery thing but i m not success so please ans me . My
write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database
write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database
excel
excel  how to save excel sheet data into the database using poi api... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root...(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test
excel
excel  how to read columns values of excel file in java and store in array list in java like col1 col2 2 3 1 7 7 9 then list1 have values of col1 and list2 have values of col2...  
ModuleNotFoundError: No module named 'spreadsheet'
ModuleNotFoundError: No module named 'spreadsheet'  Hi, My Python... 'spreadsheet' How to remove the ModuleNotFoundError: No module named 'spreadsheet' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'spreadsheet'
ModuleNotFoundError: No module named 'spreadsheet'  Hi, My Python... 'spreadsheet' How to remove the ModuleNotFoundError: No module named 'spreadsheet' error? Thanks   Hi, In your python environment
How to connect with database
How to connect with database  jdbc connection
JDBC
JDBC  How to connect JAVA Servlet with the database
jdbc
how to connect JSP page to database - JDBC  how to connect JSP page to database ?give program
JDBC
"); Connection connect = DriverManager.getConnection("jdbc:mysql://localhost...retrieve the value from database into dropdown list using JDBC SQL 2005  How to retrieve the value from database into dropdown list using JDBC &
JDBC
JDBC  why we use batch in jdbc
jdbc
jdbc  Hai , Give a steps for jdbc connectivity
jdbc
jdbc  display the records using index in jdbc
JDBC
JDBC  How to add set of queries in a single query in JDBC
iRows
iRows       iRows is a web-based spreadsheet currently in beta with a GUI similar to the traditional desktop-based spreadsheet applications, such as Microsoft Excel and OpenOffice. Read
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
jdbc
jdbc  why do we need to load jdbc drivers before connecting to database
JDBC
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector

Ads