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也一样。将去掉\"后报错信息贴出来看看 如何获取静态方法的返回值? 求解参数传递于引用的问题 Twaver? cannot convert from boolean to String 请教java中定时器的用法 volatile 具体是什么意思? 请教一个JAVA编译的问题 java中怎样计算时间相加?? 跪楼求救,关于SSL问题, 对短消息编程感兴趣吗,请看hnjsbyl.nease.net 密码设置问题 请问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也一样。
将去掉\"后报错信息贴出来看看