- 浏览: 33573 次
- 性别:
- 来自: 南京
最新评论
文章列表
数据库操作基类设计4
- 博客分类:
- JDBC
/**
* 添加友情链接 同时处理多张表
* @return 是否添加成功
*/
public boolean addLinks(LinksInfo linksInfo) throws SQLException
{
SqlMapClient sqlMapClient = getSqlMapClient(); // 调用父类方法获取SqlMapClient
try
{
sqlMapClient.startTransaction();
// 当前连接设 ...
数据库操作基类设计3
- 博客分类:
- JDBC
public int queryTotalCount(T criteria)
{
String statementName = entitySimpleClassName + ".queryCount";
Integer totalCount = (Integer)getSqlMapClientTemplate().queryForObject(statementName, criteria);
return totalCount;
}
public List<T> queryByCr ...
数据库操作基类设计2
- 博客分类:
- JDBC
public List<T> queryAll() // 查询Domain所有记录
{
String statementName = entitySimpleClassName + ".queryAll";
return getSqlMapClientTemplate().queryForList(statementName);
}
public T queryById(String id) // 根据对象id查询Domain
{
String statementName = ...
数据库操作基类设计1
- 博客分类:
- JDBC
// DAO基础接口
public interface BaseDao<T>
...............
// 数据库操作基类
public abstract class BaseDaoImpl<T> extends SqlMapClientDaoSupport implements BaseDao<T>
{
private String entitySimpleClassName;
public BaseDaoImpl()
{
entitySimpleClassName = ((Class<T>)(( ...
生成m个不重复随机数组
- 博客分类:
- JAVA 核心
/**
* 生成m个不重复随机数组
* @param limit 若为10 则产生 0~9之间的随机数
* @param need m个
* @return 随机数组
*/
private static int[] getRandomMethod(int limit, int need)
{
int[] tempArray = new int[limit];
int[] resArray = new int[need];
for (int i = 0; i < limi ...
<select id="queryLotteryByCriteria" resultClass="lotteryUserInfo" parameterClass="java.util.HashMap">
select * from t_po_lotterydata
<dynamic prepend="where">
<isNotEmpty prepend="and" property="appId">
APPID = # ...
server.xml:
<GlobalNamingResources>
.............
<Resource name="PortalONEServiceDB" auth="Container" type="javax.sql.DataSource"
initialSize="5" minIdle="5" maxActive="5" maxIdle="5" maxWait="100"
use ...
public class ThhreadDemo
{
public static void main(String[] args)
{
Bread bread = new Bread();
Producer producer = new Producer(bread);
Consumer consumer = new Consumer(bread);
Consumer consumer2 = new Consumer(bread);
}
}
public class Consumer extends Thread
{
private Bread bread;
public Consumer(Bread bread)
{
this.bread = bread;
this.start();
}
public void run()
{
for (int i = 0; i < 5; i++)
{
// 把hasNumbers和pop方法放在一个同步块中,保证同时只有一个线程执行
...
public class Producer extends Thread
{
private Bread bread;
public Producer(Bread bread)
{
this.bread = bread;
this.start();
}
public void run()
{
for (int i = 0; i < 5; i++)
{
bread.push(); // 执行完后即释放对象锁
try
...
public class Bread
{
private int number = 6;
public synchronized void push()
{
number++;
System.out.println("生产一个面包,剩余 :" + number);
}
public void pop()
{
number--;
System.out.println("消费一个面包,剩余 :" + number);
}
public ...
<!--theme util包:定义portalone-commons-theme.jar包依赖的类和jar包的名称-->
<target name="build-theme" depends="compile" description="generate the distribution">
<property name="themeutilTempFileRootPath" value="themeutil" />
<mkdir dir=&q ...