Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
Problem in connecting Excel to Java
Rakesh Keerthi
Ranch Hand
Posts: 153
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
i'm trying to read the contents of my Excel through
Java
and i'm getting an Exception.
The code is as below.
import java.sql.*; public class Excel { public static void main(String[] args) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myDB = "jdbc:odbc:Driver={Microsoft Excel Driver (*xl, *.xls)};DBQ=D:/New.xls;" + "DriverID=22;READONLY=false"; Connection conn = DriverManager.getConnection(myDB, "", ""); Statement st=conn.createStatement(); ResultSet rs = st.executeQuery("select * from [Sheet1$]"); System.out.println(rs); } catch(Exception e){ System.out.println(e); } } }
the exception is as below.
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I'm using Java 32 bit, Eclipse 32 bit, Excel 32 bit and odbc5.jar. please let me know where am i going wrong.
Thanks
Roger Sterling
Ranch Hand
Posts: 426
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The error is pretty self-explanatory. " Data source name not found and no default driver specified".
When you call DriverManager.getDrivers() , what is returned in your list ?
Ulf Dittmer
Rancher
Posts: 43081
77
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The error message seems to be -at least partially- off-topic: no data source name is needed, as this is the DSN-less form of ODBC connection.
Apparently "{Microsoft Excel Driver (*xl, *.xls)}" is not recognized. Try "{Microsoft Excel Driver (*.xls)}" instead.
Rakesh Keerthi
Ranch Hand
Posts: 153
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you Dittmer this worked.
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Error in Connection
Applet Reading from Excel Sheet
data source name too long
Applet reading from Excel sheet
Display Select Query Result in JTable
More...