Re: Problems with Windows Memory executing java program
The class that I use for execute a query on a mysql database is:
<CODE>
package tk_data_3_0b;
import java.sql.*;
public class ExecuteQueryDB {
String Val_min;
String Val_max;
String S_max;
String param1;
String param2;
String param3;
String param4;
String param5;
String param6;
String param7;
String param8;
String param9;
String param10;
String param11;
String param12;
String param13;
String param14;
ResultSet resultset;
public ExecuteQueryDB (String sql, int nparam){
String DRIVER = "com.mysql.jdbc.Driver";
String DB_URL = "jdbc:mysql://localhost:3306/db";
try {
Class.forName(DRIVER);
Connection connection = null;
try {
connection = DriverManager.getConnection( DB_URL, "user", "pw");
Statement statement = connection.createStatement();
resultset = statement.executeQuery(sql);
while (resultset.next()) {
switch (nparam){
case 1:{
param1 = resultset.getString(1);
break;
}
case 2:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
break;
}
case 3:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
break;
}
case 4:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
break;
}
case 5:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
break;
}
case 6:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
break;
}
case 7:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
break;
}
case 8:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
break;
}
case 9:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
break;
}
case 10:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
param10 = resultset.getString(10);
break;
}
case 11:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
param10 = resultset.getString(10);
param11 = resultset.getString(11);
break;
}
case 12:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
param10 = resultset.getString(10);
param11 = resultset.getString(11);
param12 = resultset.getString(12);
break;
}
case 13:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
param10 = resultset.getString(10);
param11 = resultset.getString(11);
param12 = resultset.getString(12);
param13= resultset.getString(13);
break;
}
case 14:{
param1 = resultset.getString(1);
param2 = resultset.getString(2);
param3 = resultset.getString(3);
param4 = resultset.getString(4);
param5 = resultset.getString(5);
param6 = resultset.getString(6);
param7 = resultset.getString(7);
param8 = resultset.getString(8);
param9 = resultset.getString(9);
param10 = resultset.getString(10);
param11 = resultset.getString(11);
param12 = resultset.getString(12);
param13= resultset.getString(13);
param14 = resultset.getString(14);
break;
}
}
}
} catch (SQLException e) {
e.toString() ;
System.out.println(e);
} finally {
try{
connection.close();
}catch (SQLException e) {e.toString();
System.out.println(e);}
}
}catch (ClassNotFoundException e) {
e.toString();
System.out.println(e);}
}
}
</CODE>
and i call this class with:
<CODE>
ExecuteQueryDB exqimp =new ExecuteQueryDB("SELECT column FROM table)",
1);
</CODE>
The problem can be here?
Thanks
Sal