- 论坛徽章:
- 0
|
以下配置都是在实际应用中遇到的一点小问题
用的是
mysql-connector-java-3.1.6-bin.jar
出现的问题在下面的注释中有简约描述
2.x 的配置
- <resource-ref>;
- <res-ref-name>;jdbc/xxxxxx</res-ref-name>;
- <res-type>;javax.sql.DataSource</res-type>;
- <res-auth>;Container</res-auth>;
- <!--<init-param driver-name="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"/>;-->;
- <!-- nnd 要用 com.mysql.jdbc.Driver 驱动才正常,而且 characterEncoding 要 gb18030 才行 -->;
- <init-param>;
- <param-name>;driver-name</param-name>;
- <param-value>;com.mysql.jdbc.Driver</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;url</param-name>;
- <param-value>;jdbc:mysql://localhost:3306/xxxxxxx</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;user</param-name>;
- <param-value>;xxxx</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;password</param-name>;
- <param-value>;xxxx</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;max-connections</param-name>;
- <param-value>;200</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;max-idle-time</param-name>;
- <param-value>;30</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;useUnicode</param-name>;
- <param-value>;true</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;characterEncoding</param-name>;
- <param-value>;gb18030</param-value>;
- </init-param>;
- </resource-ref>;
复制代码
Resin 3.x 配置
- <database>;
- <jndi-name>;jdbc/picring</jndi-name>;
- <!--<init-param driver-name="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"/>;-->;
- <!-- nnd 要用 com.mysql.jdbc.Driver 驱动才正常靠,而且 characterEncoding 要 gb18030 才行 -->;
- <driver>;
- <type>;com.mysql.jdbc.Driver</type>;
- <url>;jdbc:mysql://192.168.0.119:3306/xxxxx</url>;
- <user>;xxxxxx</user>;
- <password>;xxxxx</password>;
- <init-param>;
- <param-name>;useUnicode</param-name>;
- <param-value>;true</param-value>;
- </init-param>;
- <init-param>;
- <param-name>;characterEncoding</param-name>;
- <param-value>;gb18030</param-value>;
- </init-param>;
- </driver>;
- </database>;
复制代码
值得注意的是 以上的配置,在 mysql 4.1.x 以及 5.x 版本下, text 字段都会出现乱码,修改 数据库字段编码以及数据库配置文件无效。
解决方法是 new String(resultSet.getBytes("field" , "gb18030" ;
这个方法也可以用在 mysql 4.0.x 上。 |
|