ITeye博客

MafiaDada

MafiaDada · 共 18 篇文章

Linux MySQL主从复制(Replication)配置

MySQL是开源的关系型数据库系统。复制(Replication)是从一台MySQL数据库服务器(主服务器master)复制数据到另一个服务器(从服务器slave)的一个进程。 配置主服务器(master) 1、编辑数据库配置文件my.cnf,一般在/etc/目录下。 #vi /etc/my.cnf 在的下面加入下面代码: log-bin=mysql-bin server-id=1 innodb_flush_log_at_trx_commit=1 sync_binlog=1 binlog-do-db=wordpress binlog_ignore_db=mysql server-id=1中的…

2012-10-23 13:54 · mysql · linux · 评论(0)

Fedora 14: Install Apache log analizer, AWstats.

** Install AWstats** #yum -y install awstats #vi /etc/awstats/awstats.www03.server.world.conf # this file is already locate (replace your server's name) line 122: change if your config for log format in httpd.conf is 'combined' Set here '1' If log-config is 'common' set here '4', but in this case, …

2012-01-13 16:44 · fedora · 评论(0)

Fedora 14 下grails中文乱码问题(解决方法)

MySQL默认字符编码为latin1,因此用Grails写入数据时会导致乱码,修改方式为: /etc/init.d/mysql start (stop) 为启动和停止服务器 /etc/mysql/ 主要配置文件所在位置 my.cnf /var/lib/mysql/ 放置的是数据库表文件夹,这里的mysql相当于windows下mysql的date文件夹 启动mysql后,以root登录mysql $ mysql -u root show variables like 'character%'; #执行编码显示 +--------------------------+-------------…

2011-10-20 18:25 · grails · fedora · mysql · 评论(0)

Register multiple date format for binding properities

Grails可以自动把params里面的参数绑定到domain class。有些时候为了能够绑定自定义的日期格式,例如"yyyy-MM-dd",需要register一个自己的CustomDateEditor。 有时候还有需求要绑定多种格式的日期,例如"yyyy/MM/dd"、"yyyy-MM-dd HH:mm:ss"等等,这时候就需要一个支持多种日期格式的CustomDateEditor,解决方法如下: 新建一个MultipleDateEditor.groovy package com.myapp import java.beans.PropertyEditorSupport; import…

2011-10-12 20:55 · grails · 评论(0)

Grails - binding a customized date format

It has been possible to bind a date directly since long before Grails 1.3. The steps are: (1) Create a class that registers an editor for your date format under grails-app/utils: import org.springframework.beans.PropertyEditorRegistrar import org.springframework.beans.PropertyEditorRegistry import …

2011-09-26 18:26 · grails · 评论(0)

Changing last login date in Grails with Spring Security

在使用grails spring security core plugin时,实现用户登录的时候更新上次登录时间 在Config.groovy添加如下代码: import com.myapp.User grails.plugins.springsecurity.useSecurityEventListener = true grails.plugins.springsecurity.onInteractiveAuthenticationSuccessEvent = { e, appCtx -> User.withTransaction { def user = User.findById(a…

2011-09-06 14:31 · grails · 评论(0)

Grails, spring-security-core plugin:使用email登录

1. Implement the first requirement – Add an email address property to the user domain This is really simple, just add the property to the domain class :) package org.customauth class CustomUser { String username String password String email boolean enabled boolean accountExpired // ******* // the r…

2011-09-06 14:27 · grails · 评论(0)

Run a Java web application within grails

Ever needed to run an existing java web application side by side with your grails project? I found myself in exactly that position this week, and discovered that it (like most things in grails) was rather simple to accomplish. Considering I work in a predominately Java environment, I often need to …

2011-08-27 13:22 · grails · 评论(0)

Fedora 14下subversion开机自动启动配置

在Fedora 14了安装了subversion,不想直接简单的写到启动脚本里启动,于是google到下面的脚本了,毕竟用chkconfig和service命令更方便。 本脚本能让subversion作为一个守护进程启动。 vi /etc/init.d/subversion #!/bin/bash # # /etc/rc.d/init.d/subversion # # Starts the Subversion Daemon # # chkconfig: 2345 90 10 # description: Subversion Daemon # processname: svnserve s…

2011-08-21 18:36 · fedora · subversion · 评论(0)

Apache2使用 .htaccess控制访问权限

这里涉及的配置方式主要是使用 .htaccess 文件, 要使用.htaccess文件,则必须设置服务器以允许在这些文件中使用认证指令,即用AllowOverride指令指定哪些指令在针对单个目录的配置文件中有效。首先将对应的AllowOverride这样设置: AllowOverride All 首先,应该创建一个用于认证的密码文件,并且这个文件不应该置于DocumentRoot目录下,以避免被下载。例如可以创建/etc/apache2/passwd/目录,并将密码文件置于其下。 Apache2 为我们提供了/usr/bin/htpasswd命令用于创建密码文件,命令的具体操作方法请参阅h…

2011-08-17 18:28 · fedora · 评论(0)

Execute SQL Scripts in Grails Bootstrap or Integration Tests

I recently had to execute some SQL scripts when a Grails applications starts up to insert test data into the database. Executing sql scripts is easy. Just open the SQL File and read the contents of the Script to a String variable. String sqlFilePath = 'path/to/your/script.sql' String sqlString = ne…

2011-08-12 15:45 · grails · 评论(0)

Grails, JQuery, and AJAX

By now, you’re probably under the impression that I love Grails, and you wouldn’t be far off from the truth. Ever since I started using it almost a year ago, I’ve continually been amazed by just how darn productive I can be. One of the aspects I want to touch on today is how Grails helps you build …

2011-08-11 15:02 · grails · 评论(0)

Grails - Logging from a Controller or Service

Logging informational messages from a controller or service is the sort of thing I wish I'd figured out how to do when I first started playing around with Grails. All the information is in the docs, but it took me a while to find it and it could be a bit obscure for someone just getting started. He…

2011-08-11 14:55 · grails · 评论(0)

grails taglib修改datePicker格式

grails的datePicker标签很好,但是并不能设置成yyyy-MM-dd的格式,另外,在月份选择列表中,显示的是中文的:一月、二月等等,对于追求简捷的中国人来说,这不符合我们的习惯。怎么办? 在grails英文指南页面中,显示了它的源代码位置在:/grails/src/groovy/org/codehaus/groovy/grails/plugins/web/taglib/FormTagLib.groovy 因此,在www.grails.org把源代码下载下来,按照路径找到这个FormTagLib.groovy文件,把里面关于datePicker的一节复制下来,在自己所做项目的tag…

2011-08-10 17:07 · grails · 评论(0)

Hibernate的锁机制

1.悲观锁 它指的是对数据被外界修改持保守态度。假定任何时刻存取数据时,都可能有另一个客户也正在存取同一笔数据,为了保持数据被操作的一致性,于是对数据采取了数据库层次的锁定状态,依靠数据库提供的锁机制来实现。 基于jdbc实现的数据库加锁如下: select * from account where name="Erica" for update 在更新的过程中,数据库处于加锁状态,任何其他的针对本条数据的操作都将被延迟。本次事务提交后解锁。 而hibernate悲观锁的具体实现如下: String sql="查询语句"; Query query=session.createQuery(sq…

2011-08-10 14:02 · hibernate · 评论(0)