分类: Database预览模式: 普通 | 列表
09-04
06

关于between and包含一段问题

执行下面的HQL语句,发现3月31日的记录无法查询到,百思不得其解。
引用内容 引用内容
select count(a.click) from Article as a where  (a.sendTime between '2009-03-01' and '2009-03-31') and a.admin=56 and (a.state=1)


后来发现数据库是以03月31日00:00:00为截止点,所以需要修改为:
引用内容 引用内容
select count(a.click) from Article as a where  (a.sendTime between '2009-03-01' and '2009-03-31 23:59:59') and a.admin=56 and (a.state=1)

查看更多...

Tags: between 包含

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 448
09-03
04

远程连接mysql超时的解决办法

远程连接mysql超时的解决办法PHP远程连接MYSQL速度慢,有时远程连接到MYSQL用时4-20秒不等,本地连接MYSQL正常,出现这种问题的主要原因是,默认安装的MYSQL开启了DNS的反向解析,在MY.INI(WINDOWS系统下)或MY.CNF(UNIX或LINUX系统下)文件的[mysqld]下加入skip-name-resolve这一选项就能禁用DNS解析,连接速度会快很多。不过,这样的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。
附录:( How MySQL uses DNS )

引用内容 引用内容
When a new thread connects to mysqld, mysqld will spawn a new thread to handle the request. This thread will first check if the hostname is in the hostname cache. If not the thread will call gethostbyaddr_r() and gethostbyname_r() to resolve the hostname.

If the operating system doesn't support the above thread-safe calls, the thread will lock a mutex and call gethostbyaddr() and gethostbyname() instead. Note that in this case no other thread can resolve other hostnames that is not in the hostname cache until the first thread is ready.

You can disable DNS host lookup by starting mysqld with --skip-name-resolve. In this case you can however only use IP names in the MySQL privilege tables.

查看更多...

Tags: 超时 连接

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 800
09-03
04

解析mysql 8小时空闲后连接超时的问题

       当应用程序和数据库建立连接时,如果超过了8个小时,应用程序句不会去访问数据库,数据库就会出现断掉连接的现象 。这时再次访问就会抛出异常.

一般的解决方法大多是在数据库连接字符串中增加“autoReconnect=true ”选项。但是这只对mysql4以前的版本有效。在最新的mysql中是无效的。其实要解决这个问题也有一个简单的方法,就是修改mysql的启动参数。缺省情况下mysql的timeout时间是28800秒,正好是8小时,增加一个0就可以了。

同理也可以在" my.ini"文件中增加此参数。

mysqld-nt --default-table-type=innodb --interactive_timeout=288000


2.决定从根源入手,设置mysql的wait_timeout为31536000(一年),再来试试。

查看更多...

Tags: MYSQL

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 406
09-03
01

mysql解决自动断开8小时未曾用过的链接

近一段时间,很多部门同事反映在使用mysql的过程出现数据库连接自动断开的问题,我对该问题做了一些实验。
关于mysql自动断开的问题研究结果如下,在mysql中有相关参数设定,当数据库连接空闲一定时间后,服务器就
会断开等待超时的连接:
1、相关参数,红色部分
mysql> show variables like '%timeout%';


+--------------------------+-------+
| Variable_name      | Value  |

查看更多...

Tags: MYSQL

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 321
09-02
12

mysql --- Table crashed修复数据表

解决方法:使用MySQL或phpMyAdmin可以使用修复命令「REPAIR TABLE `YourTableName`」,数据库表`ecs_goods_action`,我就想一定是那個「blog_blogs」table,所以我就在SQL那邊輸入「REPAIR TABLE `ecs_goods_action`」。

提交 REPAIR TABLE `ecs_goods_action`   SQL语句后,数据表恢复正常。

查看更多...

Tags: 修复

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 488
     MySQL 的默认设置下,当一个连接的空闲时间超过8小时后,MySQL 就会断开该连接,而 c3p0 连接池则以为该被断开的连接依然有效。在这种情况下,如果客户端代码向 c3p0 连接池请求连接的话,连接池就会把已经失效的连接返回给客户端,客户端在使用该失效连接的时候即抛出异常。
  解决这个问题的办法有三种:
  1. 增加 MySQL 的 wait_timeout 属性的值。
  修改 /etc/mysql/my.cnf文件,在 [mysqld] 节中设置:
  # Set a connection to wait 8 hours in idle status.
  wait_timeout = 86400
  2. 减少连接池内连接的生存周期,使之小于上一项中所设置的 wait_timeout 的值。
  修改 c3p0 的配置文件,设置:
  # How long to keep unused connections around(in seconds)

查看更多...

Tags: 连接 闲置

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 728