- private static void selectRecord(){
- System.out.println("Inserisci i capi da visualizzare separati da,(*per visualizzarli tutti):");
- Scanner scanner=new Scanner(System.in);
- String str=scanner.nextLine();
- System.out.println("Inserisci le condizioni nel where:");
- String condizione=scanner.nextLine();
- String sql;
- if(condizione.isEmpty() ) {
- sql="SELECT"+str+"FROM Cast";
- }else {
- sql="SELECT"+str+"FROM Cast WHERE"+condizione;
- }
- }
- private static void insertRecord()throws SQLException {
- System.out.println("Inserisci il codice Cast");
- Scanner input;
- String Id_cast=input.nextLine();
- System.out.println("Inserisci il nome");
- String Nome=input.nextLine();
- System.out.println("Inserisci Cognome");
- String Cognome=input.nextLine();
- System.out.println("Inserisci il ruolo");
- String Ruolo=input.nextLine();
- String sql= "INSERT INTO Cast VALUES('"+Id_cast+"','"+Nome+"','"+Cognome+"','"+Ruolo+"')";
- Statement stmt=null;
- try {
- Connection conn;
- stmt=conn.createStatement();
- stmt.executeUpdate(sql);
- } catch(Exception e) {
- System.out.println(e.getMessage());
- }finally {
- try {
- if(stmt!=null) stmt.close();
- } catch (Exception e1) {
- System.out.println(e1.getMessage());
- }
- }
- }
- private static void updateRecord()throws SQLException {
- System.out.println("Inserisci il nuovo codice Cast");
- Scanner input;
- String Id_cast=input.nextLine();
- System.out.println("Inserisci il nuovo nome");
- String Nome=input.nextLine();
- System.out.println("Inserisci il nuovo Cognome");
- String Cognome=input.nextLine();
- System.out.println("Inserisci il nuovo ruolo");
- String Ruolo=input.nextLine();
- String sql="UPDATE Cast SET Id_cast='"+Id_cast+"',Nome='"+Nome+"',Cognome='"+Cognome+"',Ruolo='"+Ruolo+"'";
- Statement stmt=null;
- try {
- Connection conn;
- stmt=conn.createStatement();
- stmt.executeUpdate(sql);
- } catch(Exception e) {
- System.out.println(e.getMessage());
- }finally {
- try {
- if(stmt!=null) stmt.close();
- } catch (Exception e1) {
- System.out.println(e1.getMessage());
- }
- }
- }
- private static void deleteRecord() {
- System.out.println("Inserisci il codice Cast");
- Scanner sc;
- String Id_Cast=sc.nextLine();
- String sql="DELETE FROM Cast WHERE Id_cast='"+Id_Cast+"'";
- Statement stmt=null;
- try {
- Connection conn;
- stmt=conn.createStatement();
- stmt.executeUpdate(sql);
- } catch(Exception e) {
- System.out.println(e.getMessage());
- }finally {
- try {
- if(stmt!=null) stmt.close();
- } catch (Exception e1) {
- System.out.println(e1.getMessage());
- }
- }
- }