FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Two MySQL database connections at the same time
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Two MySQL database connections at the same time
Posted: Sun Sep 23, 2012 09:07 PM

I have a program which first opens all DBF needed and then opens some MySQL database and opens some tables using xBase syntax (USE sometable ...)
Then the program offers a main menu with several program options.
This works perfect.

Now I would like to do the same databases opening sequence (first DBF, then first databases and its tables), but now I want to add another database connection (different IP) and open some of the tables there. Meaning, one program will open two databases which are on different IP

Whenever I try to run such program, the program crashes without .LOG file, but ask me if I want to send M$ the error report..
If I remark one of the MySQL databases, the program regularly opens the first or the second MySQL database.
Cannot open BOTH databases one after another and use their tables.

The interesting thing is that after I open the first databases and use some tables, when I try to open another database on another IP, debug messages tels me that program connects to second MySQL database, but when I try to actually USE some tables there - the program crashes?

Am I missing here something? Is the parallel connection to two or more databases is possible at all?
Someone have a sample of opening the several MySQL databases one after another?

Thanks

Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Two MySQL database connections at the same time
Posted: Sun Sep 23, 2012 10:17 PM

May be duplicated table name between the 2 My databases?

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Two MySQL database connections at the same time
Posted: Mon Sep 24, 2012 12:16 PM

Codemaker

I open 2 Mysql Databases on different servers with tDolphin

connect osvr1 host "999.999.999.999" user "user" password "password" database "mydb"
connect osvr2 host "888.888.888.888" user "otheruser" password "otherpassword" database "mydb"

oDbClientes1:=tDolphinQry():New("select * from clientes",osvr1)
odbclientes2:=tDolphinQry():New("select * from clientes",osvr2)

Give it a try, is well documented, with a lot of samples.

From Chile
Adolfo

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: Two MySQL database connections at the same time
Posted: Mon Sep 24, 2012 10:57 PM

Unfortunately I am using xHarbour SQL.LIB and the "switch" to Dolphin is not what I can accept in this situation. I must keep with this LIB from many reasons.
I believe, Dolphin is efficient, but right now is not for my project.

If someone knows the way how can I connect to two different databases on two different IP addresses, please let me know

Thanks

Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: Two MySQL database connections at the same time
Posted: Mon Sep 24, 2012 10:58 PM

@ ADutheil
No, there is no duplication, either in database name or in table name

Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Two MySQL database connections at the same time
Posted: Tue Sep 25, 2012 02:53 AM
I tested following code with Harbour. I do not use xHarbour.
Code (fw): Select all Collapse
#include "dbinfo.ch"
#include "error.ch"
#include "hbrddsql.ch"

REQUEST SDDMY, SQLMIX
ANNOUNCE RDDSYS

PROCEDURE Main()
rddSetDefault( "SQLMIX" )

IF rddInfo( RDDI_CONNECT, { "MYSQL", "192.168.2.99", "egbadm","12345","egba" } ) == 0
    ? "Unable connect to the server 1"
    RETURN
ENDIF
dbUseArea( .T. , , "SELECT * FROM produtos", "prod" )
qout( "OK table 1" )

IF rddInfo( RDDI_CONNECT, { "MYSQL", "192.168.2.100", "egbadm","12345", "egba" } ) == 0
    ? "Unable connect to the server 2"
    RETURN
ENDIF
dbUseArea( .T. , , "SELECT * FROM resuentr", "resu" )
qout( "OK table 2" )

dbCloseAll()
RETURN


Everything works fine. Might be a bug in SQL.LIB?
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 130
Joined: Sun Mar 08, 2009 04:33 PM
Re: Two MySQL database connections at the same time
Posted: Tue Sep 25, 2012 12:30 PM

Zdravo Borise,

Možeš mi poslati tvoj mail?

Miloš Iz Subotice

Best regards

Milos



[ FWH 21.11 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603) ]
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: Two MySQL database connections at the same time
Posted: Tue Sep 25, 2012 06:29 PM
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: Two MySQL database connections at the same time
Posted: Tue Sep 25, 2012 06:32 PM

@ADutheil
I doubt its a bug in SQL.LIB in xHarbour
It is either I am doing something wrong, or the SQL.LIB doesn't support double connection

Continue the discussion