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

    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 {
    catch (ClassNotFoundException e) {

    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
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:171)
    at JDBC.main(

    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 17: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