java工程笔记
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工程笔记的更多相关文章
- Java开发笔记(二)Java工程的帝国区划
上一篇文章介绍了如何运行了第一个Java程序“Hello World”.然而这个开发环境看起来那么陌生,一个个名字符号完全不知道它们是干啥的呀,对于初学者来说,好比天书一般,多看几眼感觉都要走火入魔了 ...
- Java工程中各种带有O的对象分类笔记
在Java工程里面,我们总会碰到各种不同的带有O的对象, 对于一个小白来说,经常会混淆这些对象的使用场景,所以在这里mark一下,让自己的代码更加规范,但这个也是Java被诟病的地方,不同的业务需要给 ...
- Java开发笔记(序)章节目录
现将本博客的Java学习文章整理成以下笔记目录,方便查阅. 第一章 初识JavaJava开发笔记(一)第一个Java程序Java开发笔记(二)Java工程的帝国区划Java开发笔记(三)Java帝国的 ...
- Java开发笔记(四十三)更好用的本地日期时间
话说Java一连设计了两套时间工具,分别是日期类型Date,以及日历类型Calendar,按理说用在编码开发中绰绰有余了.然而随着Java的日益广泛使用,人们还是发现了它们的种种弊端.且不说先天不良的 ...
- 如何用javac 和java 编译运行整个Java工程
转自:http://blog.csdn.net/huagong_adu/article/details/6929817 前言:本文教你怎么用javac和Java命令,以及如何利用脚本(she ...
- Java开发笔记(一百四十六)JDBC的应用原理
关系数据库使得海量信息的管理成为现实,但各家数据库提供的编程接口不尽相同,就连SQL语法也有所差异,像Oracle.MySQL.SQL Server都拥有自己的开发规则,倘若Java针对每个数据库单独 ...
- Java开发笔记(一百五十)C3P0连接池的用法
JDBC既制定统一标准兼容了多种数据库,又利用预报告堵上了SQL注入漏洞,照理说已经很完善了,可是人算不如天算,它在性能方面不尽如人意.问题出在数据库连接的管理上,按照正常流程,每次操作完数据库,都要 ...
- Java开发笔记(一百零八)JSON串的定义和解析
前面提到URL尾巴支持添加请求参数,具体格式形如“参数A名称=A参数值&参数B名称=B参数值”,可是这种格式只能传递简单的键值对信息,不能传递结构化数据,也无法传递数组形式的参数,因而它不适用 ...
- 《Effective Java》笔记45-56:通用程序设计
将局部变量的作用域最小化,可以增强代码的可读性和可维护性,并降低出错的可能性. 要使用局部变量的作用域最小化,最有力的方法就是在第一次使用它的地方才声明,不要过早的声明. 局部变量的作用域从它被声明的 ...
随机推荐
- [DFNews] Cellebrite UFED系列更新, 支持IOS7
10月15日,Cellebrite公司对旗下产品进行了更新,包括UFED Classic.UFED Touch.Physical Analyzer.Logical Analyzer.Phone Det ...
- OpenGL学习笔记3——缓冲区对象
在GL中特别提出了缓冲区对象这一概念,是针对提高绘图效率的一个手段.由于GL的架构是基于客户——服务器模型建立的,因此默认所有的绘图数据均是存储在本地客户端,通过GL内核渲染处理以后再将数据发往GPU ...
- Window对象方法
Window对象方法 scrollBy() 按照指定的像素值来滚动内容. scrollTo() 把内容滚动到指定的坐标. setInterval() 按照指定的周期(以毫秒计)来调用函数或计算表达式. ...
- xp和win7安装telnet服务
xp: 有些ghost版本的xp会精简掉telnet服务 首先telnet服务需要的几个文件: tlntadmn.exe tlntsess.exe tlntsvr.exe tlntsvrp.dll 文 ...
- Scorpio-CSharp简介
Scorpio-CSharp是为了解决Unity游戏各个平台热更新的问题,纯c#实现 基于.net2.0 兼容所有c#平台 语法类似 javascript, 设计初衷是为了做一个所有人都能修改的热更新 ...
- 通过Robocopy+DOS 命令+Windows排程实现自动备份(将特定文件/目录备份至自动创建的以年月日命名的目标目录)
1. Software Requirement: 1.1.mirror.bat .mirror_SERVICE_BEGIN.mirror_SERVICE_END.robocopy.exe 1.2. C ...
- 【Python】pymongo使用
官方文档:http://api.mongodb.com/python/current/index.html MongoReplicaSetClient:http://api.mongodb.com/p ...
- 初识makefile
Makefile的规则 目标 : 需要的条件 (注意冒号两边有空格) 命令 (注意前面用tab键开头) 解释一下: 1 目标可以是一个或多个,可以是Object File,也可以是执行文件,甚至可以是 ...
- Session操作
存储API localStorage和sessionStorage通常被当做普通的JavaScript对象使用:通过设置属性来存储字符串值,查询该属性来读取该值.除此之外,这两个对象还提供了更加正式的 ...
- 在win7下将CapsLock按键变成esc
我喜欢用vim来编辑,经常要按到esc,但是去按那个按键确实比较的远,而且CapsLock这个按键对我来说着实有些鸡肋,所以就想在win7上也能像ubuntu那样把capslock映射为esc,在网上 ...