首页 > 解决方案 > How do can I duplicate a MySql database with JDBC

问题描述

I'm trying to create a chat app in Java and I've hit a road bump. I want there to be multiple chat rooms, and those chat rooms can contain multiple people. I feel like to do this by code, every time a user creates a chatroom, it should create a new database and use that. What I want to do is just have a template database, and then duplicate it with different names. I know there might be security issues like setting the users allowed to access it, but I have no idea on what else I could do. For further explanation, the server I'm using is not local host, it is in a remote location so I can't just simply send a command with terminal.

This is the code I used to do what I wanted, but with a table instead of an entire database. Hopefully it might give you some more info on what I want/need.

int updateTable = st.executeUpdate("CREATE TABLE chat_room_" + df.format(num) + " LIKE chat_room_temp");

标签: javamysqljdbc

解决方案


推荐阅读