How to Connect to MySQL Database in IntelliJ IDEA

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello welcome to the video intellij idea connected to my sql database with me namabing from java.net in this video i'd like to share with you how to work with mysql database right inside intellij idea using the database tool so you don't have to use any external program like my sql workbench or mysql command line clan in details i will show you how to make a connection to a mysql database and then create a new table update data in a table how to execute some sql statements and how to use the sql statement suggestion when writing java code in intellij idea and i suppose that you are using the following survival ramps in java development jdk intelligent idea ultimate edition and mysql community server this is intellij id on my computer and as you can see i'm opening a java project in which i'm writing some java code that connects to my sql database here and to make a connection to a master created-based array inside intellij idea you can open the database view here this database view is usually in the right side of the ide here if you don't see this and database view you can press the shortcut key ctrl i to see the actions quick menu here and type database here and you can see the command that allows you to select the database view you see and click the plus button here to create a new data source here to my sql and name this data source now for example my cells10db clear and i will connect to a database on a localhost so the host name is localhost and provides the user and password and the database name sales db and you can see the zbc url here if you want to specify additional parameters options you can use this advanced tab here and click the test connection button and you can see it says that driver files are not downloaded and intellij is very useful it allows you to download the driver files automatically here so click download driver files here very convenient right so you don't have to manually download zbc driver for my sql and you can see now it has connected to my clear database server and you can see with the green check mark here and the version of my sql server is 20 here okay and click okay here we go if she's a console editor here that allows us to write an execute sql statement here and in the database view we can browse the schema tables in the database you can see there are some tables in this sales ndb database here you can see the columns of each table here you see similarly you can create another connection to another best cloud database here test connection succeeded you see click ok and this is a second database connection to the database schema mdb as you can see here in this database i have only one table customer here so you can create as many data sources connections as they want in this database tool and for each connection it brings sql control here that you can use to write as an execute sql statement here the database tool provided by intellij idea is very advanced it allows programmers to manage under the basis yeah just like mysql workbench or more advanced you can create new table new schema and many actions so when finished working with the database you can disconnect here click choose the connection here and click the red button here to disconnect okay so i have disconnected from the cells near db and now i'm working with the mdb here and let me show you how to create a new table in this database right click new table here yeah enter the table name for example users and click the plus button here to add a new column id type integer not null auto increment in a primary key and the second column is first underscore name type is 45 not know and the third column is last name tai raja so you can see it's already convenient easy to use so programmer doesn't need to leave the ide that's managed database right inside the ide very convenient so i will grab this table with three columns and you can see the sql script automatically appears here to let you review and click the execute button here to create that table and you can see the newly created table users got appear here with three columns id first name and last name very easy right and to manage update data in a table you can double click on the table name here and we it will select all rows from the table and because this table is new so you can see no rows it is empty and let me double click the customer table here you can see there are two rows in this table each table data is opened in a new tab here now let me insert a new row going to this user's table here so you can click the plus button here add new row and you can enter the values right inside the table here first name is last name is and i can add as many rows as i wish here ruby and to commit the changes to this table you can click the submit button here you can see submit here or press the social key control enter okay so that means it has inserted three rows into this user's table you can verify by close the tab and double click on the table again you can see there are three rows in this users table to delete row you can select the row and click the minus button here delete arrow and click the submit button to commit the changes and you can see now there are only two rows and to edit you can edit for example me yeah and click submit here and it commits the chains very convenient very easy cool right now i will show you how to write sql statements then execute sql statements and when you create a new connection you can see it opens the control for a sql statement here if you don't see don't see the sql console here you can right click on the database here open query console here okay and i can type a sql statement here select asterisk from the users table here and you can see it also suggests as a completion yeah very cool you can see the film names here and also the operators sql syntax very very convenient here i want to select arrows from the users table and click the execute button here or press the circular key control enter and you can see the result the output of the execution of the sql statement here two rows received from starting starting from one here and real data here you can see the two rows here very convenient right and similarly you can write another sql statement that you just set first name equal name anyway id equal one and to execute this statement only you select it and click the execute button here and you can see the result output here of the update sql statement here one drop of water here and here in the original table you can click the refresh yeah refresh button here you can see first name has changed to nap here perfect right and you can open as many sql console editor as you want by right click on the database and query control here now let me show you how to use sql inspection or sql statement auto completion succession in intelligent idea so i already wrote the code for zbc url username password manga connection and now i want to write a sql statement here insert into yeah and i want to use the sql statement inspection so click on the hint here and select inject language or reference here and in the list you choose sql here sql and you can see the text in the string here becomes [Music] orange here and that means intelligent idea we provide succession for sql statement syntax here but you don't see any suggestion for the table names or column names in the database sldb here so you need to press the circuit ship control i and type sql and direct here and click the sql dialogue for settings here and select the project sequel i like here to mysql okay and now press ctrl space and you can see the suggestion for the table names here very convenient right i want to insert some arrow into the students table and you can see the suggestion or also suggestion for the column names here name and drone progress very convenient right so that's how to use the sql statement inspection auto connection in intellij idea and note that i even don't have any active connection in the database view yet intellij idea automatically inspects the connection based on the zvc url here and then if we provide a suggestion of in the sql statement literally here you see the succession for table names column names they're very convenient right very cool so far you have learned how to work with my sql databases right inside intellij idea you don't have to use an external program like mask i work bench on my sql command line clan very cool and convenient right i hope you found this video helpful please subscribe to my channel like comment and share this video thank you
Info
Channel: Code Java
Views: 84,792
Rating: undefined out of 5
Keywords: Java, IntelliJ IDEA, MySQL, connect to MySQL in IntelliJ, connect to mysql database in IntelliJ, intellij connect to mysql database, mysql in intellij
Id: -yiL99KFeng
Channel Id: undefined
Length: 17min 0sec (1020 seconds)
Published: Sun Nov 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.