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 jdbc driver in java?
Which jdbc driver type s is are the jdbc odbc bridge?
Explain how to make updates to the updatable resultsets.
When do we use execute method in java jdbc?
Which type of driver is unique in jdbc?
What is a datasource in java?
How to connect multiple database in jdbc?
How do we call a stored procedure from jdbc?
Is jpa faster than jdbc?
How can I determine the isolation levels supported by my DBMS?
How many types of statements are there in jdbc?
Why do you use a data source object for a connection?
What is statement and resultset in jdbc?
What does the jdbc resultsetmetadata interface?
What does the jdbc connection interface?