1 2 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
| package Maillage;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import Connexion.Connexion;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JTextField;
public class lister_tables2 {
private ResultSet rs;
Vector<Object> v=new Vector<Object>();
private String base=null;
Connection con;
private Recuperer_Liens_Ancres donnees;
private ArrayList<JTextField> motcleUrl;
public lister_tables2(Connexion con,Recuperer_Liens_Ancres donnees, ArrayList<JTextField> motsCle_Et_Url ) {
this.donnees=donnees;
this.con= (Connection) con.getConnexion();
this.motcleUrl=motsCle_Et_Url;
// System.out.println(con.getBase());
Vector s=new Vector();
this.base=con.getBase();
DatabaseMetaData md;
try {
md = this.con.getMetaData();
rs = md.getTables(null,null, "%", null);
int i=0;
while (rs.next()) {
// System.out.println(rs.getString(3));
s.add(rs.getString(3));
//System.out.println(++i);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println(s.get(3));
for(int t=0;t<s.size();t++){
getdata(s.get(t).toString());
}
}
public void getdata(String table){
try {
int i=0;
Statement st = (Statement) con.createStatement();
//System.out.println("table "+table);
rs=st.executeQuery("select * from "+table);
//System.out.println()
i=rs.getMetaData().getColumnCount();
//for(int a=1;a<i;a++){
int j=i;
while(rs.next()){
while(j>0){
//System.out.println(rs.getString(j));
recherche(rs.getString(j),
table,
j,
rs.getMetaData().getColumnName(j));
j=j-1;
}j=i;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
//e.printStackTrace(); Il y' a une exception sur le timestame
}
}
/*
*
*
*
*/
public void recherche(String chaine,String tablename,int a,String nomColon) throws SQLException{
//System.out.println("la recherche "+chaine);
for (int e =0;e< donnees.getData().size();e++ ){
//System.out.println(" traore "+donnees.getData().elementAt(0));’intégralité de votre contenu dans WordPress.
if(chaine.contains(donnees.getData().elementAt(e).toString())){
System.out.println("Nom table "+tablename+" Numero colonne "+a+" texte "+chaine+" Equivalance "+donnees.getData().elementAt(e).toString());
replaceMot( chaine,tablename,nomColon);
}
}
}
public void Update(String chaineUpdate,String chaineReplace,String NomTable,String base,String nomColon) throws SQLException{
String requetUpdate="UPDATE `"+base+"`.`"+NomTable+"` SET `"+nomColon+"` = '"+chaineReplace+"' WHERE `"+NomTable+"`.`"+nomColon+"` = '"+chaineUpdate+"'";
gestion_Update(requetUpdate);
}
public void gestion_Update(String reket){
try {
Statement st = (Statement) con.createStatement();
st.executeUpdate(reket);
con.setAutoCommit(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void replaceMot(String chaine,String tablename,String nomColon){
for(int i=0;i<motcleUrl.size()-1;i++){
if(chaine.contains(motcleUrl.get(1).getText()+"</a>")||chaine.contains(motcleUrl.get(1).getText()+" </a>")){
}else{
if(chaine.contains(motcleUrl.get(1).getText())){System.out.println("tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt");
String chaineReplace = chaine.replaceAll(motcleUrl.get(1).getText(), "<a href=\""+motcleUrl.get(i).getText()+"\">"+motcleUrl.get(1).getText()+"</a>");
try {
Update(chaine,chaineReplace, tablename,this.base,nomColon);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
/*public void test(int i) throws SQLException{
for(int a=1;a<=i;a++){
v.add(rs.getString(a));
}
}
*/} |
Partager