gistfile1.txt import java.lang.annotation.Annotation;import java.lang.reflect.AnnotatedElement;import java.lang.reflect.Constructor;import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.M
import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; //临时数据表(实体类) public class DataTable{ Listcolumns=new ArrayList (); List > rows=new ArrayList
>(); } //select s.id users_id,users_name,users_pwd,roles_id,roles_name,users_roleid from users s,roles r where s.roleid=r.id private static Connection conn; //当前连接对象 private static final String name="C##CYB"; //用户名 private static final String pwd="123456"; //密码 private static final String envName="aaa"; //JNDI名,tomcat配置的连接池名称 private static final boolean isPool=false; //是否使用连接池(如果需要使用连接池,请在web环境测试) private static Context ctx=null; //创建容器对象 private static DataSource ds=null; //容器中取出Datasource数据源 private static ThreadLocal
tl; //线程资源绑定 /**初始化资源*/ static{ try { if (isPool) { ctx = new InitialContext(); ds=(DataSource)ctx.lookup("java:comp/env/"+envName); }else Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NamingException e) { e.printStackTrace(); } } /**根据SQL语句和参数获取Result对象*/ public static ResultSet getReusultSet(String sql,List