In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to add sqlite database in IntellJ Idea version 2020". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
List of tools:
1.Sqlite
2. SQLiteStudio
3. IntellJ
4. Sqlite-jdbc-3.32.3.2.jar
Take a look at the results in advance:
Download and install IntellJ
Download directly to the official website, beginners suggest not to download the latest, once there are changes and tutorials on the compiler UI do not match the number, climb upstairs to compare the time. Of course, there will be first-hand valuable gains.
Https://www.jetbrains.com/idea/download/#section=windows
Download Sqlite development tools
Https://www.sqlite.org/download.html
It can be run directly after decompression without installation.
Create a database file
Create a database file with the studio.sqlite name.
Note: if there is a phenomenon that cannot be generated, enter any non-empty characters after "sqlite >", enter and then cancel Ctrl+C to generate a studio.sqlite file. (.sqlite, .db suffix database files are recognized. )
If you only create a blank file here, you can also create a new * .db file directly by modifying the suffix.
Database file writes data
SQLiteStudio can be downloaded from this network address, as well as tutorials. It is convenient to input data.
Http://www.xue51.com/soft/4831.html
Input data in database
The sample data and fields are entered as follows:
Enter the IntellJ configuration database
At this point, it is found that there is no Database option in Tool Windows, and you need to install the Database toolkit.
File- "Settings-" Plugins
Select Plugins, search for database in the search box, install "Database Navigator", and then restart the Intellj application.
After reboot, the "DB Browser" option appears on the left border.
The java code is as follows:
Import java.sql.*; public class database {public static void main (String [] arg) throws ClassNotFoundException, SQLException {System.out.println ("database"); Connection conn = null; ResultSet rs = null; Statement statement; Class.forName ("org.sqlite.JDBC"); / / sqlite database name. Conn = DriverManager.getConnection ("jdbc:sqlite:F:\ codeZ\\ database\\ mysqlite1.sqlite"); statement = conn.createStatement (); rs = statement.executeQuery ("SELECT * FROM demo"); / / this is name of database list while (rs.next ()) {System.out.println ("-"); System.out.print ("id:" + rs.getString ("id")) System.out.print ("name:" + rs.getString ("name")); System.out.println ("age:" + rs.getString ("age"));}
Note:
1. There are exceptions in the database operation function, so you need to include ClassNotFoundException and SQLException, which can be debugged and added by referring to the compiler.
The running result is as follows:
Appendix:
Problem 1: database loading failed
The following error occurred, which may be caused by not adding the jar package. Sqlite-jdbc-3.32.3.2.jar
File- "Project structure-"
Add sqlite-jdbc-3.32.3.2.jar, remember to check it.
Question 2:
The following URL corresponds to the path and name of the database.
Problem 3: unable to connect to the database
Check the database url name and make sure the database is in the disconnect state before running the code.
Question 4: failed to read table information
The names of the tables created for the database below do not correspond to each other. Use SQLiteStudio to open the database file and view the DLL (refer to the figure above) and change it to the correct name.
This is the end of the introduction to "how to add a sqlite database in IntellJ Idea version 2020". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.