文章分类 -  database

浅谈unique列上插入重复值的MySQL解决方案
摘要:本文将介绍在MySQL中unique列上插入重复值的解决方案,希望对广大数据库开发人员有所帮助。本文的unique列上插入重复值解决方案,主要基于MySQL平台。通过这些,可以做到一些新的功能和应用。希望本文能对大家有所帮助。当unique列在一个UNIQUE键上插入包含重复值的记录时,我们可以控制MySQL如何处理这种情况:使用IGNORE关键字或者ON DUPLICATE KEY UPDATE子句跳过INSERT、中断操作或者更新旧记录为新值。mysql>createtablemenus(idtinyint(4)notnullauto_increment, ->labelvar 阅读全文

posted @ 2014-01-16 12:48 优雅的码农 阅读(465) 评论(0) 推荐(0)

mysql数据库连接超时
摘要:项目最近老是在重启8小时候过后查询出错。check log,发现是mysql数据库默认wait_time时间是8小时。8小时候过后,datasource-pool中的所有连接被mysql-server端释放掉。客户端并不知道,程序直接从datasource-pool中获取连接,并没有检测连接有效性,使用的时候就出错了。 于是就趁此机会,花了两天时间仔细学习了mysql的相关设置和dbcp和c3p0。 由于要测试,肯定不能用mysql默认的8小时来测试了。等的头发都白了,还不能重现。果断重设wait_time时间。mysql 上有段原话 The number of seconds the ... 阅读全文

posted @ 2014-01-13 13:41 优雅的码农 阅读(1334) 评论(0) 推荐(0)

Does Connection.close() result in commit or rollback ?
摘要:Earlier today I saw a transaction question targeted for a completely different audience pop up as the first headline news item on a well known java news site. Besides giving me and my colleagues a good laugh about bugs and transactions it also touched upon one of the questions that have given me a c 阅读全文

posted @ 2013-11-24 20:31 优雅的码农 阅读(639) 评论(0) 推荐(0)

When should we call connection.rollback() method?
摘要:Please let me know when do we require to call the method connection.rollback();try{ connection = getConnection(); connection.setAutoCommit(false); pstmt1 = connection.preparedstatement (...);... pstt1.executeUpdate(); pstmt2 = connection.preparedstatement (...);... pstt2.executeUpdate(); conn... 阅读全文

posted @ 2013-11-24 20:19 优雅的码农 阅读(173) 评论(0) 推荐(0)

导航