我有一个名为DatabaseInterface的类,我在那里创建了我的表,其中get Customer作为一种方法,如下所示:
public static Customer getCustomer(long id) {
System.out.println("Get customer " + id);
Customer customer = new Customer();
try {
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * FROM customer where id = " + id);
if (resultSet.next())
{
long cId = resultSet.getLong("id");
String name = resultSet.getString("name");
long tagNo = resultSet.getLong("tagNo");
String email = resultSet.getString("EMAIL");
String telephoneNo = resultSet.getString("telephoneNo");
int noOfTimesRecycled = resultSet.getInt("No of Times Recycled");
customer = buildCustomer(cId, name, tagNo, telephoneNo, email, noOfTimesRecycled);
System.out.println(customer);
}
} catch (SQLException ex) {
System.out.println("Error in getting customer");
ex.printStackTrace();
}
return customer;
}
我有一个文本文件,它读取tagNo的值,每次有一个标签的新条目时,它会增加noOfTimesRecycled的值。 我在一个名为UpdateTag的新类中这样做。所以我首先从DatabaseInterface类调用了方法getCustomer,然后继续更新,但是收到错误。
package com.qmul.rfid.service;
import java.util.List;
import com.qmul.rfid.dataaccess.DatabaseInterface;
//import com.qmul.rfid.dom.Customer;
import com.qmul.rfid.reader.ImportTagJob;
public class UpdateTag {
List<String> fileList = ImportTagJob.fetchData();
{
try{
for (String tag : fileList)
{
DatabaseInterface.getCustomer(long id); //Getting error on long id -Syntax error on token "long", delete this token
System.out.println(tag);
}
}
catch (IllegalArgumentException ex)
{
ex.printStackTrace();
}
}
}
知道为什么吗?