Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹¦ÄÜÍêÉƵÄJavaÁ¬½Ó³Øµ÷ÓÃʵÀý


/**
* Title: ConnectPool.java
* Description: Á¬½Ó³Ø¹ÜÀíÆ÷
* Copyright: Copyright (c) 2002/12/25
* Company:
* Author :
* Version 2.0
*/
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
/**
* ¹ÜÀíÀàDBConnectionManagerÖ§³Ö¶ÔÒ»¸ö»ò¶à¸öÓÉÊôÐÔÎļþ¶¨ÒåµÄÊý¾Ý¿âÁ¬½Ó
* ³ØµÄ·ÃÎÊ.¿Í»§³ÌÐò¿ÉÒÔµ÷ÓÃgetInstance()·½·¨·ÃÎʱ¾ÀàµÄΨһʵÀý.
*/
public class ConnectPool
{
static public ConnectPool instance; // ΨһʵÀý
static public int clients;
public Vector drivers = new Vector(); //Çý¶¯
public PrintWriter log;
public Hashtable pools = new Hashtable(); //Á¬½Ó
/**
* ·µ»ØΨһʵÀý.Èç¹ûÊǵÚÒ»´Îµ÷Óô˷½·¨,Ôò´´½¨ÊµÀý
*
* @return DBConnectionManager ΨһʵÀý
*/
static synchronized public ConnectPool getInstance()
{
if (instance == null)
{
instance = new ConnectPool();
}
clients++;
return instance;
}
/**
* ½¨¹¹º¯Êý˽ÓÐÒÔ·ÀÖ¹ÆäËü¶ÔÏó´´½¨±¾ÀàʵÀý
*/
public ConnectPool() {
init();
}
/**
* ½«Á¬½Ó¶ÔÏ󷵻ظøÓÉÃû×ÖÖ¸¶¨µÄÁ¬½Ó³Ø
*
* @param name ÔÚÊôÐÔÎļþÖж¨ÒåµÄÁ¬½Ó³ØÃû×Ö
* @param con Á¬½Ó¶ÔÏó
*/
public void freeConnection(String name, Connection con)
{
DBConnectionPool pool = (DBConnectionPool) pools.get(name);
if (pool != null)
{
pool.freeConnection(con);
}
else
{
System.out.println("pool ==null");
}
clients--;
}
/**
* »ñµÃÒ»¸ö¿ÉÓõÄ(¿ÕÏеÄ)Á¬½Ó.Èç¹ûûÓпÉÓÃÁ¬½Ó,ÇÒÒÑÓÐÁ¬½ÓÊýСÓÚ×î´óÁ¬½ÓÊý
* ÏÞÖÆ,Ôò´´½¨²¢·µ»ØÐÂÁ¬½Ó
*
* @param name ÔÚÊôÐÔÎļþÖж¨ÒåµÄÁ¬½Ó³ØÃû×Ö
* @return Connection ¿ÉÓÃÁ¬½Ó»ònull
*/
public Connection getConnection(String name)
{
DBConnectionPool pool = (DBConnectionPool) pools.get(name);
if (pool != null)
{
//return pool.getConnection();
return pool.returnConnection();
}
return null;
}
/**
* »ñµÃÒ»¸ö¿ÉÓÃÁ¬½Ó.ÈôûÓпÉÓÃÁ¬½Ó,ÇÒÒÑÓÐÁ¬½ÓÊýСÓÚ×î´óÁ¬½ÓÊýÏÞÖÆ,
* Ôò´´½¨²¢·µ»ØÐÂÁ¬½Ó.·ñÔò,ÔÚÖ¸¶¨µÄʱ¼äÄڵȴýÆäËüÏß³ÌÊÍ·ÅÁ¬½Ó.
*
* @param name Á¬½Ó³ØÃû×Ö
* @param time ÒÔºÁÃë¼ÆµÄµÈ´ýʱ¼ä
* @return Co


Ïà¹ØÎĵµ£º

Java½â¾ö¸÷ÖÖÖÐÎÄÂÒÂëÎÊÌ⣨1£©getºÍpostÇëÇó

×÷Ϊjava³ÌÐòÔ±£¬ÖÐÎĵÄÂÒÂëÎÊÌâ»á¾­³£Åöµ½¡£¹ýÈ¥µÄÒ»¸öÏîÄ¿£¬ÎÒÅöµ½Á˸÷ÖÖÀàÐ͵ÄjavaÂÒÂëÎÊÌâ¡£ÏÈ·ÖÏí¸ø´ó¼Ò£º
 
1£ºÍøÒ³PostÇëÇó£¬Ìá½»ºó£¬ÏÔʾÌá½»½á¹û£¬ÂÒÂë¡£
Ê×ÏÈÈ·¶¨Êý¾Ý¿âµÄ±àÂ뷽ʽ¡£ÕâÀïÎÒ·¢ÏÖ£¬Èç¹ûÊý¾Ý¿âµÄ±àÂë²»ÊÇUTF-8£¬PostÇëÇóÒ²¿ÉÒÔ±£Ö¤»ØÏÔÕýÈ·£¬µ«ÊÇÓÐÒ»¸öµØ·½Òª×¢Òâ¡£
ÈçhtmlÖУº
£¨1£©<i ......

JavaÃæÊÔÌâ

    JavaÃæÊÔÌâ—»ù´¡·½Ãæ:
1¡¢×÷ÓÃÓòpublic,private,protected,ÒÔ¼°²»Ð´Ê±µÄÇø±ð£¿
´ð£ºÇø±ðÈçÏ£º
×÷ÓÃÓò  µ±Ç°Àà ͬһpackag ×ÓËïÀà ÆäËûpackage
public √ √ √ √
protected √ √ √ ×
friendly √ √ × ×
pr ......

JAVAÀà±ä³Éwebservice

»·¾³eclipse6.0 +tomcat6.0
1.´´½¨Ò»¸ö¶¯Ì¬web¹¤³Ì£ºDynamic Web Project
2.Ìîд¹¤³ÌÃû³Æºó £¬Ò»Â·next -->finish ÔÚÕâÀïÎÒ´´½¨µÄÃû³ÆΪmywebservice
 
 
 
3.ÔÚsrc´´½¨×Ô¼ºµÄ°ücom.zhangchaoºÍÀà Hello.java£¬ÎÒÃÇÕâÀﻹÊÇ×ö¸ö¼òµ¥µÄhelloworld¡£
 
ÕâÀïÖ»×ö¶ÔijÈ˽øÐÐÎʺò¡£
 
4.Ì ......

JavaÖÐInputstreamÓëReaderµÄÇø±ð


JavaÖÐInputstreamÓëReaderµÄÇø±ð
 
ReaderÖ§³Ö16λµÄUnicode×Ö·ûÊä³ö£¬InputStreamÖ§³Ö8λµÄ×Ö·ûÊä³ö¡£
ReaderºÍInputStream·Ö±ðÊÇI/O¿âÌṩµÄÁ½Ì×ƽÐжÀÁ¢µÄµÈ¼¶»ú¹¹£¬
InputStream¡¢OutputStreamÊÇÓÃÀ´´¦Àí8λԪµÄÁ÷£¬
Reader¡¢WriterÊÇÓÃÀ´´¦Àí16λԪµÄÁ÷¡£
¶øÔÚJAVAÓïÑÔÖУ¬byteÀàÐÍÊÇ8λµÄ£¬charÀàÐÍÊÇ1 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