start.sh

#TITLE=jetty

DEPLOY_PATH=$(cd $(dirname $)/../ && pwd)
export DEPLOY_PATH CLASSPATH=${CLASSPATH}:${DEPLOY_PATH}/lib/start.jar:${DEPLOY_PATH}/configs
export CLASSPATH JAVA_OPTIONS="-server -XX:PermSize=64m -XX:MaxPermSize=128m -Xmx512m -Xms256m"
export JAVA_OPTIONS DEBUG_PORT=
export DEBUG_PORT JAVA_DEBUG="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=${DEBUG_PORT},server=y,suspend=n"
export JAVA_DEBUG ${JAVA_HOME}/bin/java ${JAVA_OPTIONS} ${JAVA_DEBUG} -Dclasspath=${DEPLOY_PATH}/lib -Dbasepath=${DEPLOY_PATH} com.dc.jetty.start.Start
if [ "${doExitFlag}" = "true" ] ; then
exit
fi

log4j.properties

log4j.rootLogger=info,console,debug,info,warn,error,fatal

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender
log4j.appender.debug.File=./log/rest/rest_debug
log4j.appender.debug.DatePattern='.'yyyyMMdd'.log'
log4j.appender.debug.layout=org.apache.log4j.PatternLayout
log4j.appender.debug.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n
log4j.appender.debug.filter.F1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.debug.filter.F1.LevelMin=debug
log4j.appender.debug.filter.F1.LevelMax=debug log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
log4j.appender.info.File=./log/rest/rest_info
log4j.appender.info.DatePattern='.'yyyyMMdd'.log'
log4j.appender.info.layout=org.apache.log4j.PatternLayout
log4j.appender.info.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n
log4j.appender.info.filter.F1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.info.filter.F1.LevelMin=info
log4j.appender.info.filter.F1.LevelMax=info log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender
log4j.appender.warn.File=./log/rest/rest_warn
log4j.appender.warn.DatePattern='.'yyyyMMdd'.log'
log4j.appender.warn.layout=org.apache.log4j.PatternLayout
log4j.appender.warn.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n
log4j.appender.warn.filter.F1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.warn.filter.F1.LevelMin=warn
log4j.appender.warn.filter.F1.LevelMax=warn log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
log4j.appender.error.File=./log/rest/rest_error
log4j.appender.error.DatePattern='.'yyyyMMdd'.log'
log4j.appender.error.layout=org.apache.log4j.PatternLayout
log4j.appender.error.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n
log4j.appender.error.filter.F1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.error.filter.F1.LevelMin=error
log4j.appender.error.filter.F1.LevelMax=error log4j.appender.fatal=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fatal.File=./log/rest/rest_fatal
log4j.appender.fatal.DatePattern='.'yyyyMMdd'.log'
log4j.appender.fatal.layout=org.apache.log4j.PatternLayout
log4j.appender.fatal.layout.ConversionPattern=%d [%-5p] (%F.%M:%L) - %m%n
log4j.appender.fatal.filter.F1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.fatal.filter.F1.LevelMin=fatal
log4j.appender.fatal.filter.F1.LevelMax=fatal #log4j.logger.com.dc.oauth.server=debug #----------------------------------------------------Ibaits----------------------------------------------------
#log4j.logger.com.ibatis=debug
#log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
#log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
#log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
#log4j.logger.java.sql.Connection=debug
#log4j.logger.java.sql.Statement=debug #log4j.logger.java.sql.PreparedStatement=debug,stdout
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n #log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601}[%-5p][%c][%t]:%m%n

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--
<welcome-file-list>
<welcom-file>index.jsp</welcom-file>
</welcome-file-list>
-->
<servlet>
<servlet-name>restServlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.dc.jetty.server</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>restServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

config.properties

