73 lines
2.0 KiB
Java
73 lines
2.0 KiB
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
*/
|
|
package acces_aux_donnes;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.sql.Statement;
|
|
import java.util.ArrayList;
|
|
/**
|
|
*
|
|
* @author emile.lalorcey
|
|
*/
|
|
public class MedicamentSQL {
|
|
private Connection connexionTest;
|
|
private Statement stmt = null;
|
|
private ResultSet result = null;
|
|
|
|
/**
|
|
* Constructeur de la classe médicamentSQL
|
|
*/
|
|
public MedicamentSQL() {
|
|
connexionTest = connexionSQL.getConnect("10.121.38.69","bdgsb","appliGSB","(Uq1XV0Tr01s2H9Z");
|
|
}
|
|
|
|
/**
|
|
* Méthode permettant la recherche d'un médicament dans une base données
|
|
* suivant le nom commercial de celui-ci
|
|
* @param nomCo
|
|
* @return ArrayList<String> infoMedoc avec toutes les informations du médicament
|
|
*/
|
|
public ArrayList<String> rechercherMedicament (String nomCo){
|
|
ArrayList<String> infoMedoc = new ArrayList<String>();
|
|
|
|
try {
|
|
stmt = connexionTest.createStatement();
|
|
// Accès à la table
|
|
result = stmt.executeQuery("SELECT * FROM MEDICAMENT WHERE mNomCommercial ='"+nomCo+"';");
|
|
if(result.next()){
|
|
infoMedoc.add(result.getString(1));
|
|
infoMedoc.add(result.getString(2));
|
|
infoMedoc.add(result.getString(3));
|
|
infoMedoc.add(result.getString(4));
|
|
infoMedoc.add(result.getString(5));
|
|
infoMedoc.add(result.getString(6));
|
|
}
|
|
result.close();
|
|
stmt.close();
|
|
}catch (SQLException ex) {
|
|
System.out.println("SQLException : " + ex.getMessage());
|
|
System.out.println("SQLState : " + ex.getSQLState());
|
|
System.out.println("Code erreur : " + ex.getErrorCode());
|
|
}
|
|
return infoMedoc;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|