import java.sql.*;
public class userRegistration {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/keystone";
static final String USER = "root";
static final String PASS = "cusat123";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
stmt = conn.createStatement();
String sql;
sql = "SELECT name,id,password FROM user";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String first = rs.getString("name");
String last = rs.getString("id");
String pwd = rs.getString("password");
if("siju".equals(first))
{
if("cusatse".equals(pwd))
{
System.out.println("login ok");
}
}
System.out.print(" username: " + first);
System.out.println(", id: " + last);
System.out.println(", password: " + pwd);
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException se){
se.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}
}
System.out.println("Goodbye!");
}
}
出力は
username: siju, id: 0d2809092a1e41c485181b07f8ac62ae , password: $6$rounds=40000$JHmpeyx13IDIJdgJ$zFGji3SJPQ4Dx3pz6BWnIXmkVvpZNmHxMfj8qN2DOQ2K6pR5Vl/UNfjo00HJwNXRgXxEhly6N6Hf6MTaMb1d21 username: glance, id: 47bcfb1392514dc5b890bfb14186663d , password: $6$rounds=40000$yDvqf1kBnvcTldCH$DGKrrqY3mavByeM8xtqF8AaXEFiViapwHLo14WnTIE4z0N.IiCJ96lIxtmqfDKqYp2lxCQkFpff63Wh8.z2du/ username: nova, id : 5504658950fa47239fa476e895111f5a , password: $6$rounds=40000$YQe7qgAKC3UiLBkM$pFd.VCf2U6PeJnx2ejPGkW04tHq63o0fb9RiUjJTztiouH.d7UhqRmwA0aVZb6j/O..XDnhV9U4MLBnbW315Z0 username: admin, id: 6a6bae538bd749bb8f6388ec5f3c2707 , password: $6$rounds=40000$.6.GubHpPpkZrk5J$RtRAI3Xd9.eAWKoQCMtfVf6jNok.n6zCcqFWlV/ 1x0RWjLAxd29/Jm9OjtNUNtK8JqJPjl0.lgyuHc1ZJVYIY0 ユーザー名: スウィフト、ID: bce9ad99e4ad44988203180080ac022a、パスワード:$6$rounds=40000$OWbwnCWLbCEPSwed$.UbZQD4WLnjzM4n2qkSMjqpP8IIXNMtKNQuW3oqNdfvUof1/qYVGtnEcONPphmXBbJMlOZOkQqTnTrFC03UU70 username: demo, id: d059821f33fa498b979b7b1539f00274 , password: $6$rounds=40000$X8MyyrjduXoeHC1F$e6Dc2k4bUz9YnnWY/rx0ECXW95mZhAdV8EDNnY9waLmuAXfVThME7g.V2rirhCt6WkRA4yr1jQlB9D2lTT0iL1 username: sunil, id: e57a4c4bce984cbebf2a4f9babd42983 , password: $6$rounds=40000さようなら!パスワード: $6$rounds=40000$/mrUJI0OIe6TOVWx$z4fOjo4hRk55sI2MbE/rrkqKiPrRvY9WdNMfhsitvmeIHccO8FjeqWS7dM3KUNt0giM1Cx4ayduSQcJxKlFyP/ さようなら!パスワード: $6$rounds=40000$/mrUJI0OIe6TOVWx$z4fOjo4hRk55sI2MbE/rrkqKiPrRvY9WdNMfhsitvmeIHccO8FjeqWS7dM3KUNt0giM1Cx4ayduSQcJxKlFyP/ さようなら!
1.問題は、パスワードの形式が異なることです。
2.正しい文字列形式で Keystone データベースからパスワードにアクセスできますか?