connect jdbc to an Excel spreadsheet

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









Related Tutorials/Questions & Answers:
connect jdbc to an Excel spreadsheet
connect jdbc to an Excel spreadsheet  hello, How can I connect to an Excel spreadsheet file using jdbc?   Hello Friend,ADS_TO_REPLACE_1... Select Microsoft Excel Driver(*.xls) Select work book or excel file and Create
how to connect xlsx(2007 excel) - JDBC
how to connect xlsx(2007 excel)  i am not able connect to office 2007 excel file from jdbc
Advertisements
XLS JDBC Example
to connect your excel spreadsheet . The name of the worksheet is equivalent... .style1 { background-color: #FFFFCC; } XLS JDBC XlS JDBC driver is used to access xls file from java application. It is read only JDBC driver
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
JDBC to EXcel
JDBC to EXcel  How to insert data in excel sheet from java
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
Use JDBC to connect Microsoft Access
Use JDBC to connect Microsoft Access  How to use JDBC to connect Microsoft Access
how to connect mysql with JDBC - JDBC
how to connect mysql with JDBC  I have created three tables in the database MYsql, i have to connect them now using JDBC, can u please suggest me...(); } } Thanks Rajanikant  Hi friend, To mysql connect using JDBC
could not connect to the server - JDBC
could not connect to the server  Hii sir, I am working with a JBDC program now. Now i am trying to host it. when i am trying to connect...: Connection timed out: connect STACKTRACE: java.net.SocketException
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
cannot connect to database - JDBC
cannot connect to database  Iam using eclipse in my system ,when connecting the database mysql version 5.0 to the eclipse iam getting an error as ""Creating connection to mysql has encountered a problem.Could not connect to mysql
Java and excel - JDBC
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 tried using the following code but it gives me a distorted records in excel
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
exporting data to excel sheet - JDBC
exporting data to excel sheet  Sir i have already send request about... query in java swing program,i want to print the result about the query in excel... = wb.createSheet("Excel Sheet"); try{ Connection con = null
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
Access Excel file through JDBC
Access Excel file through JDBC In this section, you will learn how to access excel file through Jdbc and display records in JTable. As you know Excel comes with an ODBC driver, so we are using JDBC-ODBC bridge driver to connect jdbc
Connect to MS Acces wothout using ODBC but JDBC - JDBC
Connect to MS Acces wothout using ODBC but JDBC  Hi, I want to connect my MS Access using JDBC but not ODBC. Please help me out. Thanks
java + excel data +graph - JDBC
java + excel data +graph  i am doin' a project in which i need to take up data from excel sheets and work upon them mathematically and finally draw a graph with the facility of drawing a trendline(in the graph)...also i need
can't connect to MySQL Server(10060) - JDBC
can't connect to MySQL Server(10060)  Hii Sir, I am working... MySQL front end. Can we connect to the MySQL server using the I.P address... write as the subject. Can we connect thorugh a MySQL Frontend. Kindly
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 connect swings with jdbc... - Java Beginners
how to connect swings with jdbc...  Hi friends, Is it possible, to connect swings with data base like oracle....i want to store data into database..."); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test
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
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
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 can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc
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 'google_spreadsheet'
ModuleNotFoundError: No module named 'google_spreadsheet'  Hi, My... named 'google_spreadsheet' How to remove the ModuleNotFoundError: No module named 'google_spreadsheet' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google_spreadsheet'
ModuleNotFoundError: No module named 'google_spreadsheet'  Hi, My... named 'google_spreadsheet' How to remove the ModuleNotFoundError: No module named 'google_spreadsheet' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'o2-google-spreadsheet'
ModuleNotFoundError: No module named 'o2-google-spreadsheet'  Hi...: No module named 'o2-google-spreadsheet' How to remove the ModuleNotFoundError: No module named 'o2-google-spreadsheet' error? Thanks   Hi
ModuleNotFoundError: No module named 'spreadsheet-maker'
ModuleNotFoundError: No module named 'spreadsheet-maker'  Hi, My... named 'spreadsheet-maker' How to remove the ModuleNotFoundError: No module named 'spreadsheet-maker' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Spreadsheet-HTML'
ModuleNotFoundError: No module named 'Spreadsheet-HTML'  Hi, My... named 'Spreadsheet-HTML' How to remove the ModuleNotFoundError: No module named 'Spreadsheet-HTML' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'spreadsheet-maker'
ModuleNotFoundError: No module named 'spreadsheet-maker'  Hi, My... named 'spreadsheet-maker' How to remove the ModuleNotFoundError: No module named 'spreadsheet-maker' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'bluesky-spreadsheet'
ModuleNotFoundError: No module named 'bluesky-spreadsheet'  Hi, My... named 'bluesky-spreadsheet' How to remove the ModuleNotFoundError: No module named 'bluesky-spreadsheet' error? Thanks   Hi
ModuleNotFoundError: No module named 'google_spreadsheet'
ModuleNotFoundError: No module named 'google_spreadsheet'  Hi, My... named 'google_spreadsheet' How to remove the ModuleNotFoundError: No module named 'google_spreadsheet' error? Thanks   Hi, In your
How to connect with database
How to connect with database  jdbc connection
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
JDBC Query to Connect Database  JDBC Query to connect to database  will u supply me the block of code where it throws the exception
Possibility of Creating a Spreadsheet in Java? - Java Beginners
Possibility of Creating a Spreadsheet in Java?  Is it possible to create a spreadsheet (like MS Excel) in java?   hi friend This code... = wb.createSheet("Excel sheet"); HSSFRow row = sheet.createRow((short)0); HSSFCell
Version of com.supwisdom>spreadsheet-mapper-parent dependency
List of Version of com.supwisdom>spreadsheet-mapper-parent dependency
ModuleNotFoundError: No module named 'django-spreadsheet-reports'
ModuleNotFoundError: No module named 'django-spreadsheet-reports'  Hi...: No module named 'django-spreadsheet-reports' How to remove the ModuleNotFoundError: No module named 'django-spreadsheet-reports' error? Thanks
ModuleNotFoundError: No module named 'django-spreadsheet-reports'
ModuleNotFoundError: No module named 'django-spreadsheet-reports'  Hi...: No module named 'django-spreadsheet-reports' How to remove the ModuleNotFoundError: No module named 'django-spreadsheet-reports' error? Thanks

Ads