Skip to main content

Mysql Memory

No replies
carachi83
Offline
Joined: 2011-02-15
Points: 0

Hello everybody,

I'm new in java and I have some problem with Mysql and memory ResultSet.

I configure my project with Mysql and the driver connector and I wrote my SQL query.

I create a Class call Database and I open the connection when the project start and I execute the query with this method:

<span class="Apple-tab-span" style="white-space:pre">    </span>public class Database {
...
public ResultSet select(String query) {

<span class="Apple-tab-span" style="white-space:pre"> </span> try {

      Statement stmt=this.CONNECTION.createStatement();

       ResultSet risultato = (stmt.executeQuery(query));

<span class="Apple-tab-span" style="white-space:pre"> </span>      return risultato;

   <span class="Apple-tab-span" style="white-space:pre"> </span>} catch (SQLException ex) {

       return null;

<span class="Apple-tab-span" style="white-space:pre"> </span>   }

    return null;
}
...
}

But I see with jconsole that my memory arise every times that the server make a SQL select.

I also try to create a connection and statement every time that the program have to make a query and the memory in costant, but the connections on Mysql arise a lot because I receive a lot of request in few time.

How can I solve this problem?

Exist a method to flush the ResultSet in Mysql ??

Thank you bye.