连接池应该说是一种提访问高数据库连接效率的方法,它可以有不同的实现(C++/JAVA等),而jdbc是指用java语言进行数据库连接的实现

解决方案 »

  1.   

    jdbc对数据库连接,每次访问数据库都要进行连接,当访问很频繁的时候系统开销比较大;连接池的作用就是一个数据库和访问数据库的模块之间的缓冲区,需要访问数据库的时候,就分配一个连接给这个模块,用完之后释放,而连接池和数据库之间是一直连接的,这就减小了频繁连接数据库所需要的开销了。
      

  2.   


    连接池一般情况下指数据库连接池,它的作用是将数据库连接池化,在池中时刻保持多个数据库连接,在程序需要连接数据库的时候,直接从连接池中取连接,而不去直接建立到数据库的连接,这样可以大大减少建立连接和断开连接的次数。从而减轻了数据库压力,同时也提高的应用程序的效率。JDBC,是Java DataBase Connection的简称,是java连接数据库的一种技术。目前,java只能通过jdbc来连接数据库。关于鼠标事件的捕获,需要用到MouseListener
    下面是一个简单的程序:
    //Frame1.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;public class Frame1 extends JFrame implements MouseListener{
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JButton jButton1 = new JButton();
      JPanel jPanel1 = new JPanel();  //Construct the frame
      public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();
        jButton1.setText("jButton1");
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        contentPane.add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jButton1, null);
        jButton1.addMouseListener(this);
      }
      //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }  /**
        * Invoked when the mouse button has been clicked (pressed
        * and released) on a component.
        */
       public void mouseClicked(MouseEvent e)
       {
         System.out.println("mouseClicked");
       }   /**
        * Invoked when a mouse button has been pressed on a component.
        */
       public void mousePressed(MouseEvent e)
       {
         System.out.println("mousePressed");
       }   /**
        * Invoked when a mouse button has been released on a component.
        */
       public void mouseReleased(MouseEvent e)
       {
         System.out.println("mouseReleased");
       }   /**
        * Invoked when the mouse enters a component.
        */
       public void mouseEntered(MouseEvent e)
       {
         System.out.println("mouseEntered");
       }   /**
        * Invoked when the mouse exits a component.
        */
       public void mouseExited(MouseEvent e)
       {
         System.out.println("mouseExited");
       }   public static void main(String args[])
       {
         Frame1 frame = new Frame1();    //Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
       }}