select 时,总报这个错,是啥原因?? 在线等待中..... 你把pwd username的引号都去掉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 faintselect语句你都是错的 那些引号都是系统自动生成的,只是为了显示而用的.具体代码如下: public String ejbFindByPrimaryKey(String pwdKey) throws ObjectNotFoundException { Connection connection = null; PreparedStatement statement = null; try { connection = dataSource.getConnection(); statement = connection.prepareStatement("SELECT \"username\" FROM \"pwd\" WHERE \"username\" = ?"); statement.setString(1, pwdKey); ResultSet resultSet = statement.executeQuery(); if (!resultSet.next()) { throw new ObjectNotFoundException("Primary key does not exist"); } return pwdKey; } catch(SQLException e) { throw new EJBException("Error executing SQL SELECT \"username\" FROM \"pwd\" WHERE \"username\" = ?: " + e.toString()); } finally { closeConnection(connection, statement); } }我试着改过了,去掉引号,也还是报错,怎么办? SELECT \"username\" FROM \"pwd\" WHERE \"username\" = ?username是否是字段名称还是变量?若是字段名称就没有必要加上\",若是变量你的语句就是错误的。同样对于后面的pwd也一样。将去掉\"后报错信息贴出来看看 Java调用AppleScript BigDecimal 四舍五入的问题 一个简单的面试题目,很遗憾今天没做出。现在不知其解 如何更新JList里面的数据? runtime与外部应用程序交互的问题 一个非常可笑的运行错误.简直就是奇异. 帮简单介绍下Linux和unix 怪事!Socket编程重新定义对象名,居然可以通过! 请教各位! jsp中怎么发自动邮件那? java和j2ee的区别? 密码设置问题 请问java里面tcp/ip编程一般包括那些技术?
select语句你都是错的
public String ejbFindByPrimaryKey(String pwdKey) throws ObjectNotFoundException {
Connection connection = null;
PreparedStatement statement = null;
try {
connection = dataSource.getConnection();
statement = connection.prepareStatement("SELECT \"username\" FROM \"pwd\" WHERE \"username\" = ?");
statement.setString(1, pwdKey);
ResultSet resultSet = statement.executeQuery();
if (!resultSet.next()) {
throw new ObjectNotFoundException("Primary key does not exist");
}
return pwdKey;
}
catch(SQLException e) {
throw new EJBException("Error executing SQL SELECT \"username\" FROM \"pwd\" WHERE \"username\" = ?: " + e.toString());
}
finally {
closeConnection(connection, statement);
}
}我试着改过了,去掉引号,也还是报错,怎么办?
username是否是字段名称还是变量?若是字段名称就没有必要加上\",若是变量你的语句就是错误的。同样对于后面的pwd也一样。
将去掉\"后报错信息贴出来看看