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

Answer Posted / n.gowtham raj

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:gowtham");
Statement st = con.createStatement
();
ResultSet rs = st.executeQuery
("select * from [Sheet1$]");

while(rs.next())
{
System.out.println
("USER ID:"+rs.getString("ID"));
}

rs.close();
st.close();
} catch (Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}

Step 1: goto control panel and select the Administrative
Tools and click the odbc driver.
Step 2: Then click the add button and select the microsoft
excel driver (".xls")
Step 3: then give the dsn name. (gowtham).
Step 4: then click the select workbook button and choose
the excel file then it work well.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which database is used for java?

680


Is jdbc faster than hibernate?

728


Write a program JDBCcode forfetching student database with SQL.

762


What is executeupdate in java?

623


Differentiate between type_scroll_insensitive and type_scroll_sensitive.

696






Explain the life cycle of jdbc.

791


Define preparedstatement.

708


What is the execute method in java?

710


What are different types of JDBC Drivers?

687


What is a jdbc driver and how many jdbc drivers are available?

751


How to move the cursor in scrollable resultset ?

760


What are the different types of statements in jdbc?

655


Is jdbc object oriented?

663


Name different methods for getting streams.

712


Describe odbc?

717