lishunli / nutz

Automatically exported from code.google.com/p/nutz
0 stars 0 forks source link

mysql查詢,在window下正常,可是在linux下會找不到 #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. 
同樣的mysql資料架在window下可以查詢到,可是在linux下會找不�
��
2.
3.

What is the expected output? What do you see instead?
基礎的Nutz.Dao程式碼
Category cat = fetch(Category.class, Cnd.where("name", "=", categoryName));

查詢的時候,打印所有的log,如果mysql是安裝在window之下,可
以正常查到資料,如下
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]- Get
'CategoryDAO'<interface com.sanfong.crm.dao.ICategoryDAO> 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Load definition 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Make... 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.ScopeContext:?]- Save object
'CategoryDAO' to [app]  
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]- Get 'dataSource'<null> 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Load definition 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Make... 
12/10 14:40:09 DEBUG [org.nutz.ioc.impl.ScopeContext:?]- Save object
'dataSource' to [app]  
12/10 14:40:10 DEBUG [org.nutz.dao.entity.impl.DefaultEntityMaker:?]- Parse
POJO <com.sanfong.crm.bean.Category> for DB[MYSQL] 
12/10 14:40:10 DEBUG [org.nutz.dao.impl.NutDao:?]- SELECT * FROM CATEGORY 
WHERE name='臺南' LIMIT 0, 1 
臺南

但是,如果mysql是安裝在linux之下,會拋出NullPointerException 
查不到
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]- Get
'CategoryDAO'<interface com.sanfong.crm.dao.ICategoryDAO> 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Load definition 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Make... 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.ScopeContext:?]- Save object
'CategoryDAO' to [app]  
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]- Get 'dataSource'<null> 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Load definition 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.NutIoc:?]-   >> Make... 
12/10 14:41:40 DEBUG [org.nutz.ioc.impl.ScopeContext:?]- Save object
'dataSource' to [app]  
12/10 14:41:40 DEBUG [org.nutz.dao.entity.impl.DefaultEntityMaker:?]- Parse
POJO <com.sanfong.crm.bean.Category> for DB[MYSQL] 
12/10 14:41:40 DEBUG [org.nutz.dao.impl.NutDao:?]- SELECT * FROM CATEGORY 
WHERE name='臺南' LIMIT 0, 1 
Exception in thread "main" java.lang.NullPointerException
    at com.sanfong.crm.dao.CategoryDAO.main(CategoryDAO.java:110)

想請問版主或者有哪位先進曾經遇過這樣的問題,謝謝

What version of the product are you using? On what operating system?
1.a.23
Window XP SP3
JRE 1.6.0_12

Please provide any additional information below.

Original issue reported on code.google.com by wsc0...@gmail.com on 10 Dec 2009 at 7:27

GoogleCodeExporter commented 9 years ago
補充,window下的mysql版本是 MySQL 5.0.37-community-nt
linux CentOS 5.2的mysql版本是 MySQL 5.0.45

Original comment by wsc0...@gmail.com on 10 Dec 2009 at 7:32

GoogleCodeExporter commented 9 years ago
我以前在 Windows 上碰到过这个问题。 好像是 Mysql 
的字符集问题。

你写个 Main 函数,直接用 JDBC 执行 SELECT * FROM CATEGORY WHERE 
name='臺南' LIMIT 0, 1
看看会有什么结果。如果依然查询不到结果,则就是 Mysql 
字符集的问题了。

Original comment by zozoh...@gmail.com on 11 Dec 2009 at 8:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
真的很不好意思,我豬頭,終於發現問題了
當初是用Spring設定applicationContext.xml複製url過來,所以,url長�
��如下:
jdbc:mysql://localhost:3306/myTest?useUnicode=true&characterEncoding=utf-8
可是,使用Nutz的時候,因為是用js檔案,沒有encode的問題,��
�以url長相如下:
jdbc:mysql://localhost:3306/myTest?useUnicode=true&characterEncoding=utf-8
就差在&不需要encode低,浪費大家的時間,真是不好意思~

Original comment by wsc0...@gmail.com on 15 Dec 2009 at 1:53

GoogleCodeExporter commented 9 years ago

Original comment by zozoh...@gmail.com on 15 Dec 2009 at 4:51

GoogleCodeExporter commented 9 years ago
確認

Original comment by wsc0...@gmail.com on 16 Mar 2010 at 12:46

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 13 May 2010 at 10:54

GoogleCodeExporter commented 9 years ago
Verified in 1.a.28

Original comment by wendal1985@gmail.com on 15 May 2010 at 8:29

GoogleCodeExporter commented 9 years ago
Verified

Original comment by wsc0...@gmail.com on 15 May 2010 at 9:17