“未找到列”错误?
我需要有关以下错误的帮助。下面是方法retrievePassword()。我对其进行了编程,以便当调用 Clickid 时,我也可以检索所有其他数据。
public boolean retrievePassword() {
// declare local variables
boolean success = false;
ResultSet rs = null;
DBController db = new DBController();
// step 1 of using DBController, passing data source name setup during last practical
db.setUp("myDatabase");
// declare the SQL
String dbQuery = "SELECT Clickid FROM PROFILE WHERE Clickid = '" + clickId + "'" ;
// step 2 of using DBCcontroller, for retrieve SQL use readRequest method
rs = db.readRequest(dbQuery);
try{
if (rs.next()){
firstName = rs.getString("Firstname");
lastName = rs.getString("LastName");
password = rs.getString("Password");
email = rs.getString("Email");
success = true;
}
}
catch (Exception e) {
e.printStackTrace();
}
db.terminate();
return success;
}
我已经检查过,所有列名称都是正确的。我认为问题在于上述方法或下面的实例化
String first = jTextFieldFirst.getText();
String email = jTextFieldEmail.getText();
Profile p2 = new Profile(jTextFieldId.getText());
p2.retrievePassword();
String firstName = p2.getFirstName();
String email2 = p2.getEmail();
if(email == email2 && first == firstName)
JOptionPane.showMessageDialog(null, "Your Password is "+p2.getPassword(),
"Retrieve Password",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null, "Some information you entered is incorrect", "Retrieve Password",JOptionPane.INFORMATION_MESSAGE);
当我编译并在相应字段中键入时,不断出现错误“未找到列”。我已确保列名称和数据正确,但我还有更多列未包含在retrievePassword() 方法中。我确信这两种方法中的任何一种似乎都是问题所在,但无论我怎么做,我似乎都无法解决它。有好心人会帮助我吗?请?
I need help with the below error. Below is the method, retrievePassword(). I programmed it so that when the Clickid is called, I can retrieve all other datas too.
public boolean retrievePassword() {
// declare local variables
boolean success = false;
ResultSet rs = null;
DBController db = new DBController();
// step 1 of using DBController, passing data source name setup during last practical
db.setUp("myDatabase");
// declare the SQL
String dbQuery = "SELECT Clickid FROM PROFILE WHERE Clickid = '" + clickId + "'" ;
// step 2 of using DBCcontroller, for retrieve SQL use readRequest method
rs = db.readRequest(dbQuery);
try{
if (rs.next()){
firstName = rs.getString("Firstname");
lastName = rs.getString("LastName");
password = rs.getString("Password");
email = rs.getString("Email");
success = true;
}
}
catch (Exception e) {
e.printStackTrace();
}
db.terminate();
return success;
}
I have checked and all the column names are correct. I think the problem lies with either the above method or the instantiation below
String first = jTextFieldFirst.getText();
String email = jTextFieldEmail.getText();
Profile p2 = new Profile(jTextFieldId.getText());
p2.retrievePassword();
String firstName = p2.getFirstName();
String email2 = p2.getEmail();
if(email == email2 && first == firstName)
JOptionPane.showMessageDialog(null, "Your Password is "+p2.getPassword(),
"Retrieve Password",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null, "Some information you entered is incorrect", "Retrieve Password",JOptionPane.INFORMATION_MESSAGE);
When I compiled and typed in the respective fields, the error "Column not found" keeps appearing. I have ensured that the column names and data are correct but I have more columns that I didnt include in the retrievePassword() method. I am sure it is either of this 2 methods that seems to be the problem but I cant seems to solve it no matter how I do it. Will some kind soul help me? Please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看起来您的查询仅选择 ClickId 字段,但在结果中您尝试获取其他字段。请改用 SELECT * 或 SELECT 与您需要的字段。
Looks like your query only selects the ClickId field but then in your result you're trying to obtain other fields. Use SELECT * or SELECT with the fields you need instead.
您仅选择 clickid 列。
尝试
从个人资料中选择 *
或者更好地使用列列表。
you select only the clickid column.
try
select * from profile
or better use a column list.
没错,如果您要从结果集中使用名字、姓氏、电子邮件和密码,则需要在选择查询中检索它们。
That's correct, you need to retrieve FirstName, LastName, Email, and Password in your select query if you're going to be using them from the result set.
大家好,我按照你们说的做了,把所有的栏目都选了,成功了。但是当我实现下面的方法时,
它会不断显示 else 循环中的 jOptionPane 。我实际上需要的是当我在正确的字段中输入时得到 if 循环 =(。感谢您的所有帮助 =)
Hey all, I did what you all said and selected all the columns and it was a success. But when I implement the method below
It keeps showing the jOptionPane from the else loop. What i need is actually to get the if loop out when I typed in the correct field =(. Thanks for all of your help =)