在SQL中如何模糊查询

来源:百度知道 编辑:UC知道 时间:2024/05/02 14:07:17

SQL="Select * From TableName Where TopicName Like '%" & KeyWord &"%'"

/** * 获得LDAP连接(不通过连接池,直接获得连接) * @return * @throws Exception */ private javax.naming.directory.DirContext getDirContext() throws Exception { DirContext ctx = null; java.util.Hashtable env = new java.util.Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, user); env.put(Context.SECURITY_CREDENTIALS, pwd); ctx = new InitialDirContext(env); return ctx; } /** * 返回用户查询接口 * @param DN 查找范围 ou=test,dc=abcd,dc=com * @param filter 过滤条件 cn=* * @param myserach 搜索范围 * @return LDAP标准接口 * @throws Exception */ public javax.naming.NamingEnumeration getFilter(String DN,String filter,int myserach) throws Exception { DirContext ctx = getDirContext(); try { NamingEnumeration em; SearchControls