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 type 1 driver and i have done successfully.but disadvantage is when i create a executabloe jar for this .it is working in my system only .since the odbc coneecction is their in my system only.if i want to work in my colleagues system i need to connect same DNS name in my colleague system also .So, this is the problem.
so, can any one help me without creating DNS we should retrieve data from excel using ODBC.plz help me guys..........
View Answers
October 17, 2011 at 11:34 AM
Follow these steps:
Open Data Sources (Start->Settings->Control Panel->Administrative Tool->Data Sources(ODBC)
Open User DSN tab
Add a user DSN
Select Microsoft Excel Driver(*.xls)
Select work book or excel file and Create the DSN name (e.g excel)
Click "Ok" and restart your compiler.
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.
October 17, 2011 at 2:20 PM
Sir,
Actually i too know how to read data using type 1 driver.sir,you have given procedure to do is done right but u have used type 1 driver but i want to do this using type 2 or type 4 driver (i.e nothing but not to create DNS in local system) the program should automatically do DNS creation and them access excel data and should given output of reading data in console.
thnx for write some answer that u know...
Ads
Related Tutorials/Questions & Answers:
how to set fetch size for jdbc odbc driver
how to set fetch size for
jdbc odbc driver What is the default fetch size for the
JDBC ODBC driver and
how can i fetch a set of results for
JDBC ODBC driver?
Fetching results
JDBC ODBC Driver
A. The default fetch
Advertisements
HOW TO SAVE XML INTO MYSQL AND RETRIEVE IT USING JAVA
HOW TO SAVE XML INTO
MYSQL AND
RETRIEVE IT
USING JAVA H ello, i have an xml code, i need to save it into
mysql 5.5 server database
using java. i also want to be able to
retrieve it as well. please note that i want it saved
retrieve related data from database using jsp and mysql
retrieve related
data from database
using jsp and mysql Hi sir,
please give some example of jsp code for retrieving
mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
JDBC-Odbc Connection
JDBC-
ODBC Connection
JDBC-
ODBC Connection is a
JDBC driver that translates
the operation... in explaining
JDBC Odbc Connection in Java. The code
explains you a
how creation
How To Retrieve Image From From MySQL Using Java
How To
Retrieve Image From From
MySQL Using Java
In this section we will discuss about
how to
retrieve image from the
MySQL
using Java.
This example explains you about all the steps that
how to
retrieve image from
MySQL database
jdbc odbc
jdbc odbc i have two tables in database 1table's attribute is foreign key of another
in this case
how to retrive value from both table and show in a gridview combine
using java code
Sql query to
retrieve values
Data retrieve from mysql database
Data retrieve from
mysql database Hi sir,
please give some example...("name").toString();
String
data="";
Connection conn = null;
String url = "
jdbc:
mysql://localhost:3306/";
String dbName = "test";
String
driver
How To Use Database Driver
to interact with database. In
JDBC there are four types Database
driver
Type 1:
JDBC-
ODBC Bridge
driver
Type 2: Native-API/partly Java
driver
Type 3... to
connect to an application to database
using type 4
driver you must need to load
Identify Excel's cell data type
Identify
Excel's cell
data type
In this section, you will learn
how you can identify cell's
data type and
handle it appropriately
using Apache POI.
In Apache POI library, for fetching each
type of
data, there is separate