Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't connect to Access database using Cloudscape

 
Jodie Anderson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have the following code:
import java.sql.*;
public class Exercise2_1 {
static String driver = "COM.cloudscape.core.JDBCDriver";
static String url = "jdbc:cloudscape:c:/j2sdkee1.3/cloudscape/test2";
public static void main(String[] args) {
try{
Class.forName(driver).newInstance();
System.out.println("Loaded driver");
Connection conn = DriverManager.getConnection(url);
System.out.println("Connected to database");
conn.close();
System.out.println("Closed connection");
}
catch(Throwable e)
{System.err.println(e.getMessage());}
}
}
The driver loads fine.
However, I get an error message saying "Can't find database" (the Access
database does exist in the given directory above!)
Is the fact that it is an Access db an issue? If so, how can I resolve this
issue?
Any info would be great, as I am at a loss here!
Thanks in advance!
 
Sean Richards
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to connect to an Access database you must first set up the DSN in ODBC. Then you must use the appropriate driver for Access. You cannot connect to an access database using a cloudscape driver. the right driver to use is
String driver = "Sun.jdbc.odbc.JdbcOdbcDriver"
String url = "jdbc dbc SNNAME"
The DSNNAME is the name you choose to use for your database.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic