JNDI is a standardized Java naming system interface. In the Jetty container, JNDI can be compiled and developed. You can also configure JNDI resources into Jetty. Here's how to develop JNDI in the Linux system Jetty environment.
First, the development environment
The tools used in this article can be listed as follows:
1) JDK 8.0.25
2)Maven 3.3.3< Br>
3) Eclipse JEE 4.5.0 (mars version)
4) Jetty 9.3.2
5) H2 Database Engine 1.4.188
Note that The H2 database can be run through a single JAR package without additional installation.
Also, suppose we want to create a jcgexamle data table with two columns, the ID column and the ARTICLE_NAME column.
C:\\jtools\\h2\\bin"java -cp h2-1.4.188.jar org.h2.tools.Server
TCP server running at tcp://192.168.1.103: 9092 (only local connections)
PG server running at pg://192.168.1.103:5435 (only local connections)
Web Console server running at http://192.168.1.103:8082 (only local connections)
This command immediately starts the server mode of the H2 database and automatically opens the browser to connect to the H2 web console, allowing the user to create and configure the H2 database.
Select Chinese (Simplified) language, and fill
JDBC URL: jdbc: h2: tcp: //localhost /~ /jcgdb
Username: Sa
Click the Test Connection button to return the message "Test Success". At this point, the H2 database engine will automatically create a database file named jcgdb.mv.db in the home directory of the file system, and then we can run the following script to create the data table jcgexamle and insert two rows of records:
CREATE CACHED TABLE PUBLIC.JCGEXAMPLE(
ID INTEGER,
ARTICLE_NAME VARCHAR(255)
);
insert into JCGEXAMPLE values(1, ‘Jetty JNDI Example’);
insert into JCGEXAMPLE values(2,‘Jetty JMX Example’);
At this point, the database is ready.
Second, build the Demo project
1, create a Maven project in the Eclipse environment
Group Id:com.ch.snippets.enterprise
Artifact Id: Jetty-jndi-demo
Packaging:war
2. Add a dependency package
Add the following dependency package to the pom.xml configuration file:
org .eclipse.jetty:jetty-server
org.eclipse.jetty:jetty-webapp
org.eclipse.jetty:jetty-plus
org.eclipse.jetty: Jetty-jndi
com.h2database:h2
The pom.xml configuration file is as follows:
"project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”"
"modelVersion" 4.0.0 "/modelVersion"
"groupId" "com.ch.snippets.enterprise"/groupId"
artifactId"jetty-jndi-demo"/artifactId
"version" 0.0.1-SNAPSHOT "/version"
"packaging" war "/packaging"
"dependencies"
Dependency
groupId org.eclipse.jetty/groupId
artifactId jetty-server/artifactId
"version" 9.3.2.v20150730 "/version"
"/dependency"
"dependency"
"groupId" org.eclipse.jetty "/groupId"
"artifactId" Jetty-webapp "/artifactId"
"version" 9.3.2.v20150730 "/version"
"/dependency"
"dependency"
"groupId" org.eclipse.jetty "/groupId"
"artifactId" jetty-plus "/artifactId"
"version" 9.3.2.v20150730 "/version"
"/dependency"
"dependency"
"groupId" org.eclipse.jetty "/groupId"
"artifactId" jetty-jndi "/artifactId"
"version" 9.3.2.v20150730 "/version"
"/dependency"
"dependency"
"groupId" com.h2database "/groupId 》
"artifactId" h2 "/artifactId"
"version" 1.4.188 "/version"
"/dependency"
"/dependencies
"/project"
The above is how to develop JNDI in the Linux Jetty environment. The resources defined in jetty need to be declared in web.xml. So jetty will map the resources in the default context to java:comp/env.
In the previous article, the su command was introduced. The su command is used for
In Linux, commands can be used to form dialog boxes. The dialog box formed by Linux command line is
The gnome panel function of the Linux system is actually equivalent to the taskbar
When formatting Linux partitions, many people have encountered a tough problem, suggesting that Coul
How to solve the problem after unable to connect to the network after reinstalling Linux
How to solve the problem of multi-line display of wget download progress bar in CentOS
Linux system how to switch the foreground process and background process
Teach you how to add a personalized display in the Linux login interface
Two ways to speed up the copying speed of Linux files
How to use Linux to use rsync command to delete small files in batches
The principle of implementing breakpoint resume in Linux
How to remove the ^M character of the Linux file
How to install LAMP in yum in CentOS6.5 system
Ubuntu 14.04 install java method
Gulp error under Linux Error: What should I do with ENOSPC?
Linux installation third-party library error Python version 2.7 how to do?
Win8.1 SkyDrive can not log in the solution
Win8.1 must set 15 places Win8.1 optimization settings tutorial
Share Windows XP Practical Shortcuts Tips
Win8 App Store Installer Hangs Cannot Install
How to set up screen saver in Win7
Win8 system IE11 can not open the local website solution
What if win7 task manager stops running
How does the Win10 system enlarge the mouse pointer?