Probleme java out of memory : java heap: comment on fait pour allouer de la memo

tomski Messages postés 48 Date d'inscription mercredi 24 mars 2004 Statut Membre Dernière intervention 24 décembre 2009 - 4 sept. 2009 à 13:10
kirua12 Messages postés 1155 Date d'inscription samedi 17 janvier 2004 Statut Membre Dernière intervention 29 avril 2011 - 10 sept. 2009 à 10:00
Salut a tous,


voila g un prog (E.java) qui aujourdhui ma lance une OutofMemory: java heap error. En fouillant sur le web g trouvé comment résoudre le lancement de ma classe (qui doit charger aujourdhui 23000 lignes dans une JTABLE).

g mis "java -Xmx1024m E" et ca marche nickel.

Par contre, E.java appelle une autre classe qui elle, comme elle a pas l'argument -Xmx1024m, ben elle plante. Il sagit de ma classe d'export excel ExcelExporter. Ca me renvoit null, pas java heap... Sur une Jtable moins garnie l'export marche nickel, mais pas sur mes 23000 lignes d aujourdhui....

Comment je fais?
Je sais lancer E.java avec l argument de memoire, mais la je sais pas comment faire pour allouer de la memoire a une classe qui est appellee par une autre classe?


Kelkun a une idee?

ce serait cool

Tomski
(_.:~:._)
A voir également:

5 réponses

kirua12 Messages postés 1155 Date d'inscription samedi 17 janvier 2004 Statut Membre Dernière intervention 29 avril 2011 7
4 sept. 2009 à 16:22
Salut,

le commutateur -Xmx est pour la JVM et non pour une classe. Je comprends pas pourquoi ton export ne fonctionne pas, si t'arrives à afficher ta JTable, ton export devrait fonctionner et ne pas renvoyer null. Tu n'as pas catché une exception de trop par hasard ?
23000 lignes dans une JTable ?! as tu vraiment besoin d'avoir autant de données affichées ?
Normalement, tu dois avoir une collection de tes données mais le modèle de la JTable ne contient pas tout (pagination) ensuite ton export travaille sur la collection et non sur la JTable.
0
tomski Messages postés 48 Date d'inscription mercredi 24 mars 2004 Statut Membre Dernière intervention 24 décembre 2009
7 sept. 2009 à 08:42
salut kirua12


ben c bizarre, kan je compile et que jexecute avec le commutateur, ma requete me renvoit bien mes 23000 lignes, cest a l export ke ca marche pas. Maintenant si je rapatrie les donnees sur un ou deux jours, l export fonctionne car moins de donnees.

pour repondre a ta question, helas oui jai besoin de rapatrier ces donnees (23000 lignes), une fois par mois.

le reste du temps mon programme recherche des donnnees sur un ou deux jours, donc no prob.


Je post mon code

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.Graphics.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.Properties;
import java.util.*;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.Writer;
import java.math.*;
import javax.imageio.*;
import javax.imageio.stream.FileImageOutputStream;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.awt.image.DataBufferByte;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.awt.image.DataBufferByte;
import javax.imageio.ImageIO;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import java.security.*;
import java.security.spec.*;
import java.math.*;
import javax.imageio.*;
import javax.imageio.stream.FileImageOutputStream;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.*;
import java.util.regex.Pattern;
import java.net.URL.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import java.util.Vector;


