summaryrefslogtreecommitdiffstats
path: root/bwLehrpool_ServerMaintenance/src/sql/sql.java
blob: 61b951727cccb6518f86e6807f1367a33ba9c023 (plain) (blame)
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
package sql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;

public class sql {
	
	public Connection getConnection() {
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		} catch (InstantiationException | IllegalAccessException
				| ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			Connection con = DriverManager
					.getConnection("jdbc:mysql://localhost/bwlehrpool?user=bwlp_user&password=!20bwlehrpool14!");
			con.setAutoCommit(false);
			
			return con;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
	
			e.printStackTrace();
		}
		return null;
	}
	
	
	public void deleteFTPUsers(){
		try {
			Connection con=getConnection();
			Statement stm = con.createStatement();

			stm.executeUpdate("Delete from bwLehrpool.FtpUsers where CreationDate > date_sub(now(),interval 1 day);");
			con.close();
			
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			
			e.printStackTrace();
		}
	}

}