Question: I want to print my result of the query to .txt file.
How to do it? i try to print it with or without .tostring, but it's still not the result i want.

Here is my code 

```
try {
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ta", "root", "root");
    Statement st = con.createStatement();
    String query = "select count(no) as 'jumlah',kelompok from email group by kelompok";
    //System.out.println(query);
    ResultSet rs = st.executeQuery(query);

    while (rs.next()) {
        dataset.setValue( Integer.parseInt(rs.getString(1)), "Jumlah", rs.getString(2));
    }
    try {
        PrintStream out = new PrintStream(new FileOutputStream("OutFile.txt"));
        String jumlahemail = "select count(*) from email";
        ResultSet rs1 = st.executeQuery(jumlahemail);
        out.println("E-mail yang diterima adalah sebanyak: "+rs1.toString());
        out.println("Dengan detail: ");
        out.println(rs.toString());
        out.close();
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    }
} catch (SQLException ex) {
    Logger.getLogger(GUI.Home.class.getName()).log(Level.SEVERE, null, ex);
}

```

the result of this is:

```
E-mail yang diterima adalah sebanyak: com.mysql.jdbc.JDBC4ResultSet@81c868
Dengan detail: 
com.mysql.jdbc.JDBC4ResultSet@8c241a

```

how to do this properly?

Answer: 
This is a change in Apache 2.4.

This is from [Apache HTTP Server Documentation Version 2.4](ftp://ftp.osuosl.org/pub/apache/httpd/docs/httpd-docs-2.4.25.en.pdf):

> 
> MOD CGI, MOD INCLUDE, MOD ISAPI, ... Translation of headers to environment variables is more strict than before
>  to mitigate some possible cross-site-scripting attacks via header injection. Headers containing invalid characters
>  ***(including underscores)*** **are now silently dropped**. Environment Variables in Apache (p. 81) has some pointers
>  on how to work around broken legacy clients which require such headers. (This affects all modules which use
>  these environment variables.)
> 
> 
> 

– Page 11

> 
> For portability reasons, the names of environment variables may contain only letters, numbers, and the underscore character. In addition, the first character may not be a number. **Characters which do not match this restriction will be replaced by an underscore** when passed to CGI scripts and SSI pages.
> 
> 
> 

– Page 86

A pretty significant change in other words. So you need to rewrite your application so send dashes instead of underscores, which Apache in turn will substitute for underscores.

**EDIT**

There seems to be a way around this. If you look at [this document](http://httpd.apache.org/docs/current/env.html#examples) over at apache.org, you can see that you can fix it in `.htaccess` by putting the value of your `foo_bar` into a new variable called `foo-bar` which in turn will be turned back to `foo_bar` by Apache. See example below:

```
SetEnvIfNoCase ^foo.bar$ ^(.*)$ fix_accept_encoding=$1
RequestHeader set foo-bar %{fix_accept_encoding}e env=fix_accept_encoding

```

The only downside to this is that you have to make a rule per header, but you won't have to make any changes to the code either client or server side.
Are you sure Django didn't get upgraded as well?

<https://docs.djangoproject.com/en/dev/ref/request-response/>

> 
> With the exception of CONTENT\_LENGTH and CONTENT\_TYPE, as given above, any HTTP headers in the request are converted to META keys by converting all characters to uppercase, replacing any hyphens with underscores and adding an HTTP\_ prefix to the name. So, for example, a header called X-Bender would be mapped to the META key HTTP\_X\_BENDER.
> 
> 
> 

The key bits are: Django is converting '-' to underscore and also prepending 'HTTP\_' to it. If you are already adding a HTTP\_ prefix when you *call* the api, it might be getting doubled up. Eg 'HTTP\_HTTP\_SPECIES'