Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

give me a java code snippet to connect Microsoft excel
through.... I am trying alot... plz help me.

Answer Posted / vijay

import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;

public class EmployeeReader1 {
public static void main(String[] args) {
Connection connection = null;
try {
Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager
.getConnection
("jdbc:odbc:friends_exl");
Statement st = con.createStatement
();
ResultSet rs = st.executeQuery
("Select * from [Sheet1$]");

ResultSetMetaData rsmd =
rs.getMetaData();
int numberOfColumns =
rsmd.getColumnCount();

System.out.println("No of cols " +
numberOfColumns);

while (rs.next()) {
for (int i = 1; i <=
numberOfColumns; i++) {
if (i > 1)

System.out.print(", ");
String columnValue
= rs.getString(i);
System.out.print
(columnValue);
}
System.out.println("");
}
rs.close();
st.close();
} catch (Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does adapter class provide?

886


Explain jdbc savepoint?

920


What are dml and ddl?

941


What is metadata in java programming?

958


How do I start debugging problems related to the JDBC API?

967


Explain what should be done when a SQL exception is raised?

928


What is db client?

915


Is odbc an api?

992


Which is best database for java?

933


What is resultset in jdbc with example?

879


Explain the life cycle of jdbc.

988


What is the function of setautocommit?

1162


What is meant by dao?

894


Where is jdbc url mysql?

928


What should be done for auto generating primary key id in a table ?

919