Package com.mysql.jdbc

Examples of com.mysql.jdbc.PreparedStatement


    @Test
    public void preProcessShouldBeginTracingPreparedStatementCall() throws Exception {
        final String sql = randomAlphanumeric(20);
        final String schema = randomAlphanumeric(20);

        final PreparedStatement statement = mock(PreparedStatement.class);
        when(statement.getPreparedSql()).thenReturn(sql);
        final Connection connection = mock(Connection.class);
        when(connection.getSchema()).thenReturn(schema);

        assertNull(subject.preProcess(null, statement, connection));
View Full Code Here


  BufferedImage img, admin, norm, bill, addz, del, edit, imgnext, pokedex, ndexBI;
  public Panel(){
    setFocusable(true);
     
    ndex=0;
    PreparedStatement s;
    try { //change the path
        img = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\pokemoncenter.jpg"));
        admin = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\admin.gif"));
        norm = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\Normal_click.jpg"));
        bill = ImageIO.read(new File("C:\\Users\\theworldiwant\\workspace\\INTRODB\\src\\Bill'shouse.jpg"));
View Full Code Here

    connex = getConnection();
    String insert = "INSERT INTO `user`(`id`, `pseudo`, `nom`, `prenom`, `solde`, `psswd`) VALUES ( ?, ?, ?, ?, ?, ?) ";

    try {
      // inscription
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(insert);

      preStat.setInt(1, 0);
      preStat.setString(2, utilisateur.getPseudo());
      preStat.setString(3, utilisateur.getNom());
      preStat.setString(4, utilisateur.getPrenom());
      preStat.setInt(5, utilisateur.getSolde());
      preStat.setString(6, utilisateur.getMotDePasse());

      int id = -1;
      preStat.executeUpdate(preStat.asSql(),
          preStat.RETURN_GENERATED_KEYS);
      // Les id auto-générées sont retournées sous forme de ResultSet
      ResultSet ids = preStat.getGeneratedKeys();
      if (ids.next()) {
        id = (int) ((long) ids.getObject(1));
      }

      utilisateur.setId(id);
View Full Code Here

    Connection connex;
    boolean exist = false;
    connex = getConnection();
    String select = "SELECT * FROM user WHERE pseudo = ? ";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(select);

      preStat.setString(1, utilisateur.getPseudo());

      ResultSet rs = preStat.executeQuery();
      exist = rs.next();

    } catch (SQLException ignore) {

    }
View Full Code Here

    Connection connex;
    boolean exist = false;
    connex = getConnection();
    String select = "SELECT * FROM user WHERE pseudo = ? AND psswd = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(select);

      preStat.setString(1, utilisateur.getPseudo());
      preStat.setString(2, utilisateur.getMotDePasse());

      ResultSet rs = preStat.executeQuery();
      exist = rs.next();
      //System.out.println(exist);
      if(exist){
        int id = rs.getInt(1);
        utilisateur.setId(id);
View Full Code Here

    Connection connex;
    int solde = -1;
    connex = getConnection();
    String select = "SELECT solde FROM user WHERE pseudo = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(select);

      preStat.setString(1, utilisateur.getPseudo());
      ResultSet rs = preStat.executeQuery();

      while(rs.next()){
        solde = rs.getInt(1);
      }
    } catch (SQLException ignore) {     
View Full Code Here

  public void updateSolde(Utilisateur utilisateur, int somme) {
    Connection connex;
    connex = getConnection();
    String select = "UPDATE user SET solde = solde + ? WHERE pseudo = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(select);
      preStat.setInt(1, somme);
      preStat.setString(2, utilisateur.getPseudo());
      preStat.executeUpdate();
    } catch (SQLException ignore) {
      System.out.println("erreur updateSolde : " + ignore);
    }
    closeConnection(connex);
  }
View Full Code Here

    ArrayList<Utilisateur> l = new ArrayList<Utilisateur>();
    Connection connex;
    connex = getConnection();
    String select = "SELECT  * FROM `user`";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(select);

      ResultSet rs = preStat.executeQuery();
      while (rs.next()) {
        Utilisateur u = new Utilisateur();
        u.setId(rs.getInt(1));
        u.setPseudo(rs.getString(2));
        u.setNom(rs.getString(3));
View Full Code Here

    Connection connex;
    connex = getConnection();
    String delete = "DELETE FROM `user` WHERE id = ?";
    try {
      PreparedStatement preStat = (PreparedStatement) connex
          .prepareStatement(delete);
     
    for (Utilisateur u : list) {
      preStat.setInt(1, u.getId());     
      preStat.executeUpdate()
    }

   
    } catch (SQLException ignore) {
      System.out.println("erreur tous utilisateur: " + ignore);
View Full Code Here

    int id = -1;
    Connection connex;
    connex = getConnection();
    String insert = "INSERT INTO `vente`(`idFilm`, `date`, `prix`, `idClient`, `type`) VALUES (?,?,?,?,?)";
    try {
      PreparedStatement preStat = (PreparedStatement) connex.prepareStatement(insert);   
      preStat.setString(1, v.getIdFilm());
      preStat.setLong(2, v.getDate());
      preStat.setInt(3, v.getPrix());
      preStat.setInt(4, v.getIdClient());
      preStat.setString(5, v.getType());
     
      preStat.executeUpdate(preStat.asSql(),preStat.RETURN_GENERATED_KEYS);
      //Les id auto-générées sont retournées sous forme de ResultSet
      ResultSet ids = preStat.getGeneratedKeys();
      if(ids.next()){
        id = (int)((long)ids.getObject(1))
      }
    } catch (SQLException ignore) {
      System.out.println("erreur ajouterVente : " + ignore);
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.PreparedStatement

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.