You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@empire-db.apache.org by Rainer Döbele <do...@esteam.de> on 2015/11/01 11:23:28 UTC

re: DBDatabase.open() question

Hi Ivan,

there is always room for improvements ;-)

Please create an issue in Jira and change the code as desired.
Please make sure, that the code is properly tested.

Regards,
Rainer

> -----Ursprüngliche Nachricht-----
> from: ivan.nemeth@gmail.com [mailto:ivan.nemeth@gmail.com]
> to: dev@empire-db.apache.org
> re: Re: DBDatabase.open() question
> 
> Hi Rainer,
> 
> thanks for your answer.
> 
> For the SET DATEFORMAT sql: wouldn't be better to handle it with
> SQL_DATE_TEMPATE and SQL_DATETIME_TEMPLATE like in Oracle driver?
> 
> I mean something like this in DBDatabaseDriverMSSQL.getSqlPhrase():
> 
> case SQL_DATE_TEMPLATE:           return "convert(date, '{0}', 121)";
> case SQL_DATETIME_TEMPLATE:       return "convert(datetime, '{0}', 121)";
> 
> 
> Regards,
> Ivan
> 
> On Sat, Oct 31, 2015 at 9:51 AM, Rainer Döbele <do...@esteam.de>
> wrote:
> 
> > Hi Ivan,
> >
> > I can say for SQL-Server that there is a default schema but this might
> > not necessarily be the database schema you want to work with.
> > Hence you need to select the database using USE [xyz] in order to
> > access the correct database schema.
> > This might not be necessary if the default schema for the connecting
> > user has already been set correctly.
> >
> > Also the date format is set to make sure, that the order of day, month
> > and year corresponds to our internal representation, in case it differs.
> >
> > This needs to be done for every connection unless you can make sure,
> > that the connections already has all required settings.
> > So the best way would be to check your user settings in the database
> > first and check whether when you connect you already access the correct
> db schema.
> > If this is the case, then there is no need to execute the statements.
> >
> > You might derive your own class from your preferred database driver
> > and then use this to skip this or implement your own logic.
> >
> > Regards,
> > Rainer
> >
> > -------------------------------------------------------------------
> > > from: Ivan Nemeth [mailto:ivan.nemeth@gmail.com]
> > > to: dev@empire-db.apache.org
> > > re: DBDatabase.open() question
> > >
> > > Hi guys,
> > >
> > > I have a question about DBDatabase.open() method. It sets the driver
> > > for
> > the db and calls the driver's attachDatabase method which in most
> > cases does nothing . But in case of MSSQL and MySql driver it executes
> > some initialization SQL (*). We use a connection pool and a singleton
> > DBDatabase instance, which is opened only once when the app is
> > initialized. So this initialization script is executed only for the first
> connection.
> > >
> > > So what is the purpose of this initialization SQL? Is it necessary,
> > > and
> > if yes, in case of a connection pool the DBDatabase should be open for
> > every new connection?
> > >
> > > Regards,
> > > Ivan
> > >
> > > * it sets the database to use (USE DATABASE...) and the date format
> >

Re: DBDatabase.open() question

Posted by ivan nemeth <iv...@forumdigital.net>.
Hi Rainer,

I've made the changes.

Regards,
Ivan

On Sun, Nov 1, 2015 at 11:23 AM, Rainer Döbele <do...@esteam.de> wrote:

> Hi Ivan,
>
> there is always room for improvements ;-)
>
> Please create an issue in Jira and change the code as desired.
> Please make sure, that the code is properly tested.
>
> Regards,
> Rainer
>
> > -----Ursprüngliche Nachricht-----
> > from: ivan.nemeth@gmail.com [mailto:ivan.nemeth@gmail.com]
> > to: dev@empire-db.apache.org
> > re: Re: DBDatabase.open() question
> >
> > Hi Rainer,
> >
> > thanks for your answer.
> >
> > For the SET DATEFORMAT sql: wouldn't be better to handle it with
> > SQL_DATE_TEMPATE and SQL_DATETIME_TEMPLATE like in Oracle driver?
> >
> > I mean something like this in DBDatabaseDriverMSSQL.getSqlPhrase():
> >
> > case SQL_DATE_TEMPLATE:           return "convert(date, '{0}', 121)";
> > case SQL_DATETIME_TEMPLATE:       return "convert(datetime, '{0}', 121)";
> >
> >
> > Regards,
> > Ivan
> >
> > On Sat, Oct 31, 2015 at 9:51 AM, Rainer Döbele <do...@esteam.de>
> > wrote:
> >
> > > Hi Ivan,
> > >
> > > I can say for SQL-Server that there is a default schema but this might
> > > not necessarily be the database schema you want to work with.
> > > Hence you need to select the database using USE [xyz] in order to
> > > access the correct database schema.
> > > This might not be necessary if the default schema for the connecting
> > > user has already been set correctly.
> > >
> > > Also the date format is set to make sure, that the order of day, month
> > > and year corresponds to our internal representation, in case it
> differs.
> > >
> > > This needs to be done for every connection unless you can make sure,
> > > that the connections already has all required settings.
> > > So the best way would be to check your user settings in the database
> > > first and check whether when you connect you already access the correct
> > db schema.
> > > If this is the case, then there is no need to execute the statements.
> > >
> > > You might derive your own class from your preferred database driver
> > > and then use this to skip this or implement your own logic.
> > >
> > > Regards,
> > > Rainer
> > >
> > > -------------------------------------------------------------------
> > > > from: Ivan Nemeth [mailto:ivan.nemeth@gmail.com]
> > > > to: dev@empire-db.apache.org
> > > > re: DBDatabase.open() question
> > > >
> > > > Hi guys,
> > > >
> > > > I have a question about DBDatabase.open() method. It sets the driver
> > > > for
> > > the db and calls the driver's attachDatabase method which in most
> > > cases does nothing . But in case of MSSQL and MySql driver it executes
> > > some initialization SQL (*). We use a connection pool and a singleton
> > > DBDatabase instance, which is opened only once when the app is
> > > initialized. So this initialization script is executed only for the
> first
> > connection.
> > > >
> > > > So what is the purpose of this initialization SQL? Is it necessary,
> > > > and
> > > if yes, in case of a connection pool the DBDatabase should be open for
> > > every new connection?
> > > >
> > > > Regards,
> > > > Ivan
> > > >
> > > > * it sets the database to use (USE DATABASE...) and the date format
> > >
>