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
explain about special characters?
What are the different types of JDBC drivers?
What is JDBC RowSet? What are different types of RowSet?
How can I determine the isolation levels supported by my DBMS?
What is JDBC ResultSet?
What is database deadlock ?
Can I enable requests to a jdbc connection pool for a database connection to wait until a connection is available?
What is the use of callablestatement? Name the method, which is used to prepare a callablestatement.
What is the meaning of batch updates?
What driver should I use for scalable Oracle JDBC applications?
What isolation level is used by the DBMS when inserting, updating and selecting rows from a database?
How to test jdbc connection to sql server?
Under what circumstances, that all four drivers are used?
What is the JDBC?
What is metadata in jdbc?