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
| try {
Class.forName("com.mysql.jdbc.Driver" );
String url = "jdbc:mysql://localhost:3306/mediaisep";
String user = "root";
String passwd = "";
Connection conn = DriverManager.getConnection(url, user, passwd);
Statement state = conn.createStatement();
state.executeUpdate("INSERT INTO photos(nom,legende,proprio,taille,date) VALUES ('"+ nom +"','"+ legende +"','"+ proprio +"','"+ taille +"','"+ date +"')");
FTPClient ftp;
try {
// Populate these variables with the necessary info.
String host = "mediaisep.franceserv.com";
String username = "*******";
String password = "*******";
String remotePath = "";
String localPath = "";
// set up client
ftp = new FTPClient();
ftp.setRemoteHost(host);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
// connect
System.out.println ("Connecting");
ftp.connect();
// login
System.out.println ("Logging in");
ftp.login(username, password);
// set up passive ASCII transfers
System.out.println ("Setting up passive, ASCII transfers");
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setType(FTPTransferType.ASCII);
// copy file to server
System.out.println ("Putting file");
String nom_fich = chemin.split("\\\\")[chemin.split("\\\\").length-1];
ftp.put(chemin, "mediaisep.franceserv.com/" + nom_fich);
// Shut down client
System.out.println ("Quitting client");
ftp.quit();
return "BDD + FTP";
} catch (Exception e) {
return "BDD " + e;
} |
Partager