Sign in to follow this  
Followers 0
dar100111

Slow connection to the database in the next room

1 post in this topic

#1 ·  Posted (edited)

Hey All!  I have this code that works great but it seems the connection times anywhere from 10 seconds to a minute when I don't close the connection.  I was looking for a faster way to get this to connect.  The query itself take about 1 second to run in the database it's just the connection I'm having a hard time figuring out how to speed up.  The connecting itself is what's taking 30 secs or more sometimes.

Does anyone have any suggestions or see anything I'm doing wrong in my code?

I need to make this lightning fast or at least try to keep the connection open for a longer time frame.  Wasn't sure if it had something to do with the DB2 drivers that I had to install for this to work properly.

Thanks!

Func ConnectToETMS($p_branch, $p_user, $p_password)
    Local $l_objConn

    $l_objConn = ObjCreate("ADODB.Connection")
    if @error = 1 then return ''

    $l_objConn.Open("DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=" & $p_branch & "." & $p_branch & ".yess;PORT=45982;DATABASE=" & $p_branch & ";PROTOCOL=TCPIP;UID=" & $p_user & ";PWD=" & $p_password)
    if $l_objConn.State = 0 then return ''

    return $l_objConn
EndFunc


;script that kicks off the above
#include <array.au3>
#include "Expeditors_DB_Connect.au3"

TrayTip("Script", "Connecting to database.", 10)
$oConn = ConnectToETMS('###', '####', '#####')

$query = LoadSQLFile('etms_consol_dims.sql')

TrayTip("Script", "Executing query.", 10)
$results = QueryToArray($oConn, $query)

CloseConnection($oConn)

_ArrayDisplay($results)
Edited by dar100111

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0