Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package muzica;
  2.  
  3. import java.awt.AWTException;
  4. import java.awt.Robot;
  5. import java.awt.event.InputEvent;
  6. import java.sql.*;
  7. public class Muzica {
  8.  
  9. static void schimba() throws AWTException, InterruptedException{
  10. Robot r=new Robot();
  11. Thread.sleep(1000);
  12. r.mouseMove(103,1005);
  13. r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  14. r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  15.  
  16. }
  17.  
  18. static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
  19. static final String DB_URL = "jdbc:mysql://localhost/muzica";
  20.  
  21. // Database credentials
  22. static final String USER = "root";
  23. static final String PASS = "parola123";
  24. public static void main(String[] args) throws AWTException, InterruptedException{
  25.  
  26.  
  27. Connection conn = null;
  28. Statement stmt = null;
  29. ResultSet rs=null;
  30.  
  31. try {
  32. Class.forName("com.mysql.jdbc.Driver");
  33. } catch (ClassNotFoundException e) {
  34. // TODO Auto-generated catch block
  35. e.printStackTrace();
  36. }
  37.  
  38. //STEP 3: Open a connection
  39. System.out.println("Connecting to a selected database...");
  40. try {
  41. conn = DriverManager.getConnection(DB_URL, USER, PASS);
  42. } catch (SQLException e) {
  43. // TODO Auto-generated catch block
  44. e.printStackTrace();
  45. }
  46.  
  47.  
  48. while(true){
  49. try{
  50. //STEP 2: Register JDBC driver
  51. System.out.println("Connected database successfully...");
  52. stmt = conn.createStatement();
  53. // ResultSet a=stmt.executeQuery("insert into note (nume,materie,nota) values (\"alexandru\",\"romana\",\"5\");");
  54. rs=stmt.executeQuery("select * from song;");
  55. if(rs.next()){
  56. int a=rs.getInt("schimba");
  57. System.out.println(a);
  58. schimba();
  59. stmt.execute("delete from song where schimba="+a);
  60. }
  61. }catch(SQLException se){
  62. //Handle errors for JDBC
  63. se.printStackTrace();
  64. }
  65. System.out.println("Goodbye!");
  66.  
  67.  
  68.  
  69.  
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement