Results 1 to 7 of 7
- 01-20-2012, 04:13 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Windows 7 and Access 2010, Help Please...
I recently graduated from school with a Bachelors in Software Engineering...but one thing we didn't do much of was database connectivity, and what we did do was only with MySQL (we used Netbeans).
I'm looking at writing an application for my parents for maintaining their blood pressure and I currently have it working nicely with but it writes to a .doc file. I'd like to make it into a database, using Access since they already have it on their PC, but cannot seem to get the JDBC-ODBC connection to work properly.
I'm running Windows 7, and I have Access 2010. I've gone through using the SYSWOS64 odbccad32.exe file, and it shows up but I still get the error that there is no default driver.
Does anyone have a sample code with/without a database?
Here's what I have, I had gone through and created a BASIC database....just for testing purposes.
--------------------------------------------------------------------------------------------------------------------------------------------
public static void main(String[] args) {
//This application will test a connection to a MS Access DB
//jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=<full path to mdb file>;Uid=;Pwd=;"
Connection con;
Statement st = null;
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try {
Class.forName(driver);
File f = new File(System.getProperty("user.dir"));
con = DriverManager.getConnection("jdbc:odbc:Driver={Mic rosoft Access Driver (*.mdb, *.accdb)}; DBQ=C:\\Users\\Joe Chorba\\Documents\\BP_DATABASE.accdb", "", "");
//st = con. createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = st.executeQuery("select * from Table1");
System.out.println(rs);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
- 01-20-2012, 09:39 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Windows 7 and Access 2010, Help Please...
Can you provide the full stack trace and message for the error.
That error usually implies that your connection string is incorrect somewhere.
- 01-20-2012, 02:42 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: Windows 7 and Access 2010, Help Please...
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3073)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
at java.sql.DriverManager.getConnection(DriverManager .java:582)
at java.sql.DriverManager.getConnection(DriverManager .java:185)
at javaapplication10.JavaApplication10.main(JavaAppli cation10.java:32)
- 01-20-2012, 03:08 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Windows 7 and Access 2010, Help Please...
That's Microsoft complaining rather than JDBC.
So it's found the driver (that is the JDBC/ODBC one) but ODBC is having problems.
Have you tried creating a DSN for the database?
That would shorten it to jdbc:odbc:<dsn name>.
- 01-20-2012, 05:23 PM #5
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: Windows 7 and Access 2010, Help Please...
So I'm changing this line:
con = DriverManager.getConnection("jdbc:odbc:Driver={Mic rosoft Access Driver (*.mdb, *.accdb)}; DBQ=C:\\Users\\Joe Chorba\\Documents\\BP_DATABASE.accdb", "", "");
to:
con = DriverManager.getConnection("jdbc:odbc:<dsn name>", "","");
???
Is this right?
- 01-20-2012, 05:30 PM #6
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: Windows 7 and Access 2010, Help Please...
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3073)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
at java.sql.DriverManager.getConnection(DriverManager .java:582)
at java.sql.DriverManager.getConnection(DriverManager .java:185)
at javaapplication10.JavaApplication10.main(JavaAppli cation10.java:32)
BUILD SUCCESSFUL (total time: 0 seconds)
I added a screen capture so you can see the ODBC Administrator Screens...
Last edited by JoeyChorba; 01-20-2012 at 05:50 PM. Reason: Adding screenshot
- 01-22-2012, 05:35 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
Connect to Access 2010 DB file (.accdb)
By rockspud5693 in forum New To JavaReplies: 2Last Post: 01-04-2012, 09:39 AM -
Render Japanese Characters & Access Presentation in PowerPoint 2010
By sherazam in forum Java SoftwareReplies: 0Last Post: 08-09-2011, 08:47 AM -
Access Windows xp from Unix machine
By mchhapolia in forum Advanced JavaReplies: 2Last Post: 04-15-2009, 02:04 AM -
How to access driver in Windows like a file?
By pthoonen in forum New To JavaReplies: 6Last Post: 01-15-2009, 03:28 AM -
Access Linux shared folder from Windows OS
By nitinpjairaj in forum NetworkingReplies: 3Last Post: 08-26-2008, 06:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks