昨天一个网友给我留言问我一个异常处理问题,我认为这种常见的异常应该和大家分享下,希望大家也能都知道:
java.sql.SQLException: Duplicate entry '鍔炰簨' for key 2
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1125)
com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:677)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1357)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1274)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1259)
这种异常一看就晓得是SQL异常,再分析就明白是你向数据库插入两次同一数据,而数据库要求不能插入重复数据。
还有像下面这种异常也同样是向mysql数据库插入了两次同样的数据,解决办法是你修改一下truename, sex,phone 就好了。还有一个方法,你把你htm.xml文件中的字段属性改为unique="false"
Hibernate: insert into t_user (truename, sex, phone, room_id) values (?, ?, ?, ?)
12:49:57,703 [main] WARN JDBCExceptionReporter : SQL Error: 1062, SQLState: 23000
12:49:57,703 [main] ERROR JDBCExceptionReporter : Duplicate entry '灏忛粦' for key 2
如果你还有问题,更多交流、更多了解QQ:444084929 (回钦波 个人主页:http://www.yezhong.net)
分享到:
相关推荐
java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK ……
NULL 博文链接:https://listen-raining.iteye.com/blog/1962065
NULL 博文链接:https://zhang-zling.iteye.com/blog/980488
帮助初学者理解spring框架,有助于提高代码能力java.sql.SQLException: Duplicate entry '2' for key 'PRIMARY' Query: insert into transaction values(?,?,?,?,?) Parameters: [2, 6212999999999, 转出, 6000000, ...
服务器出现java.sql.SQLException No suitable driver found for 的
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
问题是这样的…我在VS2008直接运行打开网页,可以连接... 异常详细信息: System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库 “TakeClass”。登录失败。 用户 ‘2D2727E2578F446\ASPNET’ 登录失败。
本文主要介绍了关于MySQL存储表情报错:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\xA9\x0D\x0A…’的相关解决方法,分享出供大家参考学习,下面话不多说了,来一起看看详细的介绍: ...
在oracle里面运行一下,解决Exception java.sql.SQLException ORA-00600 内部错误代码
oracle 10g 数据库驱动下载:oracle jdbc dirver
mysql5.6连接驱动jaf,可处理报错java.sql.SQLException: No suitable driver
主要给大家介绍了关于MySQL存储表情时报错:java.sql.SQLException: Incorrect string value: 'xF0x9Fx92xA9x0Dx0A...'的解决方法,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
Q: I am working with ... I am using updateBinaryStream method of resultset to update the BLOB field but it is failing after giving following exception java.sql.SQLException: Internal Error: Unable to
异常详细信息: System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。该用户与可信 SQL Server 连接无关联。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中...
java.sql.SQLException: Operation not allowed after ResultSet closed java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in
异常错误:java.sql.SQLException: The server time zone value ‘?й???’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTime...
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 提示的是用户访问被拒绝,原因是密码不正确,但是我们明明配置的是正确的密码,原因就在yml中: spring: datasource: ...
这种错误通常是由于开发者在编写 SQL 语句时,忘记了某个表名或视图名,导致 Oracle 无法找到该表名或视图名。解决这个错误的方法是,检查 SQL 语句中的表名或视图名是否正确,确保表名或视图名存在于数据库中。 ...
绝对好用的9i驱动包+10g驱动包 解决java.sql.SQLException: 不支持的特性 解决oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z异常 等等