Package com.mysql.jdbc

Examples of com.mysql.jdbc.Connection


    return id;
  }
 
  @Override
  public void ajouterBon(Bon b) {
    Connection connex;
    connex = getConnection();
    String insert = "INSERT INTO `bon`(`id`) VALUES (?)";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(insert);   
      preStat.setInt(1, b.getId());
      preStat.executeUpdate();
    }catch (SQLException ignore) {     
      System.out.println("erreur ajouterBon : " + ignore);
    }
View Full Code Here


   * retourne une arraylist composée des id des achat de l'utilisateur passé en paramètre
   * @see com.netflox.dao.GestionVente#venteUtilisateur(com.netflox.model.Utilisateur)
   */
  public ArrayList<Vente> venteUtilisateur(Utilisateur c) {
    ArrayList<Vente> l = new ArrayList<Vente>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT * FROM `vente` WHERE `idClient` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, c.getId());       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        Vente v = new Vente();
        v.setId(rs.getInt(1));
View Full Code Here

  }
 
  @Override
  public ArrayList<String[]> filmLoueUtilisateur(Utilisateur c) {
    ArrayList<String[]> l = new ArrayList<String[]>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT `idFilm`,`date` FROM `vente` WHERE `idClient` = ? AND `type` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, c.getId());
      preStat.setString(2, "l");
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        String loc[] = {rs.getString(1) , String.valueOf(rs.getLong(2))};
View Full Code Here

   * retourne la liste des films vendu
   * @see com.netflox.dao.GestionVente#filmVendu()
   */
  public ArrayList<String> filmsInfosVenteLoueBon(String type) {
    ArrayList<String> l = new ArrayList<String>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT  `idFilm` FROM `vente` WHERE `type` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setString(1, type);       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        l.add(rs.getString(1));
      }
View Full Code Here

    return l;
  }

  @Override
  public int bonValide(int id) {
    Connection connex;
    connex = getConnection();
    String select = "SELECT `utilise` FROM `bon` WHERE `id`= ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setInt(1, id);       
      ResultSet rs = preStat.executeQuery();
      while(rs.next()){
        if(rs.getInt(1) == 0){
          int montant = -1;
          String select2 = "SELECT `prix` FROM `vente` WHERE `id` = ?";
          PreparedStatement preStat2 = (PreparedStatement) connex.prepareStatement(select2);   
          preStat2.setInt(1, id);       
          ResultSet rs2 = preStat2.executeQuery();
          while(rs2.next()){
            montant = rs2.getInt(1);
          }
View Full Code Here

    return -1;
  }

  @Override
  public void updateBon(Bon b) {
    Connection connex;
    connex = getConnection();
    String select = "UPDATE `bon` SET `idFilm`=?,`dateU`=?,`type`=?,`idClientU`=?,`utilise`=? WHERE `id` = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(select);   
      preStat.setString(1, b.getIdFilm());
      preStat.setLong(2, b.getDateU());
      preStat.setString(3, b.getType());
      preStat.setInt(4, b.getIdClientU());
      preStat.setInt(5, b.getUtilise());
View Full Code Here

        this.detailDao = detailDao;
    }

    public List getPipeLineListByObjectInspectionId(Integer id, Properties props) throws SQLException {

        Connection dbConn = getConnection(props);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select * from pipeLineElement where objectId=" + id);
        List plList = setValues(rs);
        rs.close();
        return plList;

View Full Code Here

    }

    public List getPipeLineListByObjectInspectionAndDetailType(Integer typeId, Integer objectId, Properties props) throws SQLException {


        Connection dbConn = getConnection(props);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select * from pipeLineElement where objectId=" + objectId + " and detailTypeId=" + typeId);
        List plList = setValues(rs);
        rs.close();

        return plList;
View Full Code Here

    }

    private Connection getConnection(Properties props) {

        String driverURL = "jdbc:mysql://localhost/vstbase?useUnicode=true&amp;characterEncoding=UTF-8";
        Connection dbConn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            dbConn = (Connection) DriverManager.getConnection(driverURL, props);
            return dbConn;
        }
View Full Code Here

import junit.framework.TestCase;

public class ContextTest extends TestCase {

  public void testDBConnection() throws Exception {
    Connection conS =  Context.getSourceConnection();
    assertFalse(conS.isClosed());
   
    Connection conD =  Context.getDestinationConnection();
    assertFalse(conD.isClosed());
  }
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.