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
What is encrypted connection?
What is the purpose of jdbc resultset interface?
How can you know about drivers and database information ?
Why resultset is used in java?
What is jdbc connection interface?
What are the new features available in jdbc 4.0?
What is represented by the connection object?
Does JDBC support stored procedures?
Is there another way of dealing with the result set that could execute faster?
How do I load a database driver with JDBC 4.0 / Java 6?
What is executeupdate in java?
What is jdbc architecture?
What is difference between odbc and jdbc?
Why we use jdbc instead of odbc?
How do I find whether a parameter exists in the request object?