相关文章
更多最近更新
更多com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
2019-03-25 13:45|来源: 网路
WEB系统报以下的错,是为什么?
Caused by: java.sql.BatchUpdateException: Duplicate entry '3592030993-2011-11-23 19:22:45' for key 'PRIMARY'
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:157)
at com.longshine.indigo.dbutils.manager.WrapperStatement.executeBatch(Unknown Source)
... 47 more
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '3592030993-2011-11-23 19:22:45' for key 'PRIMARY'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1036)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976)
... 50 more
问题补充:
数据库中的数据是空的,网上也找了资料说是字符集的问题,也试了,都不行
Caused by: java.sql.BatchUpdateException: Duplicate entry '3592030993-2011-11-23 19:22:45' for key 'PRIMARY'
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:157)
at com.longshine.indigo.dbutils.manager.WrapperStatement.executeBatch(Unknown Source)
... 47 more
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '3592030993-2011-11-23 19:22:45' for key 'PRIMARY'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1036)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976)
... 50 more
问题补充:
asyty 写道
重复插入数据了吧, '3592030993-2011-11-23 19:22:45' for key 'PRIMARY',主键重复了
数据库中的数据是空的,网上也找了资料说是字符集的问题,也试了,都不行
相关问答
更多-
MySQLSyntaxErrorException异常,这说明你的sql语句写错了,“select * form user”的“form”单词拼写错误,应该是“from”。 拓展资料: 使用jdbc出现的易出现的异常和原因总结 1. ClassNotFoundException: No Suitable Driver Found 原因:没有导入第三方jar包。 2. invalid username/password 无效的用户名/密码。 3. IO 错误: The Network Adapter coul ...
-
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class TestMysqlConnection { public static void main(String[] args) { Co ...
-
你用的什么orm框架?异常是说连接建立失败,mysql服务器启动没?再仔细检查下配置文件或者连接字符串,jdbc类有没有加载错?用户名密码什么的也检查下。
-
有什么数据库专业书籍介绍?[2022-05-19]
mysql -
除其他外,准备语句的要点是不要自己连接查询。 您想要执行以下操作: //first you "prepare" your statement (where the '?' acts as a kind of placeholder) PreparedStatement st = con.prepareStatement("insert into user (user,age,school,password) values (?,?,?,?);"); //now you bind the data to yo ...
-
似乎问题是因为我没有在数据库中提到DEPT_ID。 它已被修复。 It seems the problem was because I did not mention the DEPT_ID in database. It's been fixed.
-
您的问题在于: - ResultSet rs = pstmt.executeQuery(SQL_TEXT); 将其更改为: - ResultSet rs = pstmt.executeQuery(); Your problem is in :- ResultSet rs = pstmt.executeQuery(SQL_TEXT); Change it to :- ResultSet rs = pstmt.executeQuery();
-
看起来你正在大量泄漏连接。 你完成它们后,你正在关闭你的休眠会话吗? 您也可以尝试使用hibernate.connection.release_mode ,默认情况下,将其设置为auto,并在关闭会话时释放连接。 但是,你也可以选择使用after_transaction或after_statement (当它释放两者中的每一个的连接时,它都是相当自我解释的:P)。 尽管如此,你确实需要找出泄漏的地方:) It looks like you are leaking connections big time. ...
-
默认情况下, Instance Id包含项目ID。 所以不要再次明确添加项目ID。 项目ID: sampleapp 实例ID: sampleapp:instance1 (这是google cloud sql默认创建的方式) 连接字符串: 正确: jdbc:google:mysql://sampleapp:instance1/dbname?user=root&password="+password+"useUnicode=true&characterEncoding=UTF-8"; 没错 jdbc:goog ...
-
我建议删除你当前的Conexion.ins.execute方法的实现,并将其替换为使用PreparedStatement ,你可以摆脱这种难以维护的连接问题,更糟糕的是,容易出现SQL注入 。 这是使用PreparedStatement和vararg参数实现参数的实现示例: public void execute(String query, Object ... params) throws SQLException { //assumes you already have your Connect ...