オンラインビデオストアをシミュレートするアプリケーションを作成しようとしています。私はWorkbenchでデータベースを作成しました。ユーザーの入力がデータベースの電子メールとパスワードのものと一致するかどうかを調べるif文を作成しようとしています。しかし、私は接続またはドライバについてのエラーを取得します。誰かが私を助けてくれることを願って、ありがとう!スレッドで 例外 "メイン" にjava.lang.ClassNotFoundException:com.mysqlJavaデータベースとSQLデータベース
はここにここに私のSQLスクリプトここ
create database users;
use users;
create Table Accounts(
UserEamil Char(20) NOT NULL ,
UserPassword Char(20) NOT NULL
);
私の誤差があるであるJavaコード
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
Class.forName("com.mysql.jdbc.Driver");
Scanner input = new Scanner(System.in);
String answer = "";
String sql = "";
String email = "";
String password = "";
Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=convertToNull [root on Default schema]", "<username>", "<password>");
Statement myStmt = myConn.prepareStatement(sql);
ResultSet rs;
while(!answer.equals("n") || !answer.equals("y"))
{
System.out.print("Do you have an account? (Y/N) : ");
answer = input.nextLine();
if(answer.toLowerCase().equals("n"))
{
System.out.println("Please enter the email and password for your new account.");
System.out.print("Email: ");
email = input.nextLine();
System.out.print("Password: ");
password = input.nextLine();
sql = "insert into accounts "
+ " (UserEmail, UserPassword)" + " values (?, ?)";
myStmt.executeUpdate(sql);
}
else if(answer.toLowerCase().equals("y"))
{
System.out.print("\nEmail: ");
email = input.nextLine();
System.out.print("\nPassword:");
password = input.nextLine();
rs = myStmt.executeQuery(sql);
if(!rs.absolute(1))
{
System.out.println("You do not have an account. Please create one.");
continue;
}
}
else{
System.out.println("Invalid input. Please try again.");
continue;
}
}
です。 jdbc.Driver
も投稿してください。 –
私はそれを追加しました。 スレッド "main"の例外java.sql.SQLException:jdbc:mysql:// localhost:3306/mysql?zeroDateTimeBehavior = convertToNullの適切なドライバが見つかりません[ root on default schema] – pca03