我正在研究大学项目java MemoryCatcherServant.java,我收到此错误:
方法不会覆盖或实现超类型
中的方法
有人有修复吗?任何帮助肯定会受到赞赏。快速而准确的答案肯定会得到回报:)
@Override
public boolean purchaseMemoryPoints(int memoryPointAmount, int userId) {
String error;
Connection connection;
Statement stmt = null;
Statement stmt2 = null;
int memoryPoints = 0;
try {
connection = DriverManager
.getConnection("jdbc:mysql://localhost/memorycatcher","root", "root");
} catch (SQLException e) {
return false;
}
if (connection != null) {
//make connection
try {
stmt = connection.createStatement();
String sql = "SELECT userMemoryPoints FROM users WHERE userId = \""+userId+"\"";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
memoryPoints = rs.getInt("userMemoryPoints");
}
rs.close();
stmt.close();
int newMemoryPoints = memoryPoints + memoryPointAmount;
stmt2 = connection.createStatement();
String sql2 = "UPDATE users SET userMemoryPoints = newMemoryPoints WHERE userId = \""+userId+"\"";
stmt2.close();
connection.close();
return true;
} catch (SQLException e) {
//error handling
return false;
}
} else {
return false;
}
}
购买memorycatcher的IDL
//user enters the amount of points they want to purchase
boolean purchaseMemoryPoints(in long memoryPointAmount, in long userId);
答案 0 :(得分:0)
尝试删除@Override
注释(第一行)作为开始。
如果您确定该方法确实覆盖了另一种方法,那么您的编译器可能会设置为古老的Java版本(在Java 1.6之前的接口中不允许使用@Override
- 注释。)