Applicable to jetty7 and jetty8
1. Use GBK encoding in jetty
First, the encoding filter is required, and then add the following parameters in the startup server command
-Dorg. eclipse. jetty. server. request. queryEncoding = GBK-Dorg. eclipse. jetty. util. urlEncoding. charset = GBK-Dorg. eclipse. jetty. util. URI. charset = GBK
2. Use p6spy through jndi in jetty
(1) Add the jdbc directory in the lib directory and add the following jar package
Commons-collections.jar
Commons-dbcp-1.2.1.jar
Commons-pool-1.3.jar
Log4j-1.2.15.jar
Ojdbc6.jar
P6spy. jar
(2) Add jdbc module configuration in OPTIONS of start. ini
(3) data source configuration
[Html]
<New id = "ds_dev" class = "org. apache. commons. dbcp. BasicDataSource">
<Set name = "driverClassName"> oracle. jdbc. driver. OracleDriver </Set>
<Set name = "url"> jdbc: oracle: thin: @ 10.0.20.80: 1521: dev </Set>
<Set name = "username"> dev </Set>
<Set name = "password"> dev </Set>
<Set name = "maxActive" type = "int"> 100 </Set>
<Set name = "maxIdle" type = "int"> 30 </Set>
<Set name = "maxWait" type = "int"> 1000 </Set>
<Set name = "defaultAutoCommit" type = "boolean"> true </Set>
<Set name = "removeAbandoned" type = "boolean"> true </Set>
<Set name = "removeAbandonedTimeout" type = "int"> 60 </Set>
<Set name = "logAbandoned" type = "boolean"> true </Set>
<Set name = "testOnBorrow" type = "boolean"> true </Set>
</New>
<New id = "p6spyDataSourceTarget" class = "com. p6spy. engine. spy. P6DataSource">
<Set name = "realDataSource"> realJndiName </Set>
</New>
<New class = "org. eclipse. jetty. plus. jndi. Resource">
<Arg> realJndiName </Arg>
<Arg>
<Ref id = "ds_dev"/>
</Arg>
</New>
<New class = "org. eclipse. jetty. plus. jndi. Resource">
<Arg> devdbDS </Arg>
<Arg>
<Ref id = "p6spyDataSourceTarget"/>
</Arg>
</New>
The actual jndi name used in the program is devdbDS. P6spyDataSourceTarget acts as a proxy.
3. Prevent resource files from being locked during server running during development and cannot be modified.
Set useFileMappedBuffer in etc \ webdefault. xml to false.
[Html]
<Init-param>
<Param-name> useFileMappedBuffer </param-name>
<Param-value> false </param-value>
</Init-param>
4. jetty Server java. SQL. SQLException: Already closed Processing
Add the following configuration to the jetty data source Configuration:
[Html]
<Set name = "testOnBorrow" type = "boolean"> true </Set>
<Set name = "testOnReturn" type = "boolean"> true </Set>
<Set name = "testWhileIdle" type = "boolean"> true </Set>
<Set name = "validationQuery" type = "String"> select 1 from dual </Set>
The connection pool is added to retrieve, return, and test whether the connection is valid when idle.
The SQL configuration of validationQuery's test connection validity needs to be adjusted according to the database.
By fengyie007