Java, how to change current database to another?

后端 未结 2 2128
失恋的感觉
失恋的感觉 2020-12-06 00:24

I have a Java program connection to a MySQL database, how can I change the current database to a different one on the same connection?

I connect to MySQL like this:<

2条回答
  •  孤街浪徒
    2020-12-06 01:13

    You can prefix the database name on your table names like this.

    For example: db1 has table1 and db2 has table2

    select * from db1.table1, db2.table2;
    

    This will allow you to do cross database queries

提交回复
热议问题