Results 1 to 2 of 2
  1. #1
    sweetvalley is offline Member
    Join Date
    Mar 2016
    Rep Power

    Default eBay JDBC - Null pointer exception

    I am attempting to download the results from eBay GetSellerTransactions, and insert the results in an Access database. I am able to return results into a Java table, however, I can't seem to find how to insert the results into an Access database. The ODBC connection is fine in a test example, so I think the error is not the connection to the database, but rather pulling the data from eBay.

    With this code, I am receiving a null pointer exception:

    Java Code:
       public void UpdateAccess() throws Exception{
             Connection con=null;
             PreparedStatement stamt=null;
             String dataSourceName = "JdbcOdbc";
             String dbURL = "jdbc:odbc:" + dataSourceName;
             con = DriverManager.getConnection(dbURL);
             StringBuilder insertQuery=new StringBuilder("INSERT INTO tblTest ")
                     .append("(TestField) ")
                     .append("VALUES (?);");
             //Null pointer exception starts here I believe
             TransactionType transa = new TransactionType();
             UserType buyer = transa.getBuyer();
             String FirstName = buyer.getUserFirstName();
             stamt.setString(0, FirstName); 
                    catch (Exception err) {
                 System.out.println("ERROR: " + err);
                 try{con.close();} catch(Exception e){System.out.println("ERROR: " + e);}}

    This is how I am calling this method, after the display results Java command:

    Java Code:
          // Display results.
               this.txtHasMoreItems.setText(api.getHasMoreTransactions() ? "yes" : "no");
                 pnresult.getTotalNumberOfPages() == null ? "" : pnresult.getTotalNumberOfPages().toString());
               String actualCountTxt = new Integer(api.getReturnedTransactionCountActual()).toString();
               //Update Access

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: eBay JDBC - Null pointer exception

    Your stack trace from the exception should tell you exactly where the error is occurring.
    You'll need to change the catch block to show that.
    Java Code:
    catch (Exception ex) {
    You shouldn't really be catching Exception, but the specific exceptions thrown by the resources you're using (SQLException and whatever the eBay code throws). Catching all Exceptions is a bad habit to get into. You want your code to fail on an NPE, not to keep going.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Null Pointer Exception
    By jameshl2008 in forum New To Java
    Replies: 6
    Last Post: 10-22-2013, 03:56 PM
  2. null pointer exception
    By Herah in forum New To Java
    Replies: 1
    Last Post: 12-01-2011, 09:44 AM
  3. Jdbc null pointer exception
    By miko5054 in forum New To Java
    Replies: 3
    Last Post: 02-24-2011, 01:06 PM
  4. Null Pointer Exception
    By ScKaSx in forum New To Java
    Replies: 1
    Last Post: 01-24-2009, 12:27 PM
  5. Null Pointer Exception
    By Jacinth in forum New To Java
    Replies: 4
    Last Post: 01-22-2009, 02:47 PM

Tags for this Thread

Posting Permissions

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