Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package muzica;
- import java.awt.AWTException;
- import java.awt.Robot;
- import java.awt.event.InputEvent;
- import java.sql.*;
- public class Muzica {
- static void schimba() throws AWTException, InterruptedException{
- Robot r=new Robot();
- Thread.sleep(1000);
- r.mouseMove(103,1005);
- r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- }
- static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:mysql://localhost/muzica";
- // Database credentials
- static final String USER = "root";
- static final String PASS = "parola123";
- public static void main(String[] args) throws AWTException, InterruptedException{
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs=null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //STEP 3: Open a connection
- System.out.println("Connecting to a selected database...");
- try {
- conn = DriverManager.getConnection(DB_URL, USER, PASS);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- while(true){
- try{
- //STEP 2: Register JDBC driver
- System.out.println("Connected database successfully...");
- stmt = conn.createStatement();
- // ResultSet a=stmt.executeQuery("insert into note (nume,materie,nota) values (\"alexandru\",\"romana\",\"5\");");
- rs=stmt.executeQuery("select * from song;");
- if(rs.next()){
- int a=rs.getInt("schimba");
- System.out.println(a);
- schimba();
- stmt.execute("delete from song where schimba="+a);
- }
- }catch(SQLException se){
- //Handle errors for JDBC
- se.printStackTrace();
- }
- System.out.println("Goodbye!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement