You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Kris Barnhoorn <kr...@biassweb.be> on 2005/01/19 14:17:35 UTC

connection parameters

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.




Re: connection parameters

Posted by Brice Ruth <bd...@gmail.com>.
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 <kr...@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 <kr...@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.
> >
> >
> 
>

Re: connection parameters

Posted by Brice Ruth <bd...@gmail.com>.
I would say that those should just end up in your connection URL, the
way the driver expects them

Brice


On Wed, 19 Jan 2005 20:01:43 +0100, Kris Barnhoorn <kr...@biassweb.be> wrote:
> I 'm following for the javabean setters.
> But what about the addConnectionProperty method?
> 
> Greets,
> Kris.
> 
> -----Oorspronkelijk bericht-----
> Van: Clinton Begin [mailto:clinton.begin@gmail.com]
> Verzonden: woensdag 19 januari 2005 17:44
> Aan: ibatis-user-java@incubator.apache.org
> CC: Larry Meadors
> Onderwerp: Re: connection parameters
> 
> Sorry this is more undocumented-ness.  :-)
> 
> BasicDataSource is a JavaBean and when configuring DBCP you can supply
> any of the JavaBean properties in the config file (i.e. ignore all the
> JDBC. and Pool. params, although they still work for backward
> compat.).
> 
> Clinton
> 
> On Wed, 19 Jan 2005 15:48:55 +0100, Kris Barnhoorn <kr...@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 <kr...@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.
> > >
> > >
> >
> >
> 
>

RE: connection parameters

Posted by Kris Barnhoorn <kr...@biassweb.be>.
I 'm following for the javabean setters.
But what about the addConnectionProperty method?


Greets,
Kris.

-----Oorspronkelijk bericht-----
Van: Clinton Begin [mailto:clinton.begin@gmail.com] 
Verzonden: woensdag 19 januari 2005 17:44
Aan: ibatis-user-java@incubator.apache.org
CC: Larry Meadors
Onderwerp: Re: connection parameters

Sorry this is more undocumented-ness.  :-)

BasicDataSource is a JavaBean and when configuring DBCP you can supply
any of the JavaBean properties in the config file (i.e. ignore all the
JDBC. and Pool. params, although they still work for backward
compat.).

Clinton


On Wed, 19 Jan 2005 15:48:55 +0100, Kris Barnhoorn <kr...@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 <kr...@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.
> >
> >
> 
>


Re: connection parameters

Posted by Clinton Begin <cl...@gmail.com>.
Sorry this is more undocumented-ness.  :-)

BasicDataSource is a JavaBean and when configuring DBCP you can supply
any of the JavaBean properties in the config file (i.e. ignore all the
JDBC. and Pool. params, although they still work for backward
compat.).

Clinton


On Wed, 19 Jan 2005 15:48:55 +0100, Kris Barnhoorn <kr...@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 <kr...@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.
> >
> >
> 
>

RE: connection parameters

Posted by Kris Barnhoorn <kr...@biassweb.be>.
:)

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 <kr...@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.
> 
>


Re: connection parameters

Posted by Larry Meadors <la...@gmail.com>.
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 <kr...@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.
> 
>