• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

help wanted

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am using MS Access as database and jdk 1.3 and i created a dsn called
akiladb and no description in the odbc dialog box. I created a directory called akiladb and storing a table employee in that.
The table employee contains name , empno,deptno,salary as fields and i have populated the table with 4 rows. i have written a program which is below and it compiles fine but gives runtime error as follows
[Microsoft][ODBC Microsoft Access Driver}
It may not be a database that your application recongnizes or the file may be corrupt.
This is the first time i am writing a JDBC application. Please correct me where i am wrong

The program is as follows.

import java.sql.*;
public class CreateCoffee {
public static void main(String args[]) {
String url = "jdbc dbc:akiladb";
Connection con;
String updateString;
updateString = "update employee " +
"set deptno=135 " +
"where name like 'akila'" ;
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url, "", "");
stmt = con.createStatement();
stmt.executeUpdate(updateString);
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out your DataSource in the ODBC Datasource Administrator.
Does your database name appear in the database frame
(eg. Database: c:\akiladb\akiladb.mdb)?
 
Lavanya Raman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi joe,
Thanks for your reply. my database appears in the ODBC Microsoft Access setup with the data source name as akiladb, description (nothing)
database
c:\akiladb\akiladb.mdb
and the system database selected as none.

please correct me wherever i am wrong.
thanks
akila
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your java code looks fine, the problem is on the Access side. You may want to verify that you can still view/update your data within MS Access (the error states that the data may be corrupt). If this is the problem then either try to use the REPAIR option or recreate the database and tables.
Keep me posted,
Joe
[This message has been edited by Joe Paolangeli (edited March 02, 2001).]
 
Lavanya Raman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,
I am able to read the database from MS access.
The database I have is in a directory c:\akiladb\db1.mdb
In my program, I have defined as follows :
String url = "jdbc dbc:akiladb";
and I am trying to connect to this to access
one of the .mdb files (db1.mdb) in my c:\akiladb. Is this
correct or do I need to specify absolute paths?
Thanks,
Akila.
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The path to the database is set in the ODBC Source Administrator.
As you stated before your database is located in the c:\akiladb directory. I am a little confused about the name of your database. Is the name db1.mdb or akiladb.mdb? Please verify that the correct database name is specified in the ODBC Source Administrator.
Keep me posted,
Joe
 
Lavanya Raman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Joe,
thanks for the reply. It was a mistake on my part. I have stored
my table in a different database and in the odbc setup i had specified a different database and so the error.i understood my mistake from your last reply.
Thanks a lot
akila
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic