Précédent   Forum des professionnels en informatique > Java > Général Java > APIs
APIs Forum sur les API standard et API complémentaires. Avant de poster -> FAQ Java, Les meilleures API Java
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/12/2011, 21h23   #1
Candidat au titre de Membre du Club
 
khadidja tih
Inscription : novembre 2010
Messages : 93
Détails du profil
Informations personnelles :
Nom : khadidja tih

Informations forums :
Inscription : novembre 2010
Messages : 93
Points : 11
Points : 11
Par défaut [NetBeans] Problème avec l'exécutable de mon application

Salut !
J'ai un problème avec l’exécutable de mon application Java; je fais un build pour obtenir un .jar de mon application, quand je lance l'application à partir de l’exécutable dans un premier temps tout a l'air de bien marché l'affichage de toutes mes fenêtre est réussi mais quand je click sur un bouton qui doit me interroger la BDD rien ne se passe y a pas de connexion, et pourtant quand je lance l'application a partir de l'IDE NetBeans tout marche bien aucun problème
Alors qui pourra m'aider pour trouver la source de ce problème ?
Je vous donne un exemple de mon code

Citation:
package base;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

/**
*
* @author pcfutur
*/
public class bdd extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public bdd() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setText("afficher facture");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(159, 159, 159)
.addComponent(jButton1)
.addContainerGap(134, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(104, 104, 104)
.addComponent(jButton1)
.addContainerGap(173, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

String titre="La recherche des facture nom payer :";
String message="les factures recherchés sont :";


try {
Class.forName("org.postgresql.Driver");

String url = "jdbc:postgresql://localhost:5432/sonelgaz";
String user = "postgres";
String passwd = "**********";

Connection conn = DriverManager.getConnection(url, user, passwd);

//Création d'un objet Statement
Statement state = conn.createStatement();
ResultSet result = state.executeQuery("SELECT * FROM facture WHERE facture.etat='En Instance' ");
ResultSetMetaData resultMeta = result.getMetaData();


while(result.next()){
message+="\n";
message+="\t" +resultMeta.getColumnName(1).toUpperCase() +": "+result.getObject(1).toString()+ "\t ";
message+="\n";
message+="\t" +resultMeta.getColumnName(2).toUpperCase() +": "+result.getObject(2).toString()+ "\t ";
message+="\n";
message+="\t" +resultMeta.getColumnName(3).toUpperCase() +": "+result.getObject(3).toString()+ "\t ";
message+="\n";
message+="\t" +resultMeta.getColumnName(8).toUpperCase() +": "+result.getObject(8).toString()+ "\t ";
message+="\n";
message+="__________________________________________________________";
message+="\n";}


result.close();
state.close();

}catch (Exception e) {
e.printStackTrace();
}

javax.swing.JOptionPane.showMessageDialog(this,message,titre,javax.swing.JOptionPane.INFORMATION_MESSAGE);



}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tu...feel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(bdd.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(bdd.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(bdd.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(bdd.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {
new bdd().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
et voila la méthode main
Citation:
public class Base {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {



java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
bdd principal=new bdd();
principal.setVisible(true);

}
});
}
}
Merci
khadi8 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2012, 16h22   #2
Membre régulier
 
Avatar de kalina
 
Inscription : avril 2009
Messages : 86
Détails du profil
Informations personnelles :
Localisation : Algérie

Informations forums :
Inscription : avril 2009
Messages : 86
Points : 86
Points : 86
salut,
regarde dans "dist" à côté de ton .jar s'il manque pas le dossier "lib" où se trouvent les drivers de bd qui permettent la connexion à ta base.
kalina est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2012, 16h48   #3
Membre éprouvé
 
Homme
Ingénieur développement logiciels
Inscription : avril 2009
Messages : 501
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Sarthe (Pays de la Loire)

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : Service public

Informations forums :
Inscription : avril 2009
Messages : 501
Points : 490
Points : 490
Citation:
Envoyé par kalina Voir le message
salut,
regarde dans "dist" à côté de ton .jar s'il manque pas le dossier "lib" où se trouvent les drivers de bd qui permettent la connexion à ta base.
+1 il faut que le jar soit accompagné du répertoire lib qui contient les librairies.

Sinon, imprime la stack trace dans les blocs catch et lance ton programme en ligne de commande. Comme ça tu pourras toujours exécuter ton jar avec une console pour voir ce qu'il se passe.
oneagaindoguys est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h46.


 
 
 
 
Partenaires

Hébergement Web