IntelliJ IDEA
IntelliJ IDEA – the Leading Java and Kotlin IDE, by JetBrains
9 Tips for Productive Java Development With Databases in IntelliJ IDEA
In this article, we’ll share nine time-saving ways IntelliJ IDEA can boost your productivity when developing Java applications with databases – whether you’re starting a new project or diving into an ongoing one.
Create data sources automatically from properties
IntelliJ IDEA makes it easy to create a data source for your Spring project right from the application.properties
file – simply open it and click on a gutter icon next to the properties.
In the opened Data Sources and Drivers dialog, you’ll see a data source already assigned and the database-related fields prefilled – all you need to do is to test connectivity (just in case) and click OK. The data source will be created for you.
Test Spring Data JPA query methods without running the application
IntelliJ IDEA simplifies Spring Data JPA method query verification! It provides autocompletion for names and the ability to check generated queries without running the application. Just click the dedicated gutter icon to execute repository methods directly in the JPQL console.
Review database schemas as diagrams
Database diagrams are great for quickly grasping the structure of databases and understanding the relationships between their various objects. IntelliJ IDEA can create detailed diagrams for data sources, schemas, or tables to help you analyze the data structure more effectively. To generate a diagram, right-click a database object in the Database tool window and select Diagrams | Show Diagram.
You can also assign colors to diagram objects to further enhance the way you interact with and comprehend your database structure.
Review query results right in the editor
IntelliJ IDEA provides a compact way to review query results right in the editor. To enable it, click the In-Editor Results button in the query console before running your query. This is especially useful for working with smaller datasets or data samples.
Modify query data in the results set view
When you need to make changes to cell values in IntelliJ IDEA, you don’t have to write and re-run queries! Simply click on a cell value that you want to edit, enter the new value, then click the Submit button (⬆) or ⌘↩/Ctrl+Enter to push changes to the database.
View query results as charts
Charts provide a powerful and user-friendly way to quickly gain actionable insights from your query results. This feature is particularly useful when analyzing large datasets, looking for patterns, or presenting trends in an easily comprehensible format.
To open chart settings, click the Switch to Chart icon on the data editor toolbar. You can choose from a wide range of chart types, including bar charts, pie charts, area charts, line charts, and more, depending on what best suits your needs.
When you need to present your findings or keep snapshots of data dynamics, you can export charts in .png
format. To save a chart snapshot, simply click the Export to PNG button in Series Settings.
Profile your query with an execution plan
You can also visualize execution plans for queries, illustrating the set of steps that were used to access data in a database and the cost of each step – in other words, how long it takes to run the statement.
To open the execution plan, right-click an SQL statement, select Explain Plan | Explain Plan, and then click on the Show Diagram icon.
Use DB migration libraries to update application databases
Database schemas evolve over time as business requirements change, and database schema updates and migration can be tricky and error-prone when done manually. Instead, take advantage of IntelliJ IDEA’s built-in support for automatically generating migration scripts based on existing JPA entities. For more information, refer to this article.
Leverage AI Assistant
AI Assistant makes data query and managing data faster and more efficient. It helps speed up SQL query generation, provides explanations, suggests fixes, and can even generate test data tables!
By following these tips, you can optimize your workflow, save time, and make working with databases more productive and enjoyable. Check out this page to learn more about the database tools in IntelliJ IDEA.
Happy developing!