相关文章
更多最近更新
更多DbUtil查找数据,查找出来的结果最后一列是null?
2019-03-25 13:33|来源: 网路
package com.webchart.dao;
import java.sql.SQLException;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.webchart.util.IConstants;
import com.webchart.vo.UserVO;
public class UserInfoDao {
static{ DbUtils.loadDriver(IConstants.DRIVER); }
public DataSource getDataSou() throws NamingException, SQLException{
final Context context=new InitialContext();
DataSource ds=(DataSource)context.lookup("java:comp/env/mysql");
return ds;
// ds.getConnection();
}
// 插入用户
public int insertUser(final UserVO uv) throws NamingException,
SQLException {
//DbUtils.loadDriver(IConstants.DRIVER);
final Context context = new InitialContext();
final DataSource ds = getDataSou();
final QueryRunner qr = new QueryRunner(ds);
final String sql = "insert into userinfo values(?,?,?,'"+uv.getPimg()+"')";
String x=uv.getPimg();
final String[] param = { (String) uv.getUname(), (String) uv.getUpwd(),
(String) uv.getTname()};
return qr.update(sql, param);
}
// 查找全部用户
public List<UserVO> selectAll() throws NamingException, SQLException {
//DbUtils.loadDriver(IConstants.DRIVER);
final String sql = "select * from userinfo";
final Context context = new InitialContext();
final DataSource ds = getDataSou();
final QueryRunner qr = new QueryRunner(ds);
final List<UserVO> list = (List) qr.query(sql, new BeanListHandler<UserVO>(UserVO.class));
return list;
}
}
全部查找时出来的结果,最后一列的数据为null
import java.sql.SQLException;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.webchart.util.IConstants;
import com.webchart.vo.UserVO;
public class UserInfoDao {
static{ DbUtils.loadDriver(IConstants.DRIVER); }
public DataSource getDataSou() throws NamingException, SQLException{
final Context context=new InitialContext();
DataSource ds=(DataSource)context.lookup("java:comp/env/mysql");
return ds;
// ds.getConnection();
}
// 插入用户
public int insertUser(final UserVO uv) throws NamingException,
SQLException {
//DbUtils.loadDriver(IConstants.DRIVER);
final Context context = new InitialContext();
final DataSource ds = getDataSou();
final QueryRunner qr = new QueryRunner(ds);
final String sql = "insert into userinfo values(?,?,?,'"+uv.getPimg()+"')";
String x=uv.getPimg();
final String[] param = { (String) uv.getUname(), (String) uv.getUpwd(),
(String) uv.getTname()};
return qr.update(sql, param);
}
// 查找全部用户
public List<UserVO> selectAll() throws NamingException, SQLException {
//DbUtils.loadDriver(IConstants.DRIVER);
final String sql = "select * from userinfo";
final Context context = new InitialContext();
final DataSource ds = getDataSou();
final QueryRunner qr = new QueryRunner(ds);
final List<UserVO> list = (List) qr.query(sql, new BeanListHandler<UserVO>(UserVO.class));
return list;
}
}
全部查找时出来的结果,最后一列的数据为null
相关问答
更多-
linux中如何保存find 查找出来的内容 到一个文档[2023-09-09]
find ./ -name xxx > filename把标准输出重定向到filename中 find ./ -name xxx >> filename把标准输出追加到filename中 -
linux查找文件[2022-02-03]
用下面的命令查找文件make-3.80-5.rpm: find / -name make-3.80-5.rpm -print 如果模糊查找,需要使用单引号,例如: find / -name 'make-3.*.rpm' -print 命令里面的第一个/表示开始搜索的文件夹,如果/文件太多了,可以换为/etc等 -
这个查找结果是对的...只要包含"子"的都会被查找 但至少是两个字符的
-
excel查找一列中包含的多个数值或几个数值[2024-04-12]
=INDEX($A:$A,SMALL(IF(ISNUMBER(FIND(1,$A$1:$A$100))*(ISNUMBER(FIND(2,$A$1:$A$100))*(ISNUMBER(FIND(3,$A$1:$A$100)))*((ISNUMBER(FIND(4,$A$1:$A$100)))*((ISNUMBER(FIND(5,$A$1:$A$100)))))),ROW($A$1:$A$100),4^8),ROW(A1)))&"" 同时按CTRL SHIFT 回车键 变色 选定A列,格式-条件格式-公式 ... -
sql中怎么使用正则表达式来查找符合的条件[2023-05-31]
肯定要用模糊查询: select * from 表名 where phone like '%1111%' % 表示0到多个字符 其他的我就不知道了 -
Zencart常量是什么,怎么定义常量,然后去查找呢,查找出来的又是什么文件格式呢??求详解!![2023-04-14]
如果您是要修改自定义页面的话,请从“工具(tool)”=》“页面编辑(define page)”进去,然后选择就可以找到了哦。 -
很多方法可以做到这一点。 最可靠的是找到。 Dim rLastCell As Range Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False) MsgBox ("The last used column is: ...
-
在数据框中查找除了一列以外的所有列的重复组(Find groups of duplicates in data frame by all columns except one)[2022-01-22]
我们先生成一些数据 df <- as.data.frame(matrix(sample(2, 20, TRUE), 5)) # Produces df like this V1 V2 V3 V4 1 2 1 1 1 2 2 1 2 2 3 1 1 2 2 4 1 2 1 1 5 1 2 1 1 然后我们通过lapply循环lapply 。 然后将每一行与apply (包括它自己)在内的所有df行进行比较。 <= 1差异的行返回TRUE ,其他行返回FALSE生 ... -
大多数控件都有一个Tag属性。您可以将所需的这些控件的所有标签设置为您希望的值,然后在迭代中可以检查标签值。 foreach (Control c in Controls) if (c.Tag == "MyTag") { //Do required actions } 如果这些控件中的任何一个位于容器控件中,您也可以考虑递归函数。 Most controls have a Tag property., You can set all the tags of those controls you r ...
-
vba通过列查找单元格数据,如果没有,则查看下一列(vba Find cell data through columns and if nothing then look at the next column)[2023-03-30]
我认为一个额外的循环,加上一些小的编辑可能就足够了: For b = 7 To 8 For a = 2 To 10 thisvalue = .Cells(a, b).Value If thisvalue Like Month.Value Then ' <-- check the names nfo.Range("A5").Value = .Cells(a, 2).Value nfo.Range("A6").Value = ...