Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:19:37+00:00 2026-06-04T14:19:37+00:00

I have a method of editing members, and I want to print out errors

  • 0

I have a method of editing members, and I want to print out errors into a file, but I keep getting the void cannot be dereferenced error if I try to print out the stack trace into a Error_Report.txt file. Is there anyway I can print it out?
This is my code.

public void edit() {
  FileWriter fw = new FileWriter(new File("Error_Report.txt"));
  Connection con;
  Statement stmt;
  ResultSet rs;

  int id = (int)_id.getSelectedItem();
  String name = _name.getText();
  String user = _username.getText();
  String pass = _password.getText();
  String pos = _position.getSelectedItem().toString();

  try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:collegesys", 
                                      "root", "0blivi0n");

    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                               ResultSet.CONCUR_READ_ONLY);

    PreparedStatement prep = con.prepareStatement("UPDATE `main` WHERE ID = ?");
    prep.setInt(1, id);
    prep.setString(2, name);
    prep.setString(3, user);
    prep.setString(4, pass);
    prep.setString(5, pos);

    prep.execute();
  } catch(SQLException sqle) {
    String sql = sqle.printStackTrace().toString();
    fw.write("" + sql);
  } catch(ClassNotFoundException cnfe) {
    fw.write("" + cnfe);
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:19:38+00:00Added an answer on June 4, 2026 at 2:19 pm

    Your problem is that printStackTrace doesn’t return anything, so there’s nothing to convert to a string. Write it like this.

    PrintWriter writer = new PrintWriter(fw);
    sqle.printStackTrace(writer);
    writer.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a custom tableviewcell and override the method - (void) setEditing:(BOOL)editing animated:(BOOL)animated
I have a text editing program that hands out cursors to other parts of
I use NSString stringWithFormat method for create an URL string. But now I have
I have a method that I want to expand (rather than writing a new
I have a jqgrid from trirand (asp.net version) and cannot work out how to
I have method that returns Drawable , and if its Bitmap object is recycled
I have method that returned NSManagedObject and I don't know what kind of NSManagedObject
I have method with two parameters: bool1 and bool2. Both are boolean of course.
I have method that returns module path of given class name def findModulePath(path, className):
I have method in a class that I need to make sure is only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.