public class E extends JFrame{

Dialog d1, d2;
JButton ob, oe, os, bb;
JLabel lbc;
JLabel lbdd;
JLabel lbdfi;
JLabel lbdb;
JLabel lbde;
JLabel lbddc;
JLabel lbdfc;
JLabel lbw;
JLabel lbs;
JTextField td;
JTextField tf;
JTextField tbe;
JTextField te;
JTextField tdc;
JTextField ttc;
JList l1;
JList l2;
JList l3;
JScrollPane s1;
JScrollPane s2;
JScrollPane s3;
JScrollPane s4;

String dd, df, db, de, ddc,dfc;

static String[] aj= {"Tous","3", "4","5","6", "7","8","9","10", "12", "P"};
static String[] aw= {"Tous","PI7", "PI9","SE7", "SI9", "SO7","RI7","BNI","BGI", "COI","FLI","MTI","PLI","SOI", "VII", "25A", "25P", "KSN", "MAS", "PAS", "PDS"};
//static String[] as= {"Tous","ABDC", "AS-COM","SFTA", "WELLCOM"};
static String[] as= {"Tous", "AS-COM","SFTA", "WELLCOM"};
//static String[] cols= {"Tous","4h0", "8h0","J1h0", "J2h0"};
String[] str = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
String query= "";
String endquery = " Order by RDV,GTR,RDV_ef,ot.code_codeot";

Statement stmt = null;
ResultSet rs = null;
Connection connexion;

FileWriter flog;
BufferedWriter out;

String[] headers;
int colNo;
JTable tb= new JTable();
ResultSetMetaData meta, rsmd;
Object[] objects;
DefaultTableModel MonModel;
String sau, ui, etat;
String elements[];
boolean sm false; //exportSAM? false
boolean first_run = true;

boolean ct = false;
boolean ef = false;
boolean cl = false;
JOptionPane op = new JOptionPane();


public E(){
JLabel lbfrm = new JLabel();
System.out.println("in E()");
try {
URL helpURL=E.class.getResource("E.htm");
System.out.println(helpURL);
JEditorPane ep = new JEditorPane(helpURL);
this.getContentPane().add(ep, BorderLayout.PAGE_START);
}catch(Exception e){
System.out.println(e);
}

JPanel pstr= new JPanel();
String myString = new String();
myString= str[12].toUpperCase()+str[0]+str[3]+str[4]+ " " +str[1]+str[24]+ " "+str[9].toUpperCase()+str[20]+str[11]+
str[8]+str[4]+ " "+str[1].toUpperCase()+str[17]+str[20]+str[13]+str[8]+str[0]+str[18]+ " "+
str[0].toUpperCase()+str[11]+str[11]+ " "+str[17].toUpperCase()+str[8]+str[6]+str[7]+str[19]+str[18]+ " "+
str[17].toUpperCase()+str[4]+str[18]+str[4]+str[17]+str[21]+str[4]+str[3];
JLabel lb = new JLabel(myString);
pstr.add(lb);


this.getContentPane().add(pstr, BorderLayout.PAGE_END);
//this.pack;
this.setSize(600,620);
this.setTitle("EXPORT REQUETE SQL");
ImageIcon img= new ImageIcon("logo.bmp");

this.setIconImage(img.getImage());
this.setVisible(true);
showDialog1();

}//end E()

public static void main(String[] args){
E ex = new E();
ex.getContentPane().add(new MyComponent());
ex.setDefaultCloseOperation(EXIT_ON_CLOSE);
//cintel.add(editorPane);
ex.setVisible(true);
//showDialog1();

}



public void showDialog1(){

l1 = new JList(aj);
l2 = new JList(aw);
l3 = new JList(as);

s1 = new JScrollPane(l1);
s2 = new JScrollPane(l2);
s3 = new JScrollPane(l3);

l1.setVisibleRowCount(4);
l2.setVisibleRowCount(4);
l3.setVisibleRowCount(4);

tb = new JTable();

/********************************** Choix des ETATS ***********************************************/
ListSelectionListener l1_listener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent listSelectionEvent) {
Object selectedl1Values[] = l1.getSelectedValues();
int selectionsl1[] = l1.getSelectedIndices();
//debut de chaine "etat"
// etat = new String();
etat = " (";
//ensuite on boucle pour concatener la requete sur les etats
for (int n = 0; n < selectionsl1.length; n++) {
System.out.println("selectionsl1.length= " + selectionsl1.length);

switch(selectionsl1[n]){
case 0: etat "" ;break;//Tous> do nothing
case 1: etat etat + "etat_ot.codeetatot'3';" ;break;
case 2: etat = etat + "etat_ot.codeetatot='4';" ;break;
case 3: etat etat + "etat_ot.codeetatot'5';" ;break;
case 4: etat etat + "etat_ot.codeetatot'6';" ;break;
case 5: etat etat + "etat_ot.codeetatot'7';" ;break;
case 6: etat etat + "etat_ot.codeetatot'8';" ;break;
case 7: etat etat + "etat_ot.codeetatot'9';" ;break;
case 8: etat etat + "etat_ot.codeetatot'10';" ;break;
case 9: etat etat + "etat_ot.codeetatot'12';" ;break;
case 10: etat etat + "etat_ot.codeetatot'P';" ;break;
default: etat = "";break;//default "Tous"
}//end switch

//juste pour vérifier
System.out.println(selectionsl1[n] + "/" + selectedl1Values[n] + " ");
}//end for
if (selectionsl1[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
etat ="";
}else{
//autrement, on termine la chaine par ')'
etat = etat + ")";
}//end if
//on print le resultat final de la requete
System.out.println("ETAT FINI = "+etat);

//parse la string pour detecter les espaces et remplacer par des "OR"
//on split la string, tous ce qui est inclus entre ';' sera stocker dans array Elements
elements =etat.split(";");
System.out.println("selectionsl1.length = " + selectionsl1.length);
//String de manipulation et de stockage
String stock="";
String s="";

for (int i = 0; i< elements.length; i++){
if (i == elements.length-2){
System.out.println("i elements.length-2 || i "+i);
s = s + elements[i];
stock =s;
System.out.println("in i == elements.length-2 >>>> s= "+s);
}else if (i == elements.length-1) {
s = s + elements[i];
stock =s;
System.out.println("else if i == elements.length-1 >>>> s= "+s);
}else{
s = s + elements[i] + " OR " ;
stock =s;
System.out.println("else >>>> s= "+s);
}//end if
}//end for
//une toute derniere verification
System.out.println("stock = "+stock);
if (selectionsl1[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
etat ="";
}else{
etat=stock;
}//end if
//etat =stock;
}//end public void
};


/********************************** Choix des UI ***********************************************/
ListSelectionListener l2_listener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent listSelectionEvent) {
Object selectedl2Values[] = l2.getSelectedValues();
int selectionsl2[] = l2.getSelectedIndices();
//debut de chaine "ui"
ui = "(";
//ensuite on boucle pour concatener la requete sur les etats
for (int n = 0; n < selectionsl2.length; n++) {
System.out.println("selectionsl2.length= " + selectionsl2.length);

switch(selectionsl2[n]){
case 0: ui "" ; System.out.println("n "+n); break;//Tous => do nothing
case 1: ui ui + "OT.UI'PI7';"; System.out.println("n = 01? "+n); break;//
case 2: ui ui + "OT.UI'PI9';"; System.out.println("n = 02? "+n); break;//"ASCOM"
case 3: ui ui + "OT.UI'SE7';"; System.out.println("n = 03? "+n); break;
case 4: ui ui + "OT.UI'SI9';"; System.out.println("n = 04? "+n); break;
case 5: ui ui + "OT.UI'SO7';"; System.out.println("n = 05? "+n); break;
case 6: ui ui + "OT.UI'RI7';"; System.out.println("n = 06? "+n); break;
case 7: ui ui + "OT.UI'BNI';"; System.out.println("n = 07? "+n); break;
case 8: ui ui + "OT.UI'BGI';"; System.out.println("n = 08? "+n); break;
case 9: ui ui + "OT.UI'COI';"; System.out.println("n = 09? "+n); break;
case 10: ui ui + "OT.UI'FLI';"; System.out.println("n = 10? "+n); break;
case 11: ui ui + "OT.UI'MTI';"; System.out.println("n = 11? "+n); break;
case 12: ui ui + "OT.UI'PLI';"; System.out.println("n = 12? "+n); break;
case 13: ui ui + "OT.UI'SOI';"; System.out.println("n = 13? "+n); break;
case 14: ui ui + "OT.UI'VII';"; System.out.println("n = 14? "+n); break;
case 15: ui ui + "OT.UI'25A';"; System.out.println("n = 15? "+n); break;
case 16: ui ui + "OT.UI'25P';"; System.out.println("n = 16? "+n); break;
case 17: ui ui + "OT.UI'KSN';"; System.out.println("n = 17? "+n); break;
case 18: ui ui + "OT.UI'MAS';"; System.out.println("n = 18? "+n); break;
case 19: ui ui + "OT.UI'PAS';"; System.out.println("n = 19? "+n); break;
case 20: ui ui + "OT.UI'PDS';"; System.out.println("n = 20? "+n); break;
//case 15: ui ui + "OT.UI'VII';"; System.out.println("n = 15? "+n); break;
default: ui = "";break;//default "Tous"
}//end switch
//juste pour vérifier
System.out.println(selectionsl2[n] + "/" + selectedl2Values[n] + " ");
}//end for
if (selectionsl2[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
ui ="";
}else{
//autrement, on termine la chaine par ')'
ui = ui + ")";
}
//on print le resultat final de la requete
System.out.println("UI FINI = "+ui);

//parse la string pour detecter les espaces et remplacer par des "OR"
//on split la string, tous ce qui est inclus entre ';' sera stocker dans array Elements
elements =ui.split(";");
System.out.println("selectionsl2.length = " + selectionsl2.length);
//String de manipulation et de stockage
String stock="";
String s="";

for (int i = 0; i< elements.length; i++){
if (i == elements.length-2){
System.out.println("i elements.length-2 || i "+i);
s = s + elements[i];
stock =s;
System.out.println("in i == elements.length-2 >>>> s= "+s);
}else if (i == elements.length-1) {
s = s + elements[i];
stock =s;
System.out.println("else if i == elements.length-1 >>>> s= "+s);
}else{
s = s + elements[i] + " OR " ;
stock =s;
System.out.println("else >>>> s= "+s);
}
}//end for
//une toute derniere verification
System.out.println("stock = "+stock);
if (selectionsl2[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
ui ="";
}else{
ui=stock;
}//end if
}//end public void
};




/********************************** Choix de la sau ***********************************************/
ListSelectionListener l3_listener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent listSelectionEvent) {
Object selectedl3Values[] = l3.getSelectedValues();
int selectionsl3[] = l3.getSelectedIndices();
//debut de chaine "sau"
sau = " (";

//ensuite on boucle pour concatener la requete sur les Divisions de Production
for (int n = 0; n < selectionsl3.length; n++) {
switch(selectionsl3[n]){
case 0: sau "" ;break;//Tous> do nothing
case 1: sau sau + "DivProd.nomdivisionproduction 'AS-COM';" ;break;//
case 2: sau sau + "DivProd.nomdivisionproduction 'SFTA';" ;break;//"ASCOM"
case 3: sau sau + "DivProd.nomdivisionproduction 'WELLCOM';";break;
/*
case 0: sau "" ;break;//Tous> do nothing
case 1: sau sau + "DivProd.nomdivisionproduction 'ABDC';" ;break;//
case 2: sau sau + "DivProd.nomdivisionproduction 'AS-COM';" ;break;//"ASCOM"
case 3: sau sau + "DivProd.nomdivisionproduction 'SFTA';";break;
case 4: sau sau + "DivProd.nomdivisionproduction 'WELLCOM';" ;break;
*/
default: sau = "";break;//default "Tous"

}//end switch
//juste pour vérifier
System.out.println(selectionsl3[n] + "/" + selectedl3Values[n] + " ");
}//end for
if (selectionsl3[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
sau ="";
}else{
//autrement, on termine la chaine par ')'
sau = sau + ")";
}
//on print le resultat final de la requete
System.out.println("sau FINI = "+sau);

//parse la string pour detecter les espaces et remplacer par des "OR"
//on split la string, tous ce qui est inclus entre ';' sera stocker dans array Elements
elements =sau.split(";");
System.out.println("selectionsl3.length = " + selectionsl3.length);
//String de manipulation et de stockage
String stock="";
String s="";

for (int i = 0; i< elements.length; i++){
if (i == elements.length-2){
System.out.println("i elements.length-2 || i "+i);
s = s + elements[i];
stock =s;
System.out.println("in i == elements.length-2 >>>> s= "+s);
}else if (i == elements.length-1) {
s = s + elements[i];
stock =s;
System.out.println("else if i == elements.length-1 >>>> s= "+s);
}else{
s = s + elements[i] + " OR " ;
stock =s;
System.out.println("else >>>> s= "+s);
}
}//end for

//une toute derniere verification
System.out.println("stock = "+stock);
if (selectionsl3[0] == 0){
//si on selectionne Tous (indice 0),ne rien faire
//car pas besoin de preciser, la requete prendra tous par defaut
sau ="";
}else{
sau=stock;
}//end if
}//end public void
};



l1.addListSelectionListener(l1_listener);
l2.addListSelectionListener(l2_listener);
l3.addListSelectionListener(l3_listener);

s1.setPreferredSize(new Dimension(100, 80));
s2.setPreferredSize(new Dimension(100, 80));
s3.setPreferredSize(new Dimension(100, 80));

d1 = new JDialog(this, "Choix des colonnes...", true);
ob = new JButton("OK");
ob.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("in OK");
if (td.getText() != null && !td.getText().equals("") && tf.getText() != null && !tf.getText().equals("") ){
ct = true;//booleen pour dire quon est dans date contractuelle
dd = td.getText();
df = tf.getText();
ef = false;//booleen pour dire quon est pas dans date ef
cl = false;//booleen pour dire quon est pas dans date cl
}else if(tbe.getText() != null && !tbe.getText().equals("") && te.getText() != null && !te.getText().equals("") ){
ef = true;//booleen pour dire quon est dans date contractuelle
db = tbe.getText();
de = te.getText();
ct = false;//booleen pour dire quon est dans date contractuelle
cl = false;//booleen pour dire quon est pas dans date cl
}else if(tdc.getText() != null && !tdc.getText().equals("") && ttc.getText() != null && !ttc.getText().equals("") ){
cl = true;//booleen pour dire quon est dans date cl
ddc = tdc.getText();
dfc = ttc.getText();
ef = false;//booleen pour dire quon est dans date ef
ct = false;//booleen pour dire quon est pas dans date contractuelle
}//end if


System.out.println("dd= "+dd);
System.out.println("df= "+df);
System.out.println("db= "+db);
System.out.println("de= "+de);
System.out.println("ddc= "+ddc);
System.out.println("dfc= "+dfc);
//tout est ok, on peut y aller....
connectDB();
}
});

os = new JButton("Export SAM");
os.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("in EXPORT SAM");
dd = td.getText();
df = tf.getText();
//recup des objets selectionnés dans les listes
sm = true; //oui on a bien clique sur EXPORTSAM
connectDB();
}
});


JPanel lstPanel= new JPanel();
JPanel goPanel = new JPanel();
JPanel pstr= new JPanel();
String myString = new String();
myString= str[12].toUpperCase()+str[0]+str[3]+str[4]+ " " +str[1]+str[24]+ " "+str[9].toUpperCase()+str[20]+str[11]+
str[8]+str[4]+ " "+str[1].toUpperCase()+str[17]+str[20]+str[13]+str[8]+str[0]+str[18]+ " "+
str[0].toUpperCase()+str[11]+str[11]+ " "+str[17].toUpperCase()+str[8]+str[6]+str[7]+str[19]+str[18]+ " "+
str[17].toUpperCase()+str[4]+str[18]+str[4]+str[17]+str[21]+str[4]+str[3];
JLabel lb = new JLabel(myString);
pstr.add("South", lb);
JPanel choix1Panel = new JPanel();
JPanel choixLogPanel = new JPanel();

td = new JTextField(10);
tf = new JTextField(10);
tbe = new JTextField(10);
te = new JTextField(10);
tdc= new JTextField(10);
ttc= new JTextField(10);

td.setToolTipText("Date Format : YYYY-MM-DD");
tf.setToolTipText("Date Format : YYYY-MM-DD");
tbe.setToolTipText("Date Format : YYYY-MM-DD");
te.setToolTipText("Date Format : YYYY-MM-DD");

ob.setToolTipText("Click to launch Query");
os.setToolTipText("Click to launch SAM Query for Billing Purpose");

lbc = new JLabel("Etats");
lbdd = new JLabel("Date Début CONTRACTUEL");
lbdfi = new JLabel("Date Fin CONTRACTUEL");
lbdb = new JLabel("Date Début RDV EFFECTIF");
lbde = new JLabel("Date Fin RDV EFFECTIF");
lbddc = new JLabel("Date Début CLOTURE");
lbdfc = new JLabel("Date Fin RDV CLOTURE");
lbw = new JLabel("UI");
lbs = new JLabel("Société");

GridLayout grid1 = new GridLayout(6,2,10,10);
GridLayout grid2 = new GridLayout(2,3,00,00);
GridLayout grid3 = new GridLayout(3,1,00,00);
GridLayout grid4 = new GridLayout(1,1,10,00);

JPanel pdate = new JPanel();
JPanel plist = new JPanel();
JPanel p = new JPanel();
pdate.setLayout(grid1);
plist.setLayout(grid2);

pdate.add(lbdd);//date contractuelle
pdate.add(lbdfi);
pdate.add(td);
pdate.add(tf);
pdate.add(lbdb);//rdv ef
pdate.add(lbde);
pdate.add(tbe);
pdate.add(te);
pdate.add(lbddc);//cl
pdate.add(lbdfc);
pdate.add(tdc);
pdate.add(ttc);

plist.add(lbc);
plist.add(lbw);
plist.add(lbs);
plist.add(s1);
plist.add(s2);
plist.add(s3);
p.add("North", pdate);
p.add("South", plist);

goPanel.add("North", ob);
goPanel.add("South", os );

JPanel ptotal = new JPanel();
ptotal.add(p);
ptotal.setLayout(grid4);


d1.add(ptotal, BorderLayout.CENTER);
d1.add(pstr, BorderLayout.PAGE_END);
d1.add(goPanel, BorderLayout.LINE_END);
d1.setSize(700,500);
d1.setVisible(true);

}//end showDialog1


public void connectDB(){

//Connection connection = null;
try {
System.out.println("Trying to connect to MYSQL...");
// Load the JDBC driver
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);

// Create a connection to the database

String serverName = "nom_serveur"
String mydatabase = "nom_db";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "mon_user";
String password = "mon_pwd";
System.out.println("URL = "+url);
connexion= DriverManager.getConnection(url, username, password);
System.out.println("connexion = "+ connexion.toString());

//TEST REQUETE
try {

stmt = connexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);


/* Execute the query */
//Get general information about DB
DatabaseMetaData mtdt = connexion.getMetaData();
System.out.println("URL in use: " + mtdt.getURL());
System.out.println("User name: " + mtdt.getUserName());
System.out.println("DBMS name: " + mtdt.getDatabaseProductName());
System.out.println("DBMS version: " + mtdt.getDatabaseProductVersion());
System.out.println("Driver name: " + mtdt.getDriverName());
System.out.println("Driver version: " + mtdt.getDriverVersion());
//End Get general information about DB


//Compiling and Launching the query...
launchQuery();

//Will be executed whatever happens
} finally {

/* Release the resources */
if (rs != null) {
try {
rs.close();
} catch (SQLException sqlEx) {
System.out.println("SQLException: " + sqlEx.getMessage());
}//end try
rs = null;
}//end if rs
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) {
System.out.println("SQLException: " + sqlEx.getMessage());
}//end try
stmt = null;
}//end if stmt
if (connexion != null) {
try {
connexion.close();
} catch (SQLException sqlEx) {
// Ignore
}//end try
connexion = null;
}//end if connexion
out.close();
}//end finally
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
// }

} catch (Exception ex) {
System.out.println("Exception ICI: " + ex.getMessage());
}

//END TEST REQUETE
//System.out.println("Now should be CONNECTED");
}//end connectDB



public void launchQuery(){
//Here is the Query (direct from mySQL)

/*
query"select ot.code_codeot,etat_ot.codeetatot etat, OT.CodeActivite AS Activite, OT.CodeProduit AS Produit,(Select ifNull((Select LibelleEngagement From Engagement E2 Where E2.EngagementID OT.EngagementID), ' ')) AS GTR, OT.UI UI, LI.ND AS ND, ifNull(OT.OrigineSignalisation,' ') AS Origine,(Select ifNull((Select OT2.rendezvous From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS RDV,(Select ifNull((Select AD2.LibelleCommune From Ligne L2 Join Adresse AD2 On L2.EquipementID = AD2.EquipementID Where L2.LigneID = LI.LigneID), ' ')) AS Lieu,(select ifnull((select if(nom_utilisateur='',nom_titulaire,nom_utilisateur)from abonne AB where AB.equipementid=LI.equipementid ),' ')) as abonne, EQ.LibelleEquipe AS Equipe, DivProd.nomdivisionproduction as sau,(Select ifNull((Select Date(OT2.DateHeureRdv)From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS RDV_ef,(Select ifNull((Select OT2.DateHeureContractuelle From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS DateHeureContractuelle,(Select ifNull((Select Date(OT2.DateHeureTest) From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS debut,(Select ifNull((Select Date(OT2.DateHeureCloture) From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS Fin,(Select ifNull((Select RI2.CodeResultatIntervention From Asso_Ligne_Resultat_Intervention ALRI2 Join Resultat_Intervention RI2 On ALRI2.ResultatInterventionID = RI2.ResultatInterventionID Where ALRI2.LigneID = LI.LigneID), ' ')) AS Resultat_Intervention,(Select ifNull((Select ER2.LibelleEssaiRobot From Asso_Ligne_Resultat_Intervention ALRI2 Join Essai_Robot ER2 On ALRI2.EssaiRobotID = ER2.EssaiRobotID Where ALRI2.LigneID = LI.LigneID), ' ')) AS Essais, (Select if(OT2.Facture is Null or OT2.Facture = 0, 'N', 'O') From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT ) AS Facturation,(Select ifNull((Select sum(NA.QuantiteAction) From Necessiter_Action NA Where NA.LigneID = LI.LigneID And NA.CodeActionOT = 20), ' ')) AS Pose_DTI,(Select ifNull((Group_Concat((Select (if((MU2.AncTete Like '%%%-%%-%%%'), Concat(MU2.AncTete, '\n', 'N DECH ', MU2.CodeDecharge), Concat(MU2.NouvTete, '/', MU2.NouvAmorce, '/', MU2.NouvPaire, '\n', 'N DECH ', MU2.CodeDecharge))) From Mutation MU2 Where MU2.MutationID = ALM.MutationID) SEPARATOR '\n')), ' ') From Ligne LI2 Left Join Asso_Ligne_Mutation ALM On LI2.LigneID = ALM.LigneID Where LI2.LigneID = LI.LigneID ) AS New_Const_Comment, OT.CommentaireInterne AS Comment,(select ifnull((select pc.codecategoriepc from asso_ligne_architecture,pc where asso_ligne_architecture.equipementid=pc.equipementid and asso_ligne_architecture.ligneid=LI.ligneid),' ')) AS CategoriePC,(select ifnull((select libellequalificatif from qualifie_OT join qualificatif on ( qualificatif.codequalificatif=qualifie_OT.codequalificatif) where (qualificatif.codequalificatif=5 or qualificatif.codequalificatif=6) and qualifie_OT.code_codeot=ot.code_codeot),' ')) as Travail,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRA' And ALA2.LigneID = LI.LigneID), '')) AS BRA,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRI' And ALA2.LigneID = LI.LigneID), '')) AS BRI, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRF' And ALA2.LigneID = LI.LigneID), '')) AS BRF, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRS' And ALA2.LigneID = LI.LigneID), '')) AS BRS,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'ZERO' And ALA2.LigneID = LI.LigneID), '')) AS ZERO,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MIT' And ALA2.LigneID = LI.LigneID), '')) AS MIT, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PDF' And ALA2.LigneID = LI.LigneID), '')) AS PDF,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RDS' And ALA2.LigneID = LI.LigneID), '')) AS RDS, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RSTH' And ALA2.LigneID = LI.LigneID), '')) AS RSTH, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BSR' And ALA2.LigneID = LI.LigneID), '')) AS BSR,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'JRT' And ALA2.LigneID = LI.LigneID), '')) AS JRT, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'JRTM' And ALA2.LigneID = LI.LigneID), '')) AS JRTM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RNU' And ALA2.LigneID = LI.LigneID), '')) AS RNU, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'HIC' And ALA2.LigneID = LI.LigneID), '')) AS HIC, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'GTR' And ALA2.LigneID = LI.LigneID), '')) AS gtr, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'LAN' And ALA2.LigneID = LI.LigneID), '')) AS LAN, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'NET' And ALA2.LigneID = LI.LigneID), '')) AS NET, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PCM' And ALA2.LigneID = LI.LigneID), '')) AS PCM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RDM' And ALA2.LigneID = LI.LigneID), '')) AS RDM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'AMS' And ALA2.LigneID = LI.LigneID), '')) AS AMS, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPSR' And ALA2.LigneID = LI.LigneID), '')) AS MPSR, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPREJ' And ALA2.LigneID = LI.LigneID), '')) AS MPREJ, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPREN' And ALA2.LigneID = LI.LigneID), '')) AS MPREN, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PCX' And ALA2.LigneID = LI.LigneID), '')) AS PCX from code_ot ot Join Asso_OT_ND AON On OT.Code_CodeOT = AON.Code_CodeOT Join Ligne LI On AON.LigneID = LI.LigneID Left Join Adresse AD On LI.EquipementID = AD.EquipementID Left Join Asso_Ligne_Resultat_Intervention ALRI On LI.LigneID = ALRI.LigneID Left Join Resultat_Intervention RI On ALRI.ResultatInterventionID = RI.ResultatInterventionID Left Join Essai_Robot ER On ALRI.EssaiRobotID = ER.EssaiRobotID left Join OT_EQP_Planning OEP On OT.Code_CodeOT = OEP.Code_CodeOT left Join Equipe EQ On OEP.CodeEquipe = EQ.CodeEquipe left join DivProd DivProd on (divprod.codedivisionproduction=EQ.codedivisionproduction) join etat_OT on (ot.etatotid=etat_ot.etatotid) where Date(OT.DateHeureContractuelle) >= '"+dd+"' And Date(OT.DateHeureContractuelle) <= '"+df+"' Order by RDV,GTR,RDV_ef,ot.code_codeot
*/

/****TEST SI DEJA LANCE QUERY*****/

//And here is the query with "dd" and "df" parameters
query "select ot.code_codeot,etat_ot.codeetatot etat, OT.CodeActivite AS Activite, OT.CodeProduit AS Produit,(Select ifNull((Select LibelleEngagement From Engagement E2 Where E2.EngagementID OT.EngagementID), ' ')) AS GTR, OT.UI UI, LI.ND AS ND, ifNull(OT.OrigineSignalisation,' ') AS Origine,(Select ifNull((Select OT2.rendezvous From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS RDV,(Select ifNull((Select AD2.LibelleCommune From Ligne L2 Join Adresse AD2 On L2.EquipementID = AD2.EquipementID Where L2.LigneID = LI.LigneID), ' ')) AS Lieu,(select ifnull((select if(nom_utilisateur='',nom_titulaire,nom_utilisateur)from abonne AB where AB.equipementid=LI.equipementid ),' ')) as abonne, EQ.LibelleEquipe AS Equipe, DivProd.nomdivisionproduction as sau,(Select ifNull((Select Date(OT2.DateHeureRdvEffectif)From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS RDV_ef,(Select ifNull((Select OT2.DateHeureContractuelle From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS DateHeureContractuelle,(Select ifNull((Select Date(OT2.DateHeureTest) From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS debut,(Select ifNull((Select Date(OT2.DateHeureCloture) From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT),' ')) AS Fin,(Select ifNull((Select RI2.CodeResultatIntervention From Asso_Ligne_Resultat_Intervention ALRI2 Join Resultat_Intervention RI2 On ALRI2.ResultatInterventionID = RI2.ResultatInterventionID Where ALRI2.LigneID = LI.LigneID), ' ')) AS Resultat_Intervention,(Select ifNull((Select ER2.LibelleEssaiRobot From Asso_Ligne_Resultat_Intervention ALRI2 Join Essai_Robot ER2 On ALRI2.EssaiRobotID = ER2.EssaiRobotID Where ALRI2.LigneID = LI.LigneID), ' ')) AS Essais, (Select if(OT2.Facture is Null or OT2.Facture = 0, 'N', 'O') From Code_OT OT2 Where OT2.Code_CodeOT = OT.Code_CodeOT ) AS Facturation,(Select ifNull((Select sum(NA.QuantiteAction) From Necessiter_Action NA Where NA.LigneID = LI.LigneID And NA.CodeActionOT = 20), ' ')) AS Pose_DTI,(Select ifNull((Group_Concat((Select (if((MU2.AncTete Like '%%%-%%-%%%'), Concat(MU2.AncTete, '\n', 'N DECH ', MU2.CodeDecharge), Concat(MU2.NouvTete, '/', MU2.NouvAmorce, '/', MU2.NouvPaire, '\n', 'N DECH ', MU2.CodeDecharge))) From Mutation MU2 Where MU2.MutationID = ALM.MutationID) SEPARATOR '\n')), ' ') From Ligne LI2 Left Join Asso_Ligne_Mutation ALM On LI2.LigneID = ALM.LigneID Where LI2.LigneID = LI.LigneID ) AS New_Const_Comment, OT.CommentaireInterne AS Comment,(select ifnull(( select pc.codecategoriepc from asso_ligne_architecture,pc where asso_ligne_architecture.equipementid=pc.equipementid and asso_ligne_architecture.ligneid=LI.ligneid),' ')) AS CategoriePC,(select ifnull((select libellequalificatif from qualifie_OT join qualificatif on ( qualificatif.codequalificatif=qualifie_OT.codequalificatif) where (qualificatif.codequalificatif=5 or qualificatif.codequalificatif=6) and qualifie_OT.code_codeot=ot.code_codeot),' ')) as Travail,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRA' And ALA2.LigneID = LI.LigneID), '')) AS BRA,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRI' And ALA2.LigneID = LI.LigneID), '')) AS BRI, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRF' And ALA2.LigneID = LI.LigneID), '')) AS BRF, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BRS' And ALA2.LigneID = LI.LigneID), '')) AS BRS,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'ZERO' And ALA2.LigneID = LI.LigneID), '')) AS ZERO,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MIT' And ALA2.LigneID = LI.LigneID), '')) AS MIT, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PDF' And ALA2.LigneID = LI.LigneID), '')) AS PDF,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RDS' And ALA2.LigneID = LI.LigneID), '')) AS RDS, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RSTH' And ALA2.LigneID = LI.LigneID), '')) AS RSTH, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'BSR' And ALA2.LigneID = LI.LigneID), '')) AS BSR,(Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'JRT' And ALA2.LigneID = LI.LigneID), '')) AS JRT, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'JRTM' And ALA2.LigneID = LI.LigneID), '')) AS JRTM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RNU' And ALA2.LigneID = LI.LigneID), '')) AS RNU, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'HIC' And ALA2.LigneID = LI.LigneID), '')) AS HIC, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'GTR' And ALA2.LigneID = LI.LigneID), '')) AS gtr, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'LAN' And ALA2.LigneID = LI.LigneID), '')) AS LAN, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'NET' And ALA2.LigneID = LI.LigneID), '')) AS NET, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PCM' And ALA2.LigneID = LI.LigneID), '')) AS PCM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'RDM' And ALA2.LigneID = LI.LigneID), '')) AS RDM, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'AMS' And ALA2.LigneID = LI.LigneID), '')) AS AMS, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPSR' And ALA2.LigneID = LI.LigneID), '')) AS MPSR, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPREJ' And ALA2.LigneID = LI.LigneID), '')) AS MPREJ, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'MPREN' And ALA2.LigneID = LI.LigneID), '')) AS MPREN, (Select ifNull((Select ALA2.QuantiteArticle From Asso_Ligne_Article ALA2 Join Article AR2 On ALA2.ArticleID = AR2.ArticleID Where AR2.CodeArticle = 'PCX' And ALA2.LigneID = LI.LigneID), '')) AS PCX from code_ot ot Join Asso_OT_ND AON On OT.Code_CodeOT = AON.Code_CodeOT Join Ligne LI On AON.LigneID = LI.LigneID Left Join Adresse AD On LI.EquipementID = AD.EquipementID Left Join Asso_Ligne_Resultat_Intervention ALRI On LI.LigneID = ALRI.LigneID Left Join Resultat_Intervention RI On ALRI.ResultatInterventionID = RI.ResultatInterventionID Left Join Essai_Robot ER On ALRI.EssaiRobotID = ER.EssaiRobotID left Join OT_EQP_Planning OEP On OT.Code_CodeOT = OEP.Code_CodeOT left Join Equipe EQ On OEP.CodeEquipe = EQ.CodeEquipe left join DivProd DivProd on (divprod.codedivisionproduction=EQ.codedivisionproduction) join etat_OT on (ot.etatotid=etat_ot.etatotid)";

//System.out.println("valeur de ct? = "+ct);
//quelle date?
//date contractuelle

if(ct == true){
System.out.println("date con != null OR empty");
query = query + " where Date(OT.DateHeureContractuelle) >= '"+dd+"' And Date(OT.DateHeureContractuelle) <= '"+df+"' ";
//System.out.println("query + date con = "+query);
}else{
query = query;
//System.out.println("else + date contractuelle null or '' "+query);
}

//date rdv ef
if(ef == true){
System.out.println("rdv ef != null OR empty");
query = query + " where Date(OT.DateHeureRdvEffectif) >= '"+db+"' And Date(OT.DateHeureRdvEffectif) <= '"+de+"' ";
//System.out.println("query + date rdv ef = "+query);
}else{
query = query;
//System.out.println("else + date rdv ef null or '' "+query);
}

//date cl
if(cl == true){
System.out.println("date cl != null OR empty");
query = query + " where OT.DateHeureCloture >= '"+ddc+"' And OT.DateHeureCloture <= '"+dfc+"' ";
//query = query + " where Date(OT.DateHeureCloture) >= '"+ddc+"' And Date(OT.DateHeureCloture) <= '"+dfc+"' ";
System.out.println("query + heure cl = "+query);
}else{
query = query;
//System.out.println("else + date cl null or '' "+query);
}

//System.out.println("ETAT = "+ etat);

if (sau != null && sau!=""){
query = query + "And "+sau;
//System.out.println("query + sau = "+query);
}else{
query = query;
//System.out.println("else sau null or '' "+query);
}
if (ui != null && ui !=""){
query = query + "And "+ui;
//System.out.println("query + ui = "+query);
}else{
query = query;
//System.out.println("else ui null or '' "+query);
}
if (etat != null && etat!=""){
query = query + "And "+etat;
//System.out.println("query + etat = "+query);
}else{
query = query;
//System.out.println("else etat null or '' "+query);
}

//on termine par enquery
query = query + endquery;

//operateur ternaire: if else simplifie
//(condition) ? instruction si vrai : instruction si faux


//query = query+ if(sau != "") sau + if(ui != "") ui + if(etat != "") etat + if(gtr != "") gtr+endquery;
//query = query+sau+endquery;
System.out.println("NEW Query= "+query);
//System.out.println("Query= "+query);

//Execute the Query
try {
rs = stmt.executeQuery(query);
//Fill table with resultset (my own method)
if (first_run == true){
System.out.println("first_run == true");
SetTable(rs);
}else{
System.out.println("first_run == false");
deleteTable(MonModel);
SetTable(rs);
}
//MonModel.fireTableDataChanged();
} catch (Exception ex) {
System.out.println("Exception 1: " + ex.getMessage());
}

}//end launchQuery




