I'm still having trouble accessing a database from java. I added the
correct file to all the dsn i could find in the odbc window under
control panel. Anyone know what i could be doing wrong? Hers is my
code and throws an error on line 12 where i use getConnection:
Plz help cause this is very important in an project i'm working on.
import java.sql.*;
public class Lookup
{
public static void main (String [] args)
{
String dbUrl = "jdbc:odbc:StelliesXP-2003-05-21.mdb";
try
{
Class.forName (
"sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection (
dbUrl, " ", " ");
Statement s = c.createStatement ();
ResultSet r =
s.executeQuery (
"SELECT FIRST, LAST, EMAIL " +
"FROM StelliesXP-2003-05-21.mdb persone " +
"WHERE " +
"(LAST='" + args [0] + "') "
);
while (r.next ())
{
System.out.println (
r.getString ("Last") + ", "
+ r.getString ("First")
+ ": " + r.getString ("EMAIL"));
}
s.close ();
}
catch (Exception e)
{
e.printStackTrace ();
}
}
}