ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brice Ruth <bdr...@gmail.com>
Subject Re: connection parameters
Date Wed, 19 Jan 2005 16:19:48 GMT
When you say

... "in the page there are replaced with question marks '?'" ...

I assume you mean a JSP that you're displaying your results in? I
would suggest that you set the character-encoding on the JSP to UTF-8
(change any HTML <META> tags appropriately as well). From what I can
tell, you're using MySQL - and if memory serves, the parameters you're
using are telling MySQL that the data is stored as ISO-8859-1 and to
pull the data out as Unicode.

Once iBATIS passes the Unicode data on to your presentation layer
(through Struts or otherwise), then it needs to be presented to the
browser appropriately, which in most cases is UTF-8.

That's what we do here, anyway ... 

Brice


On Wed, 19 Jan 2005 15:48:55 +0100, Kris Barnhoorn <kris@biassweb.be> wrote:
> :)
> 
> With "code works" I meant iBatis doesn't give errors.
> 
> In the database there are special characters like è é ë etc..
> and in the page there are replaced with question marks '?'.
> 
> All my pages have character encoding iso-8859-1 and the database too.
> 
> I had similar problems in the past if I didn't specify the extra
> connection parameters.(useUnicode, characterEncoding)
> 
> In my pre-ibatis code I set it in a initServlet like:
> 
> BasicDataSource ds = new BasicDataSource();
> ds.setDriverClassName(getInitParameter("driverClass"));
> ds.setUrl(getInitParameter("jdbcURL"));
> ds.setUsername(getInitParameter("user"));
> ds.setPassword(getInitParameter("pwd"));
> ds.setMaxActive(Integer.parseInt(getInitParameter("maxActive")));
> ds.setMaxWait(Integer.parseInt(getInitParameter("maxWait")));
> 
> ds.addConnectionProperty("autoReconnect",getInitParameter("autoReconnect
> "));
> ds.addConnectionProperty("useUnicode",getInitParameter("useUnicode"));
> ds.addConnectionProperty("characterEncoding",getInitParameter("character
> Encoding"));
> 
> ds.setDefaultReadOnly(false);
> ds.setDefaultAutoCommit(false);
> ds.setValidationQuery(getInitParameter("validationQuery"));
> 
> greets
> kris.
> 
> -----Oorspronkelijk bericht-----
> Van: Larry Meadors [mailto:larry.meadors@gmail.com]
> Verzonden: woensdag 19 januari 2005 14:19
> Aan: ibatis-user-java@incubator.apache.org
> Onderwerp: Re: connection parameters
> 
> Heheh, well, if it works, then "yes".
> 
> I am not sure I understand the question here.
> 
> Can you clarify it?
> 
> Larry
> 
> On Wed, 19 Jan 2005 14:17:35 +0100, Kris Barnhoorn <kris@biassweb.be>
> wrote:
> > Hi,
> >
> > I was wondering if this is the correct way to add extra parameters to
> > the connection?
> >
> >         <transactionManager type="JDBC">
> >                 <dataSource type="DBCP">
> >                         <property name="JDBC.Driver" value="${driver}"
> > />
> >                         <property name="JDBC.ConnectionURL"
> >
> value="${url}?characterEncoding=iso-8859-1;autoReconnect=true;useUnicode
> > =true" />
> >                         <property name="JDBC.Username"
> > value="${username}" />
> >                         <property name="JDBC.Password"
> > value="${password}" />
> >                         <property name="JDBC.DefaultAutoCommit"
> > value="false" />
> >                         <!-- The following are optional -->
> >                         <property name="Pool.MaximumActiveConnections"
> > value="10" />
> >                         <property name="Pool.MaximumIdleConnections"
> > value="5" />
> >                         <property name="Pool.MaximumWait"
> value="60000"
> > />
> >                         <!-- Use of the validation query can be
> > problematic. If you have difficulty, try without it. -->
> >                         <property name="Pool.ValidationQuery"
> >                                 value="select 1 from users" />
> >                         <property name="Pool.LogAbandoned"
> value="false"
> > />
> >                         <property name="Pool.RemoveAbandoned"
> > value="false" />
> >                         <property name="Pool.RemoveAbandonedTimeout"
> > value="50000" />
> >                 </dataSource>
> >         </transactionManager>
> >
> > Code Works, but I have special characters to question marks issues....
> >
> > Thanks.
> > Kris.
> >
> >
> 
>

Mime
View raw message