B4J Question JRDC2 query and parameter design for 2 databases

PumaCyan

Member
Licensed User
I have 2 databases
let's assume databases A and B

if I have table data in database A and I want to relate it to table data in database B, how do I design the query in the jrdc2 config file and the parameters that I create in the client application?

Sample Query:
SELECT a.field1, a.field2, a.field3
FROM database_A.table A, database_B.table B
WHERE a.field1 = b.field1;
 
Solution
Which database will you use? In MS Sql server you need to have code like this:

Example code:
select *
from [database1].dbo.mytable a inner join [database2].dbo.maytable b on a.myfield = b.myfield

DonManfred

Expert
Licensed User
Longtime User
Sounds like a bad Databasedesign.

I don´t know if it is possible mit SQLite. With any other Database i´m positive that it will not work (not sure though).

You need to have one odbc-driver which is able to connect to two different databases. I never saw such one.
 
Upvote 0

DarkoT

Active Member
Licensed User
Which database will you use? In MS Sql server you need to have code like this:

Example code:
select *
from [database1].dbo.mytable a inner join [database2].dbo.maytable b on a.myfield = b.myfield
 
Upvote 0
Solution

DonManfred

Expert
Licensed User
Longtime User
if both (or any number) of databases lives in the same instance is trivial to connect them
if they are not in the same instance it does not work i guess.
Same is true for any MySQL-Server where the Databases are on the same machine (and have the rights to access the databases).
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Upvote 0

PumaCyan

Member
Licensed User

Yes..
that doesn't sound good, right now I haven't fully mastered proper database design yet..

because right now I need the fastest solution to manage data traffic for a company that has several branches, so there you have it
 
Upvote 0

PumaCyan

Member
Licensed User

i am using mysql as database

means for the [database] to be created in the form of a parameter?
 
Upvote 0

DarkoT

Active Member
Licensed User
Just for info... You can basically link as linked server also Ms sql with MySql server over OLE ODBC database. If someone will need instruction, I can help... When is mysql as linked server accessible from ms sql server it’s easy to run query from ms sql to my sql database... Like this:

Example:
SELECT *
FROM   openquery
        (
        MYSQL,
        '
         SELECT *
         FROM [mysqlDb].[myTable]
        '
        )
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…