Observation Fini de l'affichage à l'insertion SQL
This commit is contained in:
@@ -4,10 +4,60 @@
|
||||
*/
|
||||
package acces_aux_donnes;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emile.lalorcey
|
||||
*/
|
||||
public class observationSQL {
|
||||
private Connection connexionTest;
|
||||
private Statement stmt = null;
|
||||
private ResultSet result = null;
|
||||
|
||||
public observationSQL() {
|
||||
connexionTest = connexionSQL.getConnect("10.121.38.75","bdgsb","adminGSB","mdpGSB");
|
||||
}
|
||||
|
||||
public int compterLignes(){
|
||||
int nbLignes = 0;
|
||||
try {
|
||||
stmt = connexionTest.createStatement();
|
||||
// Acc<63>s <20> la table
|
||||
result = stmt.executeQuery("SELECT COUNT(idObservation) From OBSERVATION");
|
||||
if (result.next()) {
|
||||
nbLignes = Integer.parseInt(result.getString(1));
|
||||
}
|
||||
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 nbLignes;
|
||||
}
|
||||
|
||||
|
||||
public int ajouterObservation(String idMedoc, int idPraticien, String observation){
|
||||
int passer = 1000;
|
||||
int nbLignes = this.compterLignes();
|
||||
try {
|
||||
stmt = connexionTest.createStatement();
|
||||
// Acc<63>s <20> la table
|
||||
passer = stmt.executeUpdate("INSERT INTO OBSERVATION(idObservation, idMedoc, idPraticien, observation) "
|
||||
+ "VALUES ("+(nbLignes+1)+",'"+idMedoc+"',"+idPraticien+",\""+observation+"\");");
|
||||
|
||||
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 passer;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user