Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: NullPointerException on connection

    I'm having some issues trying to connect to my database...

    here's the sample code that I'm using to test the connection:

    import java.sql.*;
    import java.util.*;

    class JDBC {

    public static void main (String args[]) throws SQLException {

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch (ClassNotFoundException e) {
    System.err.println(e.getMessage());
    }

    Connection conn = null;

    String user = "xxxxx";
    String password = "yyyyy";
    String url = "jdbc:odbc:Flights";

    conn = DriverManager.getConnection(url, user, password);
    }
    }


    and I'm getting the following errors when I attempt to run this.


    Exception in thread "main" java.lang.NullPointerException
    at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDr iver.java:436)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:153)
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:171)
    at JDBC.main(JDBC.java:19)


    is there something that I'm not doing correctly or that I'm just not seeing? I've gone through a lot of other tutorials on connecting to an SQL database using JDBC and I don't really see anything wrong with this. Any suggestions are appreciated thx.
    Last edited by p2wang; 03-01-04 at 18:36.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •