| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 
 |  
import java.io.UnsupportedEncodingException;
import java.nio.charset.CharsetDecoder;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import mainPackage.article.ArticleModel;
/*
 * Essai.java
 *
 * Created on 26 mai 2007, 16:37
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
 
/**
 *
 * @author ACER
 */
public class Essai {
    private String url;
    private Connection c;
    CharsetDecoder decodeur ;
    /** Creates a new instance of Essai */
    public Essai() {
 
        try{
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://127.0.0.1/projet";
            c =   DriverManager.getConnection(url, "root", "sangoku");
            //DriverManager.getConnection("jdbc:mysql://127.0.0.1/projet"+"?useUnicode=true&characterEncoding=cp1250", "root", "sangoku");
        }catch (Exception e) {
 
        }
 
    }
 
    public void get() throws UnsupportedEncodingException{
        ArticleModel m = null ;
        String myString = "";
        try {
 
            // On recupere le numero de ce client
            Statement s = c.createStatement();
            ResultSet rs = s.executeQuery("select * from article ");
 
 
            while ( rs.next() ) {
                System.out.println(rs.getString("texte"));
            }
 
        } catch (SQLException ex) {
 
        }
 
    }
 
    public static void main(String [] args) throws UnsupportedEncodingException{
        Essai e = new Essai() ;
        e.get();
    }
 
 
 
 
 
 
} | 
Partager