1

I have created the connection and reading the data from excel sheet using jdbc connection.But now i have two read two more excel sheets.

Should i create one more connection for another sheet access via jdbc ? Please advise

7
  • 2
    Why not use apache-poi (or any other library?). Is using JDBC is a requirement? Commented Nov 30, 2012 at 5:38
  • Do you want to read one more sheet from the same excel file or an extra excel file ? Commented Nov 30, 2012 at 5:42
  • @Jayan using the apache poi requires validation of cell values where as JDBC type just gives data as per query Commented Nov 30, 2012 at 5:43
  • I second to Jayan's advice its much easier than doing all the database config for different excel files. i have used Apache Poi along with Apache Camel to read 1000's of excel files at a time, works like a charm with minimal code and no config. Commented Nov 30, 2012 at 5:43
  • I agree apache poi much easier compare to JDBC.But i have excel sheet with old and unwanted data.So i need to read the latest and necessary data from the excel sheet. Commented Nov 30, 2012 at 5:56

1 Answer 1

1

Assuming you created a DSN to the first excel sheet and reading it using JDBC-ODBC bridge, you need to create another DSN for the other excel sheet and create a connection with this DSN (and not with the DSN to first file) and read the other excel sheet from this connection.

This is similar to reading from a different database altogether that requires a different JDBC URL to be constructed with the second DB-specific values.

Sign up to request clarification or add additional context in comments.

3 Comments

i guess your link is broken
@Vikdor , I'm having two DSN name mapped to two excel sheets.But you said connection for only one DSN name is enough.How is poissble to read another excel sheet coumns with havening the connection ? Connection con = DriverManager.getConnection("jdbc:odbc:[B]worcester[/B]");
No, I meant to say that you have to establish two different connections, one for each DSN. Since you have already created two DSNs for those files, create two connections with respective DNS in the JDBC URL and use them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.