com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近有语法错误。求大神指点迷津!

qq_27784145 qq_27784145 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public class WorkDAOImpl  implements WorkDAO {

protected Connection con; //数据库连接
protected PreparedStatement pre; //实例
protected ResultSet res; //结果集

public List<CustomerInfo> getAllList( int addTime ) {

List<CustomerInfo> list = new ArrayList<CustomerInfo>();
con = DBCon.getConnection();
try {
String sql="select a.* , b.condition_name from customer_info a ,customer_condition b " +
"where a.condition_id=b.condition_id and a.is_used='1' ";
if(addTime == 0 ){
sql += " select datediff(day,birth_day,getDate())=0";

} else if(addTime != 0 ){
sql += " select datediff(day,birth_day,getDate())>=0 and datediff(day,birth_day,getDate())<='"+addTime+"' ";

}
pre = con.prepareStatement(sql);
res = pre.executeQuery(); //报错内容中提到这行 也不知道为什么
while (res.next()) {
CustomerInfo customerInfo = new CustomerInfo();

customerInfo.setCustomerId(res.getInt("customer_id"));
customerInfo.setCustomerName(res.getString("customer_name"));
customerInfo.setCustomerBirthday(res.getString("birth_day"));
customerInfo.setCustomerMobile(res.getString("customer_mobile"));
customerInfo.setConditionId(res.getInt("condition_id"));
customerInfo.setCustomerCondition(res.getString("condition_name"));
customerInfo.setIsUsed(res.getString("is_used"));


list.add(customerInfo);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
DBCon.closeAll(con,pre,res);
}
return list;
}
...全文

相关推荐

com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作 解决方案

com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作 解决方案

rmbrmp

解决无法通过SSL加密与SQLServer建立连接

由于项目中必须得用JDK6来作为Java环境,于是连接SQLServer时出现了com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“​ ​Java​​.lang.RuntimeException: Could not generate DH keypair”。这样的错误。

mnimumu

sql server 2005 jdbc驱动配置

:1.因为SQLexpress服务器默认是禁用的并且端口号没有配置,所以要进行重新设置 2.如果你以前用java连接sql server 2000的话就要注意了: 在sql server 2000 中加载驱动和URL路径的语句是 String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=rs"; ……

pisa8

解决SQLSERVER数据库驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接问题JAR包

用于解决SQLSERVER连接问题驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接问题JAR包。

就想叫yoko

Microsoft JDBC Driver 6.0 for SQL Server.rar

抛出异常:“没有为集成身份验证配置驱动程序” 解决办法:      将 文件夹  ...\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\chs\auth\x64(32位系统选择x86文件夹) 路径中的sqljdbc_auth.dll复制到C:\Windows\System32下即可。

qq_39591064
评论 7
收藏 已收藏
分享
返回顶部
qq_27784145
Web 开发 81,108 成员 341,720 内容