日期:2014-05-20 浏览次数:20847 次
select * from agent where ADRESS LIKE '%?%' 'q';
Object[] s = {'q'};
rs = db.executeQuery("select * from agent where ADRESS LIKE '%?%' ",s );
public ResultSet executeQuery(String sql, Object[] params)
{
getConnection(); //创建连接
try
{
pst = con.prepareStatement(sql);
// 传递参数
if (params != null)
{
if (params.length > 0)
{
for (int i = 0; i < params.length; i++)
{
pst.setObject(i + 1, params[i]);
}
}
}
// 执行
rs = pst.executeQuery();
return rs;
} catch (SQLException e)
{
System.out.println("SQL语句有问题!");
e.printStackTrace();
return null;
}
}