Reputation: 41
I had created a database using mysql workbench and i saved that database in one of the local drives. So in netbeans I need to design a database which is same as the earlier (created by using mysql workbench). So I would like to import that database into netbeans. Can anyone explain the procedure to do so?
Upvotes: 3
Views: 10997
Reputation: 88
You can use the built-in tools.
Here is a succinct example from Official Documentation: https://platform.netbeans.org/tutorials/nbm-crud.html#creating-app
Upvotes: 0
Reputation: 1938
A couple of days back I faced the same problem and found a easy solution. Though this question is asked 2 years back, I am posting this answer because it still doesn't have an answer here, so that it can provide help to other people with same problem in future.
I assume you know how to configure MySQL server. If no, visit https://netbeans.org/kb/docs/ide/mysql.html and follow the 'Configuring MySQL Server Properties' part.
After you create the server, right click on the 'MySQL Server'->'Create new database'. Give the database same name as the existing database has.
Now create a connection to the newly created database. If you dont know how, see the 'Starting the MySQL Server' and 'Creating and Connecting to the Database Instance' from https://netbeans.org/kb/docs/ide/mysql.html.
Now Expand the newly created connection which will look like 'jdbc:mysql://localhost:(portNumber)/(databaseName)'. Expand the database name node and right click 'table' and select 'Execute Command'
A new window will open. Assuming that you have a .sql file(Or may be a file without extension but consisting of SQL commands. You can export the database in file using your current admin tool if you have not already). Open that file in editor(notepad) and copy paste everything in the new opened command window in Netbeans.
Before Executing, just add one line before which states which database to use to execute query on.
USE <newly_created_database_name>;
as shown in the screenshot below (Red mark), it should be before the first line of the copy pasted SQL commands.
Now Execute the commands using the 'run SQL' button (green mark in image). To check, expand the tables node to see all the tables in original database are created.
Now you have your original database in place to work with.
Upvotes: 2