comptage du nombre d'apparitions de chaque chiffre, et stockage des id des lignes dans lesquelles ilapparait
This commit is contained in:
parent
c5c901c0a2
commit
94b829cc99
3 changed files with 22 additions and 19 deletions
|
|
@ -12,7 +12,7 @@ public class DataBase {
|
|||
//public static String url="jdbc:mariadb://vachot.fr:3306?user=mynynicolas&password=Bw0po64*";
|
||||
public static final int NBCOL =25;//le nombre de coldu fichier csv
|
||||
public static final String url="jdbc:mariadb://phpmyadmin.vachot.fr:3306?db=myny&user=mynynicolas&password=Bw0po64*";//l'acces à la db
|
||||
Connection conn;//la connexion a la db
|
||||
public Connection conn;//la connexion a la db
|
||||
|
||||
/**
|
||||
* La methode de connection
|
||||
|
|
@ -233,7 +233,6 @@ public class DataBase {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* La methode de mise a jour de la base de donnees
|
||||
* @param filePath String, le chemin+nom du fichier+extension
|
||||
* @return res int, le resultat de la requete(nb de ligne affectees)
|
||||
|
|
@ -248,9 +247,8 @@ public class DataBase {
|
|||
* <p>an String, l annee lue</p>
|
||||
* <p>anEntre long, valeur lue pour l annee et le numero de tirage. sert a definir si la valeur est a ajouter dans la table</p>
|
||||
* @deprecated
|
||||
* @throws FileNotFoundException si le fichier nest pas trouve
|
||||
*/
|
||||
public int updateTable(String filePath) throws FileNotFoundException {
|
||||
public int updateTable(String filePath) {
|
||||
ResultSet rs=null;
|
||||
Scanner sc;
|
||||
int res=-1;
|
||||
|
|
@ -355,13 +353,13 @@ public class DataBase {
|
|||
//conn.close();
|
||||
System.out.println("update validee");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("updateDataBase probleme");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("updateDataBase probleme");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
|
@ -372,7 +370,6 @@ public class DataBase {
|
|||
* La methode de mise a jour de la base de donnees 2 qui evite les injections sql
|
||||
* @param filePath String, le chemin+nom du fichier+extension
|
||||
* @return rs, int, le resultat de la requete (nb de lignes affectees)
|
||||
* @throws FileNotFoundException si le fichier nest pas trouve
|
||||
* <p>mesL tableau dans lequel seront stockes tous les long</p>
|
||||
* <p>mesS tableau dans lequel seront stockes tous les String</p>
|
||||
* <p>mesD tableau dans lequel seront stockes tous les Double</p>
|
||||
|
|
@ -391,7 +388,7 @@ public class DataBase {
|
|||
* <p>ps PreparedStatement pour executer la requete sans injection sql</p>
|
||||
* <p>stmt Statement pour executer la requete de depart</p>
|
||||
*/
|
||||
public int updateTablev2(String filePath) throws FileNotFoundException {
|
||||
public int updateTablev2(String filePath) {
|
||||
//Ligne maL=new Ligne();
|
||||
ResultSet rs=null;
|
||||
int res=-1;
|
||||
|
|
@ -515,13 +512,13 @@ public class DataBase {
|
|||
//res=ps.executeQuery();//puis on execute la requete
|
||||
System.out.println("update validee");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("updateDataBasev2 probleme");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println("updateDataBasev2 probleme, verifier si le pb ne vient pas de executeupdate au lie de executequery");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.exceptions.CsvException;
|
||||
//import com.opencsv.CSVReader;
|
||||
//import com.opencsv.exceptions.CsvException;
|
||||
import fr.myny.database.DataBase;
|
||||
import fr.myny.stats.Choix;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import com.opencsv.CSVReader;
|
||||
//import com.opencsv.CSVReader;
|
||||
|
||||
public class test{
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws SQLException {
|
||||
System.out.println("Il n'y a rien a voir !");
|
||||
System.out.println("nico fait un test");
|
||||
System.out.println("Il Je test les branchs");
|
||||
|
||||
|
||||
Choix c=new Choix();
|
||||
c.afficherChiffre1();
|
||||
//c.afficherNumBonus();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ class DataBaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void updateTable() throws FileNotFoundException, SQLException {
|
||||
void updateTable() {
|
||||
DataBase maDB=new DataBase();
|
||||
maCo=maDB.getConnection();
|
||||
int res = maDB.updateTable(FILEPATH);
|
||||
|
|
@ -53,7 +53,7 @@ class DataBaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void updateTablev2() throws FileNotFoundException, SQLException {
|
||||
void updateTablev2() {
|
||||
DataBase maDB=new DataBase();
|
||||
maCo=maDB.getConnection();
|
||||
int res = maDB.updateTablev2(FILEPATH);
|
||||
|
|
@ -80,20 +80,20 @@ class DataBaseTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void removeMultiplesLines() throws FileNotFoundException{
|
||||
public void removeMultiplesLines(){
|
||||
DataBase maDB=new DataBase();
|
||||
int res= maDB.removeMultiplesLines(2017004);
|
||||
System.out.print(res);
|
||||
}
|
||||
@Test
|
||||
public void removeLine() throws FileNotFoundException{
|
||||
public void removeLine(){
|
||||
DataBase maDB=new DataBase();
|
||||
int res= maDB.removeLine(2017014);
|
||||
System.out.print(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dropTable() throws FileNotFoundException{
|
||||
public void dropTable(){
|
||||
DataBase maDB=new DataBase();
|
||||
maDB.dropTable();
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue