这是我的问题:当我运行我的代码时,它应该检查是否有两个 boo-leans 条件。一个应该是假的,另一个应该是真的。我还在其中放入了一个 else 代码,并编码了 System-out-print ERROR 以及 boo-leans 值是什么。当我运行它时,它打印出一个是假的,一个是真的,但它没有被 if 语句捕获。这是我的代码:
' if((falseOnce = false)&(tAndCSelected = true)){//these are my two booleans
String url = "jdbc:derby://localhost:1527/Register";//place where database Register is
try{
String sql = "INSERT INTO Register(Username, Password, Email,Title,Prediction,Date_Joined) VALUES (?,?,?,?,?,?)";
String usernme = "nbuser";
String passed ="nbuser";
Connection connection = DriverManager.getConnection(url, usernme,passed);//makes a connector to the database
java.util.Calendar cal = java.util.Calendar.getInstance();//gets date
java.util.Date date = cal.getTime();
java.sql.Date sqldate = new Date(date.getTime());
PreparedStatement action = connection.prepareStatement(sql);
action.setString(1, uname);//in first position, username goes in
action.setString(2,password);
action.setString(3,email.getText());
action.setString(4,null);
action.setString(5,null);
action.setDate(6,sqldate);
action.executeUpdate();//executes the instructions
redirect.setText("Your account has been created. You may now log in");
new Timer(3000,null);//3 seconds before going back to logIn page.
new LogIn().setVisible(true);
setVisible(false);
}catch(SQLException e){
System.out.println("unsuccessful"+e);
}
}
else{
System.out.println("ERROR" + "falseOnce is " + falseOnce + "and tAndCSelected is" + tAndCSelected );
}
'
如果两个布尔条件如我所说,其余代码只是将数据输入数据库。问题是什么?