public void showDialog2(){

bb = new JButton("Go Back");
bb.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("in BACK");
MonModel = (DefaultTableModel) tb.getModel();
first_run = false;
if (query != null || !query.equals("")) {
query = "";
//clear();
deleteTable(MonModel);
} else {
System.out.println("HERE ELSE QUERY == ??? >>>" + query);
}//end if
d2.setVisible(false);
d1.setVisible(true);

}
});//end bb

oe = new JButton("EXPORT");
oe.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("in Export");
try {
ExcelExporter exp = new ExcelExporter();
exp.exportTable(tb, new File("results.xls"));
} catch (IOException ex) {
System.out.println(ex.getMessage());
0
kirua12 Messages postés 1155 Date d'inscription samedi 17 janvier 2004 Statut Membre Dernière intervention 29 avril 2011 7
7 sept. 2009 à 10:39
que tu sois obligé de rapatrier les données ne choque pas, c'est de les afficher qui me gêne. De mon point de vue, 23000 lignes c'est totalement illisibles, tu dois pouvoir les paginer ou les filtrer pour les exploiter.

Sinon il y a un (gros) problème de découpage de ton code, ta JFrame fait beaucoup trop de choses. Les traitements auraient dû être dans des classes séparées.

Je suppose que tu as testé en debug, ça donne quoi ?
0
tomski Messages postés 48 Date d'inscription mercredi 24 mars 2004 Statut Membre Dernière intervention 24 décembre 2009
8 sept. 2009 à 08:19
salut Kirua12,

avec ma Jtable, ca va, la visibilite est bonne, je peux trier dessus pour grouper les lignes avec les memes infos, mais au final oui jai besoin de toutes ces lignes...

Je comprends pas "tu dois pouvoir les paginer ou les filtrer pour les exploiter." Jai besoin de toutes les avoir dans un fichier xls en sortie. Sur un nombre un peu moins consequent de lignes, ya pas de souci, cest quand on rapatrie les donnnees sur un mois calendaire complet ke ca merde. Sinon, sur 20j environ ca marche (parfois), et sur 15j ca marche. Jai lance le programme plusieurs dizaines de fois, pour voir...

Mis a part ke ma Jframe fasse pas mal de choses (jaurais ptetre du faire une classe Conexion, mais bon...) cest kan meme pas ca ki fait buguer. Puisque avec moins de donnees ca marche nickel....
Est ce que taurais une idee de ce que je dois faire pour que ca marche, y compris avec plus de 20000 lignes, ce qui je le rappelle est exceptionnel (1/ mois).

merci davance pour ta reponse

PS le debug avec jdb ne donne rien. Dans ma classe main, quand je fais "cont" ca lance le programme comme dhab et ca nexplique pas ce qui est a Null...
(_.:~:._)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
kirua12 Messages postés 1155 Date d'inscription samedi 17 janvier 2004 Statut Membre Dernière intervention 29 avril 2011 7
10 sept. 2009 à 10:00
que veux tu dire par 'ca nexplique pas ce qui est a Null' ?

Je ne peux pas tester ton code car je n'ai pas la base de données correspondante. Plutôt que debugger avec jdb, tu n'as pas un IDE (eclipse, netbean ou autre), c'est plus efficace pour ce genre d'opération ? Il faut que tu débug en pas à pas dans le code de l'export pour voir à quel moment ça s'arrête
0
Rejoignez-nous