用JAVA和SQL实现音乐管理系统

在这里插入图片描述

View.java

package com.zhongruan;

import com.zhongruan.dao.MusicDao;
import com.zhongruan.dao.UserDao;
import com.zhongruan.exception.LoginException;
import com.zhongruan.model.Music;
import com.zhongruan.model.User;

import java.sql.SQLException;
import java.util.List;
import java.util.Scanner;

public class View {
public static void main(String[] args) throws LoginException, SQLException, ClassNotFoundException {
boolean flag=true;
while (flag){
Scanner input=new Scanner(System.in);
System.out.println("-----------您尚未登入,请先登入--------");
System.out.println("-----------请输入用户名:--------------");
String username=input.next();
System.out.println("------------请输入密码:---------------");
String password=input.next();
//1.用户名没有 提示注册
//2.密码错误
//3.登入成功
//通过用户名来数据库查询,如果有数据 看密码是否一样
UserDao userDao=new UserDao();
User user = userDao.findUserByUsername(username);
if (user==null){
System.out.println("------该用户尚未注册,请先注册------");
System.out.println("-------请输入注册名:---------------");
String name=input.next();
System.out.println("-------请输入注册密码:-------");
String pw=input.next();
userDao.charu(name,pw);

        }else if(user.getPassword().equals(password)){
            System.out.println("----欢迎来到音乐管理系统--------");
            musicSystem(user);
            flag=false;
        }else {
            //  System.out.println("------密码错误,请重新输入--------");
            throw new LoginException("登入失败");
        }
    }

}

public static void musicSystem(User user) throws SQLException, ClassNotFoundException {
    Scanner input =new Scanner(System.in);
    System.out.println("1.音乐查询 2.音乐添加 3.音乐修改 4.音乐删除 5.退出");
    int choice=input.nextInt();
    MusicDao musicDao=new MusicDao();
    switch (choice){
        case 1:
            //1.音乐查询
            List<Music> musics = musicDao.findMusics();
            System.out.println(musics);
            break;
        case 2:
            if (user.getType()!=0){
                System.out.println("权限不足,请联系管理员");
                break;
            }
            System.out.println("请输入要插入的音乐名:");
            String ym=input.next();
            System.out.println(&#
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值