Nico creation methodes vides #7
3 changed files with 70 additions and 53 deletions
|
|
@ -72,7 +72,9 @@ public class DataBase {
|
||||||
" devise VARCHAR(10));"; //25 String
|
" devise VARCHAR(10));"; //25 String
|
||||||
//System.out.println(sql);
|
//System.out.println(sql);
|
||||||
try {
|
try {
|
||||||
|
if(conn==null) {
|
||||||
conn = DriverManager.getConnection(url); //connection a la db
|
conn = DriverManager.getConnection(url); //connection a la db
|
||||||
|
}
|
||||||
if(conn!=null) {
|
if(conn!=null) {
|
||||||
stmt = conn.createStatement(); //creation de la declaration
|
stmt = conn.createStatement(); //creation de la declaration
|
||||||
res=stmt.executeUpdate(sql); //execution de la declaration
|
res=stmt.executeUpdate(sql); //execution de la declaration
|
||||||
|
|
@ -197,7 +199,9 @@ public class DataBase {
|
||||||
if (nbValAj>0) {//si on a des modifications
|
if (nbValAj>0) {//si on a des modifications
|
||||||
PreparedStatement ps;
|
PreparedStatement ps;
|
||||||
try {
|
try {
|
||||||
|
if (conn == null) {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
|
}
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
ps=conn.prepareStatement(sql);
|
ps=conn.prepareStatement(sql);
|
||||||
for(int a=0;a<nbValAj;a++){//pour chaque case de chaque ligne ajoutée, on va ajouter la valeur
|
for(int a=0;a<nbValAj;a++){//pour chaque case de chaque ligne ajoutée, on va ajouter la valeur
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,27 @@ public class Choix {
|
||||||
public long num3_bonusCpt[];
|
public long num3_bonusCpt[];
|
||||||
public long taille;
|
public long taille;
|
||||||
|
|
||||||
|
public Choix(){
|
||||||
|
maDB=new DataBase();
|
||||||
|
conn= maDB.getConnection();
|
||||||
|
//maDB.getConnection();
|
||||||
|
numSelect =new long[5];
|
||||||
|
numId =new long[50][4000];
|
||||||
|
numCpt = new long[50][2];
|
||||||
|
combi1Id =new long[50][4000];
|
||||||
|
combi1Cpt = new long[50];
|
||||||
|
num1_bonusId =new long[11][4000];
|
||||||
|
num1_bonusCpt = new long[11];
|
||||||
|
num2_bonusId =new long[11][4000];
|
||||||
|
num2_bonusCpt = new long[11];
|
||||||
|
num3_bonusId =new long[11][4000];
|
||||||
|
num3_bonusCpt = new long[11];
|
||||||
|
combi2Id=new long[50][4000];
|
||||||
|
combi2Cpt=new long[50];
|
||||||
|
bonusId =new long[11][4000];
|
||||||
|
bonusCpt=new long[11][2];
|
||||||
|
}
|
||||||
|
|
||||||
public void setTaille(){
|
public void setTaille(){
|
||||||
try {
|
try {
|
||||||
conn = maDB.getConnection();
|
conn = maDB.getConnection();
|
||||||
|
|
@ -47,26 +68,7 @@ public class Choix {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public Choix(){
|
|
||||||
maDB=new DataBase();
|
|
||||||
maDB.getConnection();
|
|
||||||
numSelect =new long[5];
|
|
||||||
numId =new long[50][4000];
|
|
||||||
numCpt = new long[50][2];
|
|
||||||
combi1Id =new long[50][4000];
|
|
||||||
combi1Cpt = new long[50];
|
|
||||||
num1_bonusId =new long[11][4000];
|
|
||||||
num1_bonusCpt = new long[11];
|
|
||||||
num2_bonusId =new long[11][4000];
|
|
||||||
num2_bonusCpt = new long[11];
|
|
||||||
num3_bonusId =new long[11][4000];
|
|
||||||
num3_bonusCpt = new long[11];
|
|
||||||
combi2Id=new long[50][4000];
|
|
||||||
combi2Cpt=new long[50];
|
|
||||||
bonusId =new long[11][4000];
|
|
||||||
bonusCpt=new long[11][2];
|
|
||||||
conn= maDB.getConnection();
|
|
||||||
}
|
|
||||||
public void afficherChiffre1() throws SQLException {
|
public void afficherChiffre1() throws SQLException {
|
||||||
System.out.println("debut afficherChiffre1");
|
System.out.println("debut afficherChiffre1");
|
||||||
int k=0, numprec=0, l=0;
|
int k=0, numprec=0, l=0;
|
||||||
|
|
@ -76,7 +78,9 @@ public class Choix {
|
||||||
for (int i=1; i<6;i++) {
|
for (int i=1; i<6;i++) {
|
||||||
sql = "SELECT Test_Table.boule_" + i + ",Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.boule_" + i + "; ";
|
sql = "SELECT Test_Table.boule_" + i + ",Count(*) as 'cnt' FROM myny.Test_Table GROUP BY Test_Table.boule_" + i + "; ";
|
||||||
try {
|
try {
|
||||||
|
if(conn==null) {
|
||||||
conn = maDB.getConnection();
|
conn = maDB.getConnection();
|
||||||
|
}
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
Statement ps = conn.createStatement();
|
Statement ps = conn.createStatement();
|
||||||
rs = ps.executeQuery(sql);
|
rs = ps.executeQuery(sql);
|
||||||
|
|
@ -105,7 +109,9 @@ public class Choix {
|
||||||
for (int i=1; i<=5;i++) {
|
for (int i=1; i<=5;i++) {
|
||||||
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.boule_" + i + " FROM myny.Test_Table ORDER BY Test_Table.boule_" + i + "; ";
|
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.boule_" + i + " FROM myny.Test_Table ORDER BY Test_Table.boule_" + i + "; ";
|
||||||
try {
|
try {
|
||||||
|
if(conn==null) {
|
||||||
conn = maDB.getConnection();
|
conn = maDB.getConnection();
|
||||||
|
}
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
Statement ps = conn.createStatement();
|
Statement ps = conn.createStatement();
|
||||||
rs = ps.executeQuery(sql);
|
rs = ps.executeQuery(sql);
|
||||||
|
|
@ -148,26 +154,27 @@ public class Choix {
|
||||||
System.out.println("debut afficherCombinaisons2");
|
System.out.println("debut afficherCombinaisons2");
|
||||||
numSelect[1]=chiffre1;
|
numSelect[1]=chiffre1;
|
||||||
int j=0, k=0, l=0, cpt=0;
|
int j=0, k=0, l=0, cpt=0;
|
||||||
|
while (numId[chiffre1][j] != 0) {
|
||||||
for(int i=1;i<50;i++) {
|
for(int i=1;i<50;i++) {
|
||||||
if (i != chiffre1) {
|
if (i != chiffre1) {
|
||||||
while (numId[chiffre1][j] != 0) {
|
|
||||||
while (numId[i][k] != 0) {
|
while (numId[i][k] != 0) {
|
||||||
//System.out.println(numId[i][k] +"=="+ numId[chiffre1][j]);
|
|
||||||
if (numId[i][k] == numId[chiffre1][j]) {
|
if (numId[i][k] == numId[chiffre1][j]) {
|
||||||
combi1Cpt[i]++;
|
//System.out.println("[i:"+i+"][k:"+k+"][j:"+j+"]");
|
||||||
combi1Id[i][cpt++]=numId[i][k];
|
//System.out.println(numId[i][k] +"=="+ numId[chiffre1][j]);
|
||||||
|
//combi1Cpt[i]++;
|
||||||
|
combi1Id[i][(int)combi1Cpt[i]++]=numId[i][k];
|
||||||
|
//System.out.println("[cpt:"+cpt+"]");
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
k = 0;
|
k = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
cpt=0;
|
cpt=0;
|
||||||
}
|
}
|
||||||
for (int i=1; i<50;i++) {
|
for (int i=1; i<50;i++) {
|
||||||
/*for (int p=1; p<50;p++) {
|
/*for (int p=0; p<50;p++) {
|
||||||
System.out.print(combi1Id[i][p]+", ");
|
System.out.print(combi1Id[i][p]+", ");
|
||||||
}*/
|
}*/
|
||||||
System.out.println(i+": "+combi1Cpt[i]);
|
System.out.println(i+": "+combi1Cpt[i]);
|
||||||
|
|
@ -182,31 +189,33 @@ public class Choix {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afficherCombinaisons3(int chiffre1, int chiffre2) throws SQLException {
|
public void afficherCombinaisons3(int chiffre1, int chiffre2) throws SQLException {
|
||||||
afficherChiffre1();
|
//afficherChiffre1();
|
||||||
afficherCombinaisons2(chiffre1);
|
afficherCombinaisons2(chiffre1);
|
||||||
System.out.println("debut afficherCombinaisons3");
|
System.out.println("debut afficherCombinaisons3");
|
||||||
numSelect[2]=chiffre2;
|
numSelect[2]=chiffre2;
|
||||||
int j=0, k=0, m=0, cpt=0;
|
int j=0, k=0, m=0, cpt=0;
|
||||||
|
while (combi1Id[chiffre2][j] != 0){
|
||||||
for(int i=1;i<50;i++) {
|
for(int i=1;i<50;i++) {
|
||||||
if (i != chiffre1 && i!=chiffre2) {
|
if (i != chiffre1 && i!=chiffre2) {
|
||||||
while (combi1Id[chiffre2][j] != 0){
|
|
||||||
while (numId[i][k] != 0) {
|
while (numId[i][k] != 0) {
|
||||||
//System.out.println(numId[i][k] +"=="+ combi1Id[chiffre2][j]);
|
//System.out.println(numId[i][k] +"=="+ combi1Id[chiffre2][j]);
|
||||||
if (numId[i][k] == combi1Id[chiffre2][j]) {
|
if (numId[i][k] == combi1Id[chiffre2][j]) {
|
||||||
combi2Cpt[i]++;
|
//combi2Cpt[i]++;
|
||||||
combi2Id[i][cpt++]=numId[i][k];
|
combi2Id[i][(int)combi2Cpt[i]++]=numId[i][k];
|
||||||
|
//j++;
|
||||||
|
//k=0;
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
k = 0;
|
k = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
cpt=0;
|
cpt=0;
|
||||||
}
|
}
|
||||||
|
k = 0;
|
||||||
for (int i=1; i<50;i++) {
|
for (int i=1; i<50;i++) {
|
||||||
/*for (int p=1; p<50;p++) {
|
/*for (int p=0; p<50;p++) {
|
||||||
System.out.print(combi1Id[i][p]+", ");
|
System.out.print(combi1Id[i][p]+", ");
|
||||||
}*/
|
}*/
|
||||||
System.out.println(i+": "+combi2Cpt[i]);
|
System.out.println(i+": "+combi2Cpt[i]);
|
||||||
|
|
@ -243,10 +252,11 @@ public class Choix {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
bonusCpt[rs.getInt(1)][0] = rs.getInt(1);
|
bonusCpt[rs.getInt(1)][0] = rs.getInt(1);
|
||||||
bonusCpt[rs.getInt(1)][1] = rs.getLong(2);
|
bonusCpt[rs.getInt(1)][1] = rs.getLong(2);
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int i=0; i<11;i++) {
|
/*for (int i=0; i<11;i++) {
|
||||||
System.out.println(i+" :"+ bonusCpt[i][1]);
|
System.out.println(i+" :"+ bonusCpt[i][1]);
|
||||||
}
|
}*/
|
||||||
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.numero_chance FROM myny.Test_Table ORDER BY Test_Table.numero_chance; ";
|
sql = "SELECT Test_Table.annee_numero_de_tirage, Test_Table.numero_chance FROM myny.Test_Table ORDER BY Test_Table.numero_chance; ";
|
||||||
try {
|
try {
|
||||||
conn = maDB.getConnection();
|
conn = maDB.getConnection();
|
||||||
|
|
@ -270,7 +280,7 @@ public class Choix {
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
bonusId[rs.getInt(2)][k]=rs.getInt(1);
|
bonusId[rs.getInt(2)][k]=rs.getInt(1);
|
||||||
System.out.println(bonusId[rs.getInt(2)][k]);
|
//System.out.println(bonusId[rs.getInt(2)][k]);
|
||||||
numprec=rs.getInt(2);
|
numprec=rs.getInt(2);
|
||||||
}
|
}
|
||||||
k=0;
|
k=0;
|
||||||
|
|
@ -300,6 +310,7 @@ public class Choix {
|
||||||
num1_bonusCpt[i]++;
|
num1_bonusCpt[i]++;
|
||||||
num1_bonusId[i][cpt++]=bonusId[i][k];
|
num1_bonusId[i][cpt++]=bonusId[i][k];
|
||||||
j++;
|
j++;
|
||||||
|
k=0;
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
|
@ -339,6 +350,7 @@ public class Choix {
|
||||||
num2_bonusCpt[i]++;
|
num2_bonusCpt[i]++;
|
||||||
num2_bonusId[i][cpt++]=bonusId[i][k];
|
num2_bonusId[i][cpt++]=bonusId[i][k];
|
||||||
j++;
|
j++;
|
||||||
|
k=0;
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
|
@ -348,7 +360,7 @@ public class Choix {
|
||||||
j = 0;
|
j = 0;
|
||||||
cpt=0;
|
cpt=0;
|
||||||
}
|
}
|
||||||
for (int i=1; i<11;i++) {
|
for (int i=0; i<11;i++) {
|
||||||
/*for (int p=1; p<50;p++) {
|
/*for (int p=1; p<50;p++) {
|
||||||
System.out.print(combi1Id[i][p]+", ");
|
System.out.print(combi1Id[i][p]+", ");
|
||||||
}*/
|
}*/
|
||||||
|
|
@ -376,9 +388,11 @@ public class Choix {
|
||||||
while (bonusId[i][k] != 0) {
|
while (bonusId[i][k] != 0) {
|
||||||
//System.out.println(combi2Id[chiffre3][j] +"=="+ bonusId[i][k]);
|
//System.out.println(combi2Id[chiffre3][j] +"=="+ bonusId[i][k]);
|
||||||
if (bonusId[i][k] == combi2Id[chiffre3][j]) {
|
if (bonusId[i][k] == combi2Id[chiffre3][j]) {
|
||||||
num3_bonusCpt[i]++;
|
//num3_bonusCpt[i]++;
|
||||||
num3_bonusId[i][cpt++]=bonusId[i][k];
|
//num3_bonusId[i][cpt++]=bonusId[i][k];
|
||||||
|
num3_bonusId[i][(int) num3_bonusCpt[i]++]=bonusId[i][k];
|
||||||
j++;
|
j++;
|
||||||
|
k=0;
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
|
@ -388,8 +402,8 @@ public class Choix {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
for (int i=1; i<11;i++) {
|
for (int i=1; i<11;i++) {
|
||||||
/*for (int p=1; p<50;p++) {
|
/*for (int p=0; p<50;p++) {
|
||||||
System.out.print(combi1Id[i][p]+", ");
|
System.out.print(num3_bonusId[i][p]+", ");
|
||||||
}*/
|
}*/
|
||||||
System.out.println(i+": "+num3_bonusCpt[i]);
|
System.out.println(i+": "+num3_bonusCpt[i]);
|
||||||
while(num3_bonusId[i][l]!=0){
|
while(num3_bonusId[i][l]!=0){
|
||||||
|
|
@ -399,6 +413,5 @@ public class Choix {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
l=0;
|
l=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,13 +18,13 @@ public class test{
|
||||||
|
|
||||||
|
|
||||||
Choix c=new Choix();
|
Choix c=new Choix();
|
||||||
c.setTaille();
|
//c.setTaille();
|
||||||
//c.afficherChiffre1();
|
//c.afficherChiffre1();
|
||||||
//c.afficherNumBonus();
|
//c.afficherNumBonus();
|
||||||
//c.afficherCombinaisons2(4);
|
//c.afficherCombinaisons2(4);
|
||||||
//c.afficherNumBonus(1);
|
//c.afficherNumBonus(1);
|
||||||
//c.afficherCombinaisons3(32,16);
|
//c.afficherCombinaisons3(32,16);
|
||||||
//c.afficherNumBonusCombi2(5,10);
|
//c.afficherNumBonusCombi2(5,10);
|
||||||
//c.afficherNumBonusCombi3(28,14,37);
|
c.afficherNumBonusCombi3(28,14,37);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in a new issue