java.sql.SQLException: Cannot create错误
程序员文章站
2022-04-30 14:02:23
...
用druid查询mysql里的数据
@Test
public void test2() throws Exception {
User user = new User("liu", "abc");
QueryRunner queryRunner = new QueryRunner(JDBCUtils.getDataSource());
User existUser = queryRunner.query("select * from userlogin where username = ? and password = ?", new BeanHandler<User>(User.class), user.getUsername(), user.getPassword());
// System.out.println(Arrays.toString(existUser));
System.out.println(existUser == null);
}
报错:
java.sql.SQLException: Cannot create com.itheima.domain.User: com.itheima.domain.User Query: select * from userlogin where username = ? and password = ? Parameters: [liu, abc]
需要在User里面添加一个无参数的构造器
运行结果如下:
上一篇: spring(一)
推荐阅读
-
getcwd cannot access parent directories错误解决方法
-
为PHP安装imagick时出现Cannot locate header file MagickWand.h错误的解决方法
-
setcookie中Cannot modify header information-headers already sent by错误的解决方法详解
-
MySQL创建用户错误ERROR 1396 (HY000): Operation CREATE USER failed for 'XXXX'@'XXXX'问题解
-
PHP严重致命错误处理:php Fatal error: Cannot redeclare class or function【转】
-
JavaScript 程序错误Cannot use 'in' operator to search的解决方法
-
react-native 在新版Xcode(10+)中运行出现的问题: node_modules/react-native/third-party/glog-0.3.4 , C compiler cannot create executables
-
SQL Server 2005 RTM 安装错误 :The SQL Server System Configuration Checker cannot be executed due to
-
解决启动MongoDB错误:error while loading shared libraries: libstdc++.so.6:cannot open shared object file:
-
CENTOS7错误:Cannot find a valid baseurl for repo: base/7/x86_6