Basically I need to run the following query through jdbc. Both databases are MySQL and on the same server.
SELECT * FROM DB1.ACCOUNT a
JOIN DB2.ITEM i ON a.AccountID = i.AccountID
My jdbc connection is set up like this:
Class.forName("com.mysql.jdbc.Driver").newInstance();
DB1 = DriverManager.getConnection("jdbc:mysql://serverloc.com:3300/DB1", "username", "password");
DB2 = DriverManager.getConnection("jdbc:mysql://serverloc.com:3300/DB2", "username", "password");
This is where I run into problems. I can now create a statement against DB1 or DB2, but I can't find a way to JOIN against both databases. I've tried running my query against one of the databases (below) but that returns null.
Statement statement = DB1.createStatement();
ResultSet resultSet = statement.executeQuery(" QUERY HERE ");
I've seen that you can use UnityJDBC to run JOIN queries across DB's, but I'm looking for a free/open source option.
Thanks!