Results 1 to 7 of 7
- 03-27-2010, 11:49 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 12
- Rep Power
- 0
Issue with MS Access database and a JAR
Hi all,
I'm working on a program that is basically just an interface for entering values into a Microsoft Access database. Every part of the program works properly in Eclipse, but when I export it to a runnable Jar file, it seems to get hung up on the location of the database.
The program establishes the location of the database at startup by reading the contents of a text file located in the same directory as the program. A string is created, and is passed to constructor of the class which establishes the database connection. I know that it IS reading from the location file while in JAR form.
Now, the rest of the program works in every way, but a connection to the database can never be made when in JAR form.
Since I can't reproduce this in Eclipse, I ran the JAR from the command line and this is the error it produces:
Java Code:java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source) at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source) at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at Lamp.<init>(Lamp.java:26) at Main.main(Main.java:38)
Anyone have any ideas? I think this all worked as a JAR on a Windows XP machine I was on, but not on my 7 machine. I might be wrong though.
Thanks.
- 03-28-2010, 07:49 PM #2
Member
- Join Date
- Mar 2010
- Posts
- 12
- Rep Power
- 0
If it helps, here is the class that makes the connection. Just can't imagine what it is about the JAR that's keeping this from working. :
Java Code:public class Lamp { private static Statement s; public static Connection con; private static PreparedStatement updateComments; public static ResultSet rs; static ResultSet hoursSet; static ResultSet roomSet; static ResultSet locationSet; public Lamp(String path) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String filename = path; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=false}"; con = DriverManager.getConnection(database ,"",""); s = con.createStatement(); } catch(Exception e) { //JOptionPane.showMessageDialog(null,"Invalid database path." + //"\n--Lamp()", "", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }
- 03-29-2010, 10:34 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 12
- Rep Power
- 0
One other update:
It does work on my Windows XP machine, with one exception. It seems that the connection to the database does not close when on XP. At least this is what I assume is happening when I close the program and the little icon that says, "Microsoft Access Record-Locking Information" still remains. I have to open the database and close it again for the icon to disappear.
Once again, these problems only manifest themselves when the program is run in JAR form.
- 04-06-2010, 02:56 AM #4
Member
- Join Date
- Mar 2010
- Posts
- 12
- Rep Power
- 0
Problem fixed itself. Weird ... oh well.
- 02-16-2011, 08:23 PM #5
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
The Jar does not work with MS Access
Now I have the same problem. Can you tell me how you did it?
Please help me. is very urgent.....
- 02-16-2011, 08:29 PM #6
Member
- Join Date
- Mar 2010
- Posts
- 12
- Rep Power
- 0
I'm terribly sorry to tell you this, but like my previous response said, it just kind of fixed itself. It's been quite awhile since I was working with the program, so I don't remember everything that went on too clearly.
My only guess was that it was a Java update that occurred, if that even makes any sense.
If it helps you can PM me your email address, and I'll send the source code with some explanation your way. Maybe you'll find something that helps.
- 02-16-2011, 08:40 PM #7
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
java with access database
By ashin in forum SWT / JFaceReplies: 4Last Post: 07-12-2009, 05:04 PM -
How to convert access database to mysql database?
By vrk in forum Advanced JavaReplies: 2Last Post: 02-11-2009, 04:43 AM -
SQL database issue
By Dublin_kopite in forum New To JavaReplies: 1Last Post: 02-04-2009, 05:34 PM -
Database access
By Doctor Cactus in forum New To JavaReplies: 1Last Post: 12-12-2008, 01:30 PM -
Help with access a database using Microsoft Access
By cachi in forum JDBCReplies: 1Last Post: 08-07-2007, 07:51 AM


LinkBack URL
About LinkBacks

Bookmarks