src/org/bs/utils/JDBCHandler.java

(完整代码) 840B

package org.bs.utils;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Connection;

public class JDBCHandler<T> implements InvocationHandler {

	private T target = null;
	
	public T createProxy(Object target){
		this.target = (T)target;
		return (T)Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), this);
	}
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		Connection conn = ConnContext.getConn();
		Object result = null;
		try {
			result = method.invoke(target, args);
			DB.commit(conn);
		} catch (Exception e) {
			DB.rollback(conn);
			e.printStackTrace();
		} finally{
			DB.close(conn);
		}
		ConnContext.remove();
		return result;
	}
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。