Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class main extends safe{
- static Scanner sc = new Scanner(System.in);
- public static String PID = "76561198142035536";
- public static String conURL = "jdbc:mysql://185.243.8.136:3306/altislife?verifyServerCertificate=false&useSSL=true";
- public static void main(String [] args){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection(conURL, user, pw);
- Statement stmt=con.createStatement();
- //String input = "SELECT bankacc FROM players WHERE pid'76561198142035536'";
- String DBinput = "SELECT pid, name, cash, bankacc, adminlevel, donorlevel, playtime FROM players WHERE pid='"+ PID+ "'";
- ResultSet rs=stmt.executeQuery(DBinput);
- System.out.println("1 Ausgabe | 2 Eingabe | 3 Beenden");
- int eingabe = sc.nextInt();
- switch(eingabe){
- case 1: readDB(rs,stmt,con) ;break;
- case 2: break;
- case 3: System.out.println("System ist beendet!"); System.exit(0) ;break;
- }
- conClose(con);
- }catch(Exception e){ System.out.println(e);}
- }
- private static void conClose(Connection con) throws SQLException {
- con.close();
- }
- private static void readDB(ResultSet db,Statement stmt,Connection con) throws SQLException {
- while(db.next()){
- int test1 = db.getInt("bankacc");
- System.out.println("Geben sie einen Betrag ein: ");
- int test2 = sc.nextInt();
- test1 = test1+test2;
- System.out.println(test1);
- updatedb(stmt, con, test1);
- }
- }
- private static void updatedb(Statement stmt, Connection con, int money) throws SQLException {
- String DBUpdater = "UPDATE players SET bankacc='" + money +"' WHERE pid='" + PID + "'";
- int rs = stmt.executeUpdate(DBUpdater);
- System.out.println(rs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement