Reconnect database connection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Reconnect database connection

Carl Gundel-2
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Carl Gundel-2
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Carl Gundel-2
Is there some cached state that I need to clear?
 
-Carl

On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Louis LaBrunda
In reply to this post by Carl Gundel-2
Hi Carl,

I do some testing to see if I have a good database connection (I can share if you need it).  I then save the connection like so:

databaseConnection := AbtDbmSystem activeDatabaseConnection.

I
m not sure if that is the same value you have in #connectionResult, if it is that's good.  Then if I feel I need to kill a connection and reconnect I do this:

databaseConnection ifNotNil: [:dbc | [dbc disconnectIfError: [:e | e]] when: ExError do: [:sig | sig exitWith: nil]].

and reconnect.

Hope that helps.

Lou


On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Carl Gundel-2
Thanks Louis, how do you do the reconnect?

-Carl

On Monday, June 22, 2015 at 5:34:17 PM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I do some testing to see if I have a good database connection (I can share if you need it).  I then save the connection like so:

databaseConnection := AbtDbmSystem activeDatabaseConnection.

I
m not sure if that is the same value you have in #connectionResult, if it is that's good.  Then if I feel I need to kill a connection and reconnect I do this:

databaseConnection ifNotNil: [:dbc | [dbc disconnectIfError: [:e | e]] when: ExError do: [:sig | sig exitWith: nil]].

and reconnect.

Hope that helps.

Lou


On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Louis LaBrunda
Hi Carl,

I reconnect the same way I connect the first time.  I have a method that is a combination of a test of the connection (which makes the connection) and closing the connection.

I pass a parameter to the method that tells it to disconnect (using #disconnectIfError:), this is used when a problem was detected elsewhere and I want to reconnect.  First time the call is made without the disconnect flag set.  I have a query that gets the SPID (SELECT SPID=@@SPID).  I want the SPID anyway.  This lets lets the base Smalltalk database code make the connection to the database.  If the SPID is retrieved, I have a good connection and save AbtDbmSystem activeDatabaseConnection, if not, I log the error (and maybe send an email) and try again later.

I also play some games that allow me to use different database aliases.  I can tell you more but I don't want to complicate things unless you really want to know more.

Lou


On Monday, June 22, 2015 at 6:05:56 PM UTC-4, Carl Gundel wrote:
Thanks Louis, how do you do the reconnect?

-Carl

On Monday, June 22, 2015 at 5:34:17 PM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I do some testing to see if I have a good database connection (I can share if you need it).  I then save the connection like so:

databaseConnection := AbtDbmSystem activeDatabaseConnection.

I
m not sure if that is the same value you have in #connectionResult, if it is that's good.  Then if I feel I need to kill a connection and reconnect I do this:

databaseConnection ifNotNil: [:dbc | [dbc disconnectIfError: [:e | e]] when: ExError do: [:sig | sig exitWith: nil]].

and reconnect.

Hope that helps.

Lou


On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Carl Gundel-2
Louis,
 
Why do you need to use different aliases?
 
Thanks,
 
-Carl

On Tuesday, June 23, 2015 at 10:27:42 AM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I reconnect the same way I connect the first time.  I have a method that is a combination of a test of the connection (which makes the connection) and closing the connection.

I pass a parameter to the method that tells it to disconnect (using #disconnectIfError:), this is used when a problem was detected elsewhere and I want to reconnect.  First time the call is made without the disconnect flag set.  I have a query that gets the SPID (SELECT SPID=@@SPID).  I want the SPID anyway.  This lets lets the base Smalltalk database code make the connection to the database.  If the SPID is retrieved, I have a good connection and save AbtDbmSystem activeDatabaseConnection, if not, I log the error (and maybe send an email) and try again later.

I also play some games that allow me to use different database aliases.  I can tell you more but I don't want to complicate things unless you really want to know more.

Lou


On Monday, June 22, 2015 at 6:05:56 PM UTC-4, Carl Gundel wrote:
Thanks Louis, how do you do the reconnect?

-Carl

On Monday, June 22, 2015 at 5:34:17 PM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I do some testing to see if I have a good database connection (I can share if you need it).  I then save the connection like so:

databaseConnection := AbtDbmSystem activeDatabaseConnection.

I
m not sure if that is the same value you have in #connectionResult, if it is that's good.  Then if I feel I need to kill a connection and reconnect I do this:

databaseConnection ifNotNil: [:dbc | [dbc disconnectIfError: [:e | e]] when: ExError do: [:sig | sig exitWith: nil]].

and reconnect.

Hope that helps.

Lou


On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Reconnect database connection

Louis LaBrunda
Hi Carl,

Some customers have production and test environments with production and test databases with the same name.  Different aliases allows them to run two copies of our program at the same time on the same workstation, each one seeing transactions from the production or test environment but not both.

Lou

On Tuesday, June 23, 2015 at 10:31:58 AM UTC-4, Carl Gundel wrote:
Louis,
 
Why do you need to use different aliases?
 
Thanks,
 
-Carl

On Tuesday, June 23, 2015 at 10:27:42 AM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I reconnect the same way I connect the first time.  I have a method that is a combination of a test of the connection (which makes the connection) and closing the connection.

I pass a parameter to the method that tells it to disconnect (using #disconnectIfError:), this is used when a problem was detected elsewhere and I want to reconnect.  First time the call is made without the disconnect flag set.  I have a query that gets the SPID (SELECT SPID=@@SPID).  I want the SPID anyway.  This lets lets the base Smalltalk database code make the connection to the database.  If the SPID is retrieved, I have a good connection and save AbtDbmSystem activeDatabaseConnection, if not, I log the error (and maybe send an email) and try again later.

I also play some games that allow me to use different database aliases.  I can tell you more but I don't want to complicate things unless you really want to know more.

Lou


On Monday, June 22, 2015 at 6:05:56 PM UTC-4, Carl Gundel wrote:
Thanks Louis, how do you do the reconnect?

-Carl

On Monday, June 22, 2015 at 5:34:17 PM UTC-4, Louis LaBrunda wrote:
Hi Carl,

I do some testing to see if I have a good database connection (I can share if you need it).  I then save the connection like so:

databaseConnection := AbtDbmSystem activeDatabaseConnection.

I
m not sure if that is the same value you have in #connectionResult, if it is that's good.  Then if I feel I need to kill a connection and reconnect I do this:

databaseConnection ifNotNil: [:dbc | [dbc disconnectIfError: [:e | e]] when: ExError do: [:sig | sig exitWith: nil]].

and reconnect.

Hope that helps.

Lou


On Monday, June 22, 2015 at 4:22:01 PM UTC-4, Carl Gundel wrote:
Let me be a little more specific.  I find that if I lost my database connection and get one of these errors:
 
  [SQLSTATE=08S01 - [Microsoft][ODBC SQL Server Driver]Communication link failure [Native Error=0]]
 
That I continue to get that error even after the network is restored and a new connection is attempted using this sort of code:
 
 conSpec := AbtDatabaseConnectionSpec
  forDbmClass: #AbtOdbcDatabaseManager
  dataSourceName: dataSource.
 logonSpec := AbtDatabaseLogonSpec
  id: user
  password: password
  server: nil.
 AbtDbmSystem
   registerLogonSpec: logonSpec
   withAlias: 'windoPath'.
 connectionResult := conSpec connectUsingAlias: 'windoPath'.
 
What am I doing wrong?
 
Thanks,
 
-Carl

On Monday, June 22, 2015 at 11:40:37 AM UTC-4, Carl Gundel wrote:
Hey!
 
I'm using the Abt database mechanisms.  I need to be able to reopen a database connection when it goes bad, for example if the database server gets rebooted or my network has a temporary problem.
 
Any suggestions for the simplest way to do this?
 
Thanks,
 
-Carl

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.