inotgo.com

Step 1 : Introduce   
Step 2 : Run... First , See the effect , Learn again   
Step 3 : Imitation and troubleshooting   
Step 4 : Test.java   
Step 5 : explain   
Step 6 : jar   

SQLite It's a database , It is running in JVM Inside , So you don't need to be like mysql That has to be installed and configured independently , But just take it and use it ...
Step 2 :

Run... First , See the effect , Learn again

edit top fracture
The old rule , First download the runnable project in the upper right corner , Configure to run , After confirming availability , Then learn what steps have been taken to achieve this effect .
function Test class , You can see the effect as shown in the figure ~
 Run... First , See the effect , Learn again
Step 3 :

Imitation and troubleshooting

edit top fracture
After ensuring that the runnable project can run correctly , Then strictly follow the steps in the tutorial , Imitate the code again .
The imitation process inevitably has code differences , As a result, the expected operation results cannot be obtained , At this moment, by comparison The correct answer ( Runnable project ) And your own code , To locate the problem .
In this way , Learning is effective , Troubleshooting is efficient , It can obviously improve the learning speed , Across all the barriers on the way to learning .

It is recommended to use diffmerge Software , Compare folders . Put your own project folder , Compare with my runnable project folder .
This software is awesome , You can know which two files in the folder are wrong , And clearly marked
Here is a green installation and use tutorial : diffmerge Download and use tutorials
The code is in the comments ~
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Test { public static void main(String[] args) { try { // Load driver , connect sqlite of jdbc Class.forName("org.sqlite.JDBC"); // Connect to the database how2j.db, You don't have to create it manually ... Connection connection = DriverManager.getConnection("jdbc:sqlite:how2j.db"); // Create connection object , yes Java An important interface for operating database Statement statement = connection.createStatement(); // Determine whether there is a table tables Existence of . If yes, delete statement.executeUpdate("drop table if exists hero"); // Create table statement.executeUpdate("create table hero(id int,name varchar(20),hp int)"); // Insert data statement.executeUpdate("insert into hero values(1,'Gareen','452')"); // Search the database , Put the search into the dataset ResultSet In ResultSet rSet = statement.executeQuery("select * from hero"); while (rSet.next()) { // Traverse this data set System.out.println("id:" + rSet.getInt(1)); System.out.println(" full name :" + rSet.getString(2)); System.out.println(" Blood volume :" + rSet.getString(3)); } rSet.close();// Close dataset connection.close();// Close database connection } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Because there is no third-party tool to link , So the code uses java Create a table structure .
The code demonstrates adding and querying , Delete and modify will not be demonstrated ....

The database file is called how2j.db, yes Sqlite Database file , Will automatically create
Required to run the project jar Already included in the runnable project in the upper right corner lib Under the directory


The official account of programming , Follow and get the latest tutorials and promotions in real time , thank you .


Q & A area    
2019-03-05 Download project operation error out of memory
yemh

about database -sqlite-JDBC Your questions
Download project operation error out of memory , I've checked here myself. It's not jvm Memory problems . I don't know where the problem is . stationmaster , For the above description The database file is called how2j.db, yes Sqlite Database file , It will be created automatically. I don't understand . I think they all have their own libraries on the Internet . I feel the problem here




1 One answer

There are no good names
Answer time :2019-03-30
The problem is not It's in jar There are no problems with the code in the package Just download the latest sqlite-jdbc.jar File Drag to lib In the file Right click servlet-api.jar, Right click “Build Path”---->"Add to Build Path " Then it's time to jar The package has been successfully added and can run normally



The answer has been submitted successfully , Auditing . Please My answer Check the answer record at , thank you
answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see








Please... Before asking questions land
The question has been submitted successfully , Auditing . Please My question Check the question record at , thank you
about database -sqlite-JDBC Your questions

Try to provide Screenshot code and Abnormal information , Help to analyze and solve problems . You can also enter this station QQ Group communication : 496725845
Ask questions and try to provide complete code , Environment description , The more conducive to the recurrence of the problem , The faster your question can be answered .
Have questions about the code in the tutorial , Please provide which step , Which line is in doubt , This makes it easy to quickly locate the problem , Improve the speed at which questions are answered
In the thousands of questions that already exist , A considerable proportion , Because of the use of and webmaster Different versions of the development environment Resulting in , For example jdk, eclpise, idea, mysql,tomcat Wait, the version of the software is inconsistent .
Please use the same version as the webmaster , You can save yourself a lot of learning time . The webmaster sorted out the software versions used in teaching , It's all here , Convenient for everyone to download : /k/helloworld/helloworld-version/1718.html

Upload screenshot