#jetty
port=8080
contextPath=/
resourceBase=../web
descriptor=../web/WEB-INF/web.xml
maxThread=5000
minThread=100 #返回时间(单位毫秒)
sleepTime=100

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="jetty" default="package" basedir="."> <path id="classpath">
<pathelement location="."/>
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>
</fileset>
</path> <target name="clean">
<delete dir="${basedir}/all"/>
</target> <target name="prepare" depends="clean">
<mkdir dir="${basedir}/all"/>
<mkdir dir="${basedir}/all/bin"/>
<mkdir dir="${basedir}/all/lib"/>
<mkdir dir="${basedir}/all/web"/>
<mkdir dir="${basedir}/all/classes"/>
<mkdir dir="${basedir}/all/configs"/>
</target> <target name="copy" depends="prepare">
<copy todir="${basedir}/all/bin">
<fileset dir="${basedir}/bin" excludes="**/.svn/**/*.*">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${basedir}/all/lib">
<fileset dir="${basedir}/lib" excludes="**/.svn/**/*.*">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${basedir}/all/web">
<fileset dir="${basedir}/web" excludes="**/.svn/**/*.*">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${basedir}/all/configs">
<fileset dir="${basedir}/configs" excludes="**/.svn/**/*.*">
<include name="**/*"/>
</fileset>
</copy>
</target> <target name="compile" depends="copy">
<javac srcdir="${basedir}/src" destdir="${basedir}/all/classes" debug="true" deprecation="off" failonerror="true" encoding="utf8" nowarn="on">
<classpath refid="classpath"></classpath>
</javac>
</target> <target name="package" depends="compile">
<jar destfile="${basedir}/all/lib/start.jar">
<fileset dir="${basedir}/all/classes" includes="**/Start.class"/>
</jar>
<jar destfile="${basedir}/all/lib/jetty.jar">
<fileset dir="${basedir}/all/classes"/>
</jar>
<delete dir="${basedir}/all/classes"/>
</target> </project>

Start.java

package com.dc.jetty.start;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List; public class Start { private static void getJars(List<URL> urls, File cpdir)
throws MalformedURLException { for (File f : cpdir.listFiles()) {
if (f.isDirectory()) {
getJars(urls, f);
}
if (f.getName().endsWith(".jar")) {
URL url = f.toURI().toURL();
urls.add(url);
}
}
} @SuppressWarnings("unchecked")
public static void main(String[] args) { String classpath = System.getProperty("classpath");
List<URL> urls = new ArrayList<URL>();
File cpdir = new File(classpath);
if (!cpdir.exists() || !cpdir.isDirectory()) {
System.err.println("Please set system property \"classpath\" properly");
} else {
try {
getJars(urls, cpdir);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
URL[] urlArray = urls.toArray(new URL[0]);
URLClassLoader cl = new URLClassLoader(urlArray);
Thread.currentThread().setContextClassLoader(cl);
try {
Class clz = Class.forName("com.dc.jetty.start.StartServer", false, cl);
Method method = clz.getDeclaredMethod("getInstance");
method.setAccessible(true);
Object instance = method.invoke(clz);
Method m = clz.getDeclaredMethod("start");
m.invoke(instance);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} }

StartServer.java

package com.dc.jetty.start;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.dc.jetty.util.ConfigUtil; public class StartServer { private static StartServer instance = null; private StartServer() { } public static StartServer getInstance() {
if (instance == null) {
instance = new StartServer();
}
return instance;
} public void start() {
ConfigUtil.getInstance().getProperty("");
Server server = new Server(Integer.valueOf(ConfigUtil.getInstance().getProperty("port"))); WebAppContext webapp = new WebAppContext();
webapp.setContextPath(ConfigUtil.getInstance().getProperty("contextPath"));
webapp.setResourceBase(ConfigUtil.getInstance().getProperty("resourceBase"));
webapp.setDescriptor(ConfigUtil.getInstance().getProperty("descriptor"));
webapp.setParentLoaderPriority(true);
webapp.setClassLoader(Thread.currentThread().getContextClassLoader()); server.setHandler(webapp);
QueuedThreadPool pool = new QueuedThreadPool();
pool.setMaxThreads(Integer.valueOf(ConfigUtil.getInstance().getProperty("maxThread")));
pool.setMinThreads(Integer.valueOf(ConfigUtil.getInstance().getProperty("minThread")));
pool.setName("RestServer");
server.setThreadPool(pool);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
Logger logger = LoggerFactory.getLogger(StartServer.class);
logger.info("server starts"); } public static void main(String[] args) {
StartServer.getInstance().start();
} }

ConfigUtil.java

package com.dc.jetty.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties; public class ConfigUtil { private static ConfigUtil instance = null;
private Properties properties = null; private ConfigUtil() { } public static ConfigUtil getInstance() {
if (instance == null) {
instance = new ConfigUtil();
}
return instance;
} public void load() {
if (properties == null) {
properties = new Properties();
InputStream input = null;
try {
URL url = ConfigUtil.class.getClassLoader().getResource(
"config.properties");
if (url == null) {
throw new FileNotFoundException(
"config.properties not found!");
}
input = new FileInputStream(url.getPath());
// input = new FileInputStream(
// "E:\\paas\\01工作库\\09-代码\\trunks\\PaaS_NewFeatureLine\\Code\\OAuth\\configs\\oauth_conf\\config.properties");
properties.load(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} public void reload() {
properties = new Properties();
InputStream input = null;
try {
URL url = ConfigUtil.class.getClassLoader().getResource(
"config.properties");
if (url == null) {
throw new FileNotFoundException("config.properties not found!");
}
input = new FileInputStream(url.getPath());
properties.load(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} public String getProperty(String name) {
if (properties == null) {
load();
}
return properties.getProperty(name);
} public static void main(String[] args) {
System.out.println(ConfigUtil.getInstance().getProperty("port"));
} }

ServiceBeanContext.java

package com.dc.multiwrite.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; public class ServiceBeanContext { private static final Logger log = LoggerFactory
.getLogger(ServiceBeanContext.class); private static ServiceBeanContext context = null; private static ApplicationContext ctx = null; private ServiceBeanContext() { } public static ServiceBeanContext getInstance() {
if (context == null) {
synchronized (ServiceBeanContext.class) {
if (context == null) {
context = new ServiceBeanContext();
}
}
}
return context;
} public void loadContext(String path) {
try {
ctx = new ClassPathXmlApplicationContext(path);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
} public Object getBean(String bean) {
return ctx.getBean(bean);
}
}

DispatcherServlet.java

package com.dc.multiwrite.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet; import com.dc.multiwrite.util.ServiceBeanContext; public class DispatcherServlet extends HttpServlet {
private static final long serialVersionUID = 1L; public void init(ServletConfig config) {
ServiceBeanContext.getInstance().loadContext("applicationContext.xml");
}
}

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:property-placeholder location="classpath*:jdbc.properties" /> <!-- proxool连接池 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>${jdbc.driverClassName}</value>
</property>
<property name="driverUrl">
<value>${jdbc.url}</value>
</property>
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="alias" value="Pool_dbname" />
<property name="maximumActiveTime" value="600000" />
<property name="prototypeCount" value="0" />
<property name="maximumConnectionCount" value="50" />
<property name="minimumConnectionCount" value="2" />
<property name="simultaneousBuildThrottle" value="50" />
<property name="houseKeepingTestSql" value="select CURRENT_DATE" />
</bean> <!-- mybatis 配置 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:${jdbc.configLocation}" />
</bean> <bean id="sqlMapClient"
class="com.dc.multiwrite.dao.SqlMapClientTemplate">
<property name="sqlSession" ref="sqlSession" />
</bean> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean> <!-- 事务管理器 -->
<bean id="transactionmanager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> <!-- 方法事务参数 -->
<tx:advice id="serviceAdvice" transaction-manager="transactionmanager">
<tx:attributes>
<tx:method name="updateAppScalableStatus" propagation="REQUIRES_NEW"
isolation="READ_UNCOMMITTED" rollback-for="Exception" />
<tx:method name="updateDefaultProtocol" propagation="REQUIRES_NEW"
isolation="READ_UNCOMMITTED" rollback-for="Exception" />
<tx:method name="saveProtocol" propagation="REQUIRES_NEW"
isolation="READ_UNCOMMITTED" rollback-for="Exception" />
<tx:method name="saveNewNode" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="add*" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="run*" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="save*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="saveUpgrade" propagation="SUPPORTS"
isolation="READ_COMMITTED" rollback-for="Exception" />
<tx:method name="update*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="del*" propagation="REQUIRED" rollback-for="Exception" />
<tx:method name="start*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="stop*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="destroy*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="deploy*" propagation="REQUIRED" isolation="READ_COMMITTED"
rollback-for="Exception" />
<tx:method name="reapply" propagation="REQUIRED" isolation="READ_COMMITTED"
rollback-for="Exception" />
<tx:method name="redeploy*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="isolate*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="return*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="unisolate*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="*"/>
</tx:attributes>
</tx:advice> <!-- 配置切面 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="servicePointcut"
expression="execution(* com.dc.multiwrite.service.impl.*.*(..))" />
<aop:advisor pointcut-ref="servicePointcut" advice-ref="serviceAdvice" />
</aop:config> <context:component-scan
base-package="com.dc.multiwrite.dao.impl, com.dc.multiwrite.service.impl" /> </beans>

jdbc.properties

#oracle
#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:PAAS
#jdbc.username=PAAS
#jdbc.password=PAAS
#jdbc.configLocation=sql-map-oracle-config.xml #mysql
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.126.253.38:3306/test_guojwe?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
jdbc.username=root
jdbc.password=root
jdbc.configLocation=sql-map-mysql-config.xml

sql-map-mysql-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN" "ibatis-3-config.dtd"> <configuration> <settings>
<setting name="lazyLoadingEnabled" value="false" />
<setting name="cacheEnabled" value="true"/>
</settings> <mappers>
<mapper resource="db/mapping/mysql/test.xml"/>
</mappers> </configuration>

test.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "ibatis-3-mapper.dtd">
<mapper namespace="test"> <insert id="insert" parameterType="java.util.List">
insert into test(id, count)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.count})
</foreach>
</insert> <update id="update" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator="">
update test
<set>
count = #{item.count}
</set>
where id = #{item.id};
</foreach>
</update> <delete id="delete" parameterType="java.util.List">
delete from test
where id in
<foreach collection="list" item="item" index="index" separator="," open ="(" close=")">
#{item.id}
</foreach>
</delete> </mapper>

ExecutorServicePool.java

package com.dc.multiwrite.util;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory; public class ExecutorServicePool { private static ExecutorServicePool pool; private transient ExecutorService services; private ExecutorServicePool(){
int size = Integer.parseInt(ConfigUtil.getInstance().getProperty("multiwrite.threadPoolSize"));
services = Executors.newFixedThreadPool( size, new ThreadFactory() {
private static final String name = "multiwrite-thread";
public Thread newThread(Runnable r) {
return new Thread(r, name);
}
});
} public static ExecutorServicePool getInstance(){
if( pool == null ){
synchronized( ExecutorServicePool.class ){
if( pool == null ){
pool = new ExecutorServicePool();
}
}
}
return pool;
} public ExecutorService getServices() {
return services;
} public <T> Future<T> submit( Callable<T> task ){
return services.submit( task );
} public Future<?> submit( Runnable task ){
return services.submit( task );
} public void execute( Runnable command ){
services.execute( command );
}
}

java工程笔记的更多相关文章

  1. Java开发笔记(二)Java工程的帝国区划

    上一篇文章介绍了如何运行了第一个Java程序“Hello World”.然而这个开发环境看起来那么陌生,一个个名字符号完全不知道它们是干啥的呀,对于初学者来说,好比天书一般,多看几眼感觉都要走火入魔了 ...

  2. Java工程中各种带有O的对象分类笔记

    在Java工程里面,我们总会碰到各种不同的带有O的对象, 对于一个小白来说,经常会混淆这些对象的使用场景,所以在这里mark一下,让自己的代码更加规范,但这个也是Java被诟病的地方,不同的业务需要给 ...

  3. Java开发笔记(序)章节目录

    现将本博客的Java学习文章整理成以下笔记目录,方便查阅. 第一章 初识JavaJava开发笔记(一)第一个Java程序Java开发笔记(二)Java工程的帝国区划Java开发笔记(三)Java帝国的 ...

  4. Java开发笔记(四十三)更好用的本地日期时间

    话说Java一连设计了两套时间工具,分别是日期类型Date,以及日历类型Calendar,按理说用在编码开发中绰绰有余了.然而随着Java的日益广泛使用,人们还是发现了它们的种种弊端.且不说先天不良的 ...

  5. 如何用javac 和java 编译运行整个Java工程

    转自:http://blog.csdn.net/huagong_adu/article/details/6929817      前言:本文教你怎么用javac和Java命令,以及如何利用脚本(she ...

  6. Java开发笔记(一百四十六)JDBC的应用原理

    关系数据库使得海量信息的管理成为现实,但各家数据库提供的编程接口不尽相同,就连SQL语法也有所差异,像Oracle.MySQL.SQL Server都拥有自己的开发规则,倘若Java针对每个数据库单独 ...

  7. Java开发笔记(一百五十)C3P0连接池的用法

    JDBC既制定统一标准兼容了多种数据库,又利用预报告堵上了SQL注入漏洞,照理说已经很完善了,可是人算不如天算,它在性能方面不尽如人意.问题出在数据库连接的管理上,按照正常流程,每次操作完数据库,都要 ...

  8. Java开发笔记(一百零八)JSON串的定义和解析

    前面提到URL尾巴支持添加请求参数,具体格式形如“参数A名称=A参数值&参数B名称=B参数值”,可是这种格式只能传递简单的键值对信息,不能传递结构化数据,也无法传递数组形式的参数,因而它不适用 ...

  9. 《Effective Java》笔记45-56:通用程序设计

    将局部变量的作用域最小化,可以增强代码的可读性和可维护性,并降低出错的可能性. 要使用局部变量的作用域最小化,最有力的方法就是在第一次使用它的地方才声明,不要过早的声明. 局部变量的作用域从它被声明的 ...

随机推荐

  1. nyoj 142, poj 1039 ,hdu 1454 管道问题

    http://acm.nyist.net/JudgeOnline/problem.php?pid=142 第一道解析几何问题,比较纠结,主要是几个解析几何的基本操作,包括求两线段的叉积,判断左右方向, ...

  2. 黑马程序员_ Objective-c 之Foundation之NSNumber ,NSValue, NSDate

    Objective-c 之Foundation之NSNumber ,NSValue, NSDate 1.NSNumber具体用法如下: 在Objective-c中有int的数据类型,那为什么还要使用数 ...

  3. questasim仿真控制——breakpoint断点

    在使用questasim或者modelsim仿真时,如果需要控制仿真时间长度,一般在vsim中使用 run xxxxms/us等命令. 但是有时候不好估计仿真多长时间才能得到所有希望观察的结果,这个时 ...

  4. Eclipse导入Tomcat源码(转)

    想要研究下Tomcat的体系结构或者源码,最好将Tomcat的源码导入到ide中,编写实例进行代码跟踪(debug). 这里参考了网上一些资料,将自己操作过程记个流水账. 准备: 1.Tomcat源码 ...

  5. .html()和.text()的区别

    在页面调用接口显示数据的时候,正常情况下.html()和.text()都可以显示数据内容,但是在特殊情况下,比如接口中这个参数为空的时候就表现出差距了,.html()显示的是空白,而.text()显示 ...

  6. html, xhtml和xml

    html, xhtml和xml 1.定义及特点: 1) html:Hyper Text Markup Language 超文本标记语言 是最早写网页的语言,但编码不规范,主要用于控制数据的显示和外观. ...

  7. Sublime插件安装

    来在Sublime text3上安装Package Control 使用Ctrl+`(ESC下边的那个~)快捷键或者通过View->Show Console菜单打开命令行,粘贴如下代码: imp ...

  8. [转]简单理解Socket

    简单理解Socket 转自 http://www.cnblogs.com/dolphinX/p/3460545.html  题外话 前几天和朋友聊天,朋友问我怎么最近不写博客了,一个是因为最近在忙着公 ...

  9. JUC.Lock(锁机制)学习笔记[附详细源码解析]

    锁机制学习笔记 目录: CAS的意义 锁的一些基本原理 ReentrantLock的相关代码结构 两个重要的状态 I.AQS的state(int类型,32位) II.Node的waitStatus 获 ...

  10. SequoiaDB 笔记

    SequoiaDB 笔记 这几天翻了翻SequoiaDB的代码,记了点笔记.不保证下面内容的正确性(肯定有错的地方) 个人观感 优点 代码还不错,设计也算简洁. EDU和CB的使用让整个系统变得简单很 ...