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 are the common JDBC problems that you got and how do you solved them?
What is jdbc class forname?
When do we get java.sql.SQLException: No suitable driver found?
What is xe in oracle jdbc url?
What is jdbc stand for?
Can I enable requests to a jdbc connection pool for a database connection to wait until a connection is available?
What is connection pooling and why it is used?
What are the ddl statements?
Which constraint cannot be specified as an explicit constraint and should be specified with the column only ?
How many types of jdbc drivers are there?
List the advantages of using datasource?
How to connect html page to database using jdbc?
How can I instantiate and load a new CachedRowSet object from a non-JDBC source?
What are the different classes through which JDBC represents statements?
What is jdbc in java?