连接池和JDBC连接有何不同? 连接池应该说是一种提访问高数据库连接效率的方法,它可以有不同的实现(C++/JAVA等),而jdbc是指用java语言进行数据库连接的实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jdbc对数据库连接,每次访问数据库都要进行连接,当访问很频繁的时候系统开销比较大;连接池的作用就是一个数据库和访问数据库的模块之间的缓冲区,需要访问数据库的时候,就分配一个连接给这个模块,用完之后释放,而连接池和数据库之间是一直连接的,这就减小了频繁连接数据库所需要的开销了。 连接池一般情况下指数据库连接池,它的作用是将数据库连接池化,在池中时刻保持多个数据库连接,在程序需要连接数据库的时候,直接从连接池中取连接,而不去直接建立到数据库的连接,这样可以大大减少建立连接和断开连接的次数。从而减轻了数据库压力,同时也提高的应用程序的效率。JDBC,是Java DataBase Connection的简称,是java连接数据库的一种技术。目前,java只能通过jdbc来连接数据库。关于鼠标事件的捕获,需要用到MouseListener下面是一个简单的程序://Frame1.javaimport 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); }} QQ,网易,当当等短信提醒业务的实现思考与讨论 请大家帮我看下这个文件夹复制代码 关于多线程的一个问题 在string中如何实现对某个子母或单词的查找并输出要查找字段的首字母其在整个String中的索引位置? API文档中一个问题 简单的JAVA问题,麻烦高手来看看。 client端写一个串,再读一个串。server端读一个串,再写一个串。这个功能应该怎样实现? 如何用java实现远程抓图(要包括鼠标轨迹) 我运行jdk1.3执行程序时出现以下错误: 写服务器遇到这样的问题,昏倒! 当在输入框中未输入任何东西, jbuilder中如何用JavaScript实现一个提示窗体?
连接池一般情况下指数据库连接池,它的作用是将数据库连接池化,在池中时刻保持多个数据库连接,在程序需要连接数据库的时候,直接从连接池中取连接,而不去直接建立到数据库的连接,这样可以大大减少建立连接和断开连接的次数。从而减轻了数据库压力,同时也提高的应用程序的效率。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);
}}