I. Introduction of Jsqlparser
Jsqlparser is an open-source SQL statement parser that can parse SQL statements into a hierarchical set of Java classes.
Jsqlparser's project address is:
Https://github.com/JSQLParser/JSqlParser/wiki#what-is-jsqlparser the version I downloaded to is 0.9.4.
Second, the introduction of environmental construction
- Java version is JDK1.8;
- The Jsqlparser version is 0.9.4, which I downloaded from the project address above;
- Eclipse version is Mars release (4.5.0)
Third, import source project 3.1 import Maven Project
First we will download to the source code extracted from the project folder into Eclipse, note this time we will be in the form of MAVEN project, such as:
This is the case when I import:
There are a lot of unknown errors, we solve each.
3.2 Adding dependent libraries
Open the Pom.xml file in the project, from the following code in which we can see that Jsqlparser relies on Junit4.11,commons-io 2.4:
Then we look at whether the dependencies in the MAVEN repository in the project already have these dependent libraries, and I bring these dependent libraries after the import, so there's no need to add them, and if you don't have these dependent libraries in your project, we can download them separately and add them to the library in the build path. Specific download and add dependent library please Baidu.
Then according to the official document Https://github.com/JSQLParser/JSqlParser/wiki, you need to add some code (red part), notice the part of the circle in the picture, which indicates the current Jsqlparse version number, my is 0.9.4, Must not fill the wrong, otherwise there will be some classes can not find (may be related to the version), this section later found that, in fact, is used to add Jsqlparse0.9.4.jar Library, after this step has been done, there is no need to do step 3.5, the found class will call directly in the library.
3.3 Fix some bugs
Even if we do some of the above work, there are two errors in the Pom.xml file:
The error message is:
Through Baidu, I found a solution http://blog.sina.com.cn/s/blog_6accbcc30101duig.html,
Add a < pluginmanagement ></pluginmanagement > tag outside the < plugins ></plugins > label.
Like this:
<build>
<pluginManagement>
<plugins>
<plugin>
...
</plugin>
...
</plugins>
</pluginManagement>
</build>
This should be the wrong tip of the Red fork should not be.
3.5 using JAVACC to generate some classes
After we have done the above steps, there are a lot of errors in the project (if not, congratulations on your installation success), because the class is not found because Jsqlparse is based on JAVACC (about JAVACC (http://www.cnblogs.com/ gavin_liu/archive/2009/03/07/1405029.html),
Jsqlparser source of SQL parsing that part is generated using JAVACC, in Jsqlparser source, you can see jsqlparsercc.jj such a file.
Here we need to install JAVACC, in Eclipse has a JAVACC plug-in, specific installation method, you can refer to here (http://eclipse-javacc.sourceforge.net/)
After the installation is complete, locate the following file,
Right-click on this file and select the red part of the diagram:
After a while, a lot of Java files will be generated to copy these newly generated Java files here:
In addition, src/test/resources
all the errors in the file can be deleted, these files are written by the author of the example, some code older, and the current version is incompatible with the cause.
From for notes (Wiz)
Jsqlparser Source Compilation Environment Construction (original)