i have a project am working on, its all about querying a data from multiple databases from different vendors (i mean querying databases like mysql, hsqldb, microsoft sql, oracle, etc at the same time using one query statement). Though i have achieved this by loading each driver of the database connector sequentially and execute the query sequentially across the databases. But the project architecture is such that when i sent a query statement, it shouldgo simultaneously to each database and retrieve the item ifavailable in all databases involved. I came across this unityjdbc software, a mediation software but dont know how to implement it in my java source file so that to achieve my aim. I have read the unityjdbc user manual but is not clear and straight-forward. Please can anyone advise how toimplement this unityjdbc driver in my java application and use it to successful query multiple databases. Suggestions for any other way to simultaneously query their multiple databases with a single statement would also be welcome.
我有一个项目正在进行中,它涉及到从不同供应商的多个数据库查询数据(我的意思是同时使用一条查询语句查询mysql、hsqldb、microsoft sql、oracle等数据库)。尽管我是通过顺序加载数据库连接器的每个驱动程序并在数据库之间顺序执行查询来实现这一点的。但是,项目架构是这样的,当我发送一个查询语句时,它应该同时访问每个数据库,并在所有涉及的数据库中检索到ifavailable。我遇到了这个unityjdbc软件,一个中介软件,但不知道如何在我的java源文件中实现它,以便实现我的目标。我读过unityjdbc用户手册,但不清楚,也不清楚。请任何人建议如何在我的java应用程序中实现这个unityjdbc驱动程序,并使用它成功查询多个数据库。对于任何其他方式同时使用一条语句查询多个数据库的建议也将是受欢迎的。
2 个解决方案
#1
2
UnityJDBC allows you to query multiple databases in one SQL query. You cannot do this using separate threads as you would then be responsible for merging the data from the multiple databases yourself in your Java program.
UnityJDBC允许您在一个SQL查询中查询多个数据库。您不能使用单独的线程来实现这一点,因为您将负责在Java程序中合并来自多个数据库的数据。
The setup steps are easy:
安装步骤很简单:
-
Use the SourceBuilder application to specify the JDBC connection information to your databases.
使用SourceBuilder应用程序指定数据库的JDBC连接信息。
-
Test a sample query that accesses multiple databases. Standard SQL is supported. To reference tables in different databases use databaseName.tableName in your FROM clause.
For example:测试访问多个数据库的示例查询。支持标准的SQL。要引用不同数据库中的表,请使用databaseName。在你的FROM子句中。例如:
SELECT * FROM Database1.Table1 T1 INNER JOIN Database2.Table2 T2 ON T1.id = T2.id
从Database1选择*。表1 T1内部连接数据库2。在T1表T2。id = T2.id
-
The SourceBuilder application will provide an XML configuration file as output often called sources.xml. To use this in your own Java program or any software that supports JDBC the connection URL is:
jdbc:unity://sources.xml
You may specify an absolute or relative path to the sources.xml file.SourceBuilder应用程序将提供一个XML配置文件,作为通常称为sources.xml的输出。要在您自己的Java程序或任何支持JDBC的软件中使用它,连接URL是:JDBC:unity://source。您可以指定到源的绝对路径或相对路径。xml文件。
There is documentation on their site at http://www.unityjdbc.com/support/ or contact them for free support.
在他们的网站http://www.unityjdbc.com/support/或联系他们获得免费支持。
Another way to get started quickly is to use the MultiSource SQL Plugin that comes with the open source query software SQuirreL SQL. The plugin will allow you to query any number of databases using SQL in SQuirreL and will generate the XML configuration files for you to use in other programs. The plugin is open source and free. The plugin also supports querying and joining NoSQL databases like MongoDB with relational databases such as MySQL and Postgres.
另一种快速启动的方法是使用开源查询软件SQuirreL SQL提供的多源SQL插件。该插件允许您使用SQuirreL中的SQL查询任意数量的数据库,并将生成XML配置文件供您在其他程序中使用。这个插件是开源的,而且是免费的。该插件还支持查询和连接NoSQL数据库(如MongoDB)和关系数据库(如MySQL和Postgres)。
#2
1
You don't need UnityJDBC for what you want to do, if you've already managed to load all the db-specific JDBC drivers.
如果您已经成功地加载了所有特定于db的JDBC驱动程序,那么您就不需要UnityJDBC了。
Instead, you should look at doing each query in a separate thread. That way, you don't need to wait for one database to return its results before querying the next one.
相反,您应该考虑在一个单独的线程中执行每个查询。这样,在查询下一个数据库之前,您不需要等待一个数据库返回它的结果。
#1
2
UnityJDBC allows you to query multiple databases in one SQL query. You cannot do this using separate threads as you would then be responsible for merging the data from the multiple databases yourself in your Java program.
UnityJDBC允许您在一个SQL查询中查询多个数据库。您不能使用单独的线程来实现这一点,因为您将负责在Java程序中合并来自多个数据库的数据。
The setup steps are easy:
安装步骤很简单:
-
Use the SourceBuilder application to specify the JDBC connection information to your databases.
使用SourceBuilder应用程序指定数据库的JDBC连接信息。
-
Test a sample query that accesses multiple databases. Standard SQL is supported. To reference tables in different databases use databaseName.tableName in your FROM clause.
For example:测试访问多个数据库的示例查询。支持标准的SQL。要引用不同数据库中的表,请使用databaseName。在你的FROM子句中。例如:
SELECT * FROM Database1.Table1 T1 INNER JOIN Database2.Table2 T2 ON T1.id = T2.id
从Database1选择*。表1 T1内部连接数据库2。在T1表T2。id = T2.id
-
The SourceBuilder application will provide an XML configuration file as output often called sources.xml. To use this in your own Java program or any software that supports JDBC the connection URL is:
jdbc:unity://sources.xml
You may specify an absolute or relative path to the sources.xml file.SourceBuilder应用程序将提供一个XML配置文件,作为通常称为sources.xml的输出。要在您自己的Java程序或任何支持JDBC的软件中使用它,连接URL是:JDBC:unity://source。您可以指定到源的绝对路径或相对路径。xml文件。
There is documentation on their site at http://www.unityjdbc.com/support/ or contact them for free support.
在他们的网站http://www.unityjdbc.com/support/或联系他们获得免费支持。
Another way to get started quickly is to use the MultiSource SQL Plugin that comes with the open source query software SQuirreL SQL. The plugin will allow you to query any number of databases using SQL in SQuirreL and will generate the XML configuration files for you to use in other programs. The plugin is open source and free. The plugin also supports querying and joining NoSQL databases like MongoDB with relational databases such as MySQL and Postgres.
另一种快速启动的方法是使用开源查询软件SQuirreL SQL提供的多源SQL插件。该插件允许您使用SQuirreL中的SQL查询任意数量的数据库,并将生成XML配置文件供您在其他程序中使用。这个插件是开源的,而且是免费的。该插件还支持查询和连接NoSQL数据库(如MongoDB)和关系数据库(如MySQL和Postgres)。
#2
1
You don't need UnityJDBC for what you want to do, if you've already managed to load all the db-specific JDBC drivers.
如果您已经成功地加载了所有特定于db的JDBC驱动程序,那么您就不需要UnityJDBC了。
Instead, you should look at doing each query in a separate thread. That way, you don't need to wait for one database to return its results before querying the next one.
相反,您应该考虑在一个单独的线程中执行每个查询。这样,在查询下一个数据库之前,您不需要等待一个数据库返回它的结果。