当前位置:编程学习 > JS >>

jsp自定义标签下拉框

package com.soft.test;
 
 import java.sql.*;
 
 import sun.jdbc.odbc.ee.ConnectionPool;
 
 public class BaseDao {
     //定义数据源驱动
     private static final String drive="oracle.jdbc.driver.OracleDriver";
     //定义连接字符串
     private static final String url="jdbc:oracle:thin:@10.72.240.34:1522:ffv2dev2";
     //用户名
     private static final String uid="produsr";
     //密码
     private static final String pwd="prod_123";
     //获得连接
     public static Connection getConnection()
     { 
         Connection con=null;
         try {
             //加载驱动
             Class.forName(drive);
             //建立连接
             con=DriverManager.getConnection(url,uid,pwd);
         } catch (Exception e) {
             e.printStackTrace();
         }
         return con;
     }
     //运行有结果,没有参数的sql语句
     public static ResultSet ResultrunSelectSql(String sql)
     {
         Connection con=null;
         PreparedStatement ps=null;
         ResultSet res=null;
         try
         {
         con=getConnection();
         ps=con.prepareStatement(sql);
         res=ps.executeQuery();  
         }
         catch(Exception e)
         {
             e.printStackTrace();
         }
         return res;
     }
     //执行有结果有参数的sql语句
     public static ResultSet runSelectSql(String sql,Object[] params)
     {
         Connection con=null;
         PreparedStatement pre=null;
         ResultSet res=null;
         
         try {
             con=getConnection();
             pre=con.prepareStatement(sql);
           for(int i=0;i<params.length;i++)
           {
               pre.setObject(i+1, params[i]);
               
           }
           res=pre.executeQuery();
         } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
         return res;
     }
     
     //运行没有结果,没有参数的sql语句
     public static boolean runUpdateSql(String sql)
     
     {
         Connection con=null;
         PreparedStatement ps=null;
         ResultSet res=null;
         try
         {
             con=getConnection();
             ps=con.prepareStatement(sql);
             
         ps.executeUpdate();
         return true;
             
         }
         catch(Exception e)
         {
             e.printStackTrace();
             return false;
         }
         
         
     }
     //执行有结果有参数的sql语句
     public static boolean runUpdateSql(String sql,Object[] params)
     {
         Connection con=null;
         PreparedStatement pre=null;
     
         
         try {
             con=getConnection();
             pre=con.prepareStatement(sql);
           for(int i=0;i<params.length;i++)
           {
               pre.setObject(i+1, params[i]);
                
           }
           pre.executeUpdate();
           return true;
         } catch (Exception e) {
             // TODO Aut

补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,