Two MySQL database connections at the same time

Two MySQL database connections at the same time

Postby codemaker » Sun Sep 23, 2012 9: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
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Two MySQL database connections at the same time

Postby ADutheil » Sun Sep 23, 2012 10:17 pm

May be duplicated table name between the 2 My databases?
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Two MySQL database connections at the same time

Postby Adolfo » 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
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Two MySQL database connections at the same time

Postby codemaker » 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
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Two MySQL database connections at the same time

Postby codemaker » Mon Sep 24, 2012 10:58 pm

@ ADutheil
No, there is no duplication, either in database name or in table name
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Two MySQL database connections at the same time

Postby ADutheil » Tue Sep 25, 2012 2:53 am

I tested following code with Harbour. I do not use xHarbour.
Code: Select all  Expand view  RUN
#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
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Two MySQL database connections at the same time

Postby mtajkov » 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) ]
mtajkov
 
Posts: 130
Joined: Sun Mar 08, 2009 4:33 pm

Re: Two MySQL database connections at the same time

Postby codemaker » Tue Sep 25, 2012 6:29 pm

User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Two MySQL database connections at the same time

Postby codemaker » Tue Sep 25, 2012 6: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
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests