日期:2014-05-20  浏览次数:20757 次

3道编程题!~~各位高手来帮帮我啊!小女子先谢谢了!~
1.写一个Java程序实现线程连接池功能
2.写一个服务器端程序实现在客户端输入字符然后在控制台显示,直到输入“END”时停止
3.用JavaSocket编程,读服务器几个字符,再写入本地显示

一题20分!

------解决方案--------------------
这应该是作业吧,我给你写了,你自己也学不会呀,还是好好读书,研究一下吧。
------解决方案--------------------
网上好多。
------解决方案--------------------
这应该是作业吧,我给你写了,你自己也学不会呀,还是好好读书,研究一下吧。
同意

------解决方案--------------------
不厚道哦,这些最好自己研究明白...
------解决方案--------------------
我这正好有一个,LZ参考!
import java.sql.*;
import java.util.*;

public class ConnectionPool {
private static Vector freeConnetions = new Vector();
private static Vector usingConnections = new Vector();

//获取一个空闲连接
public static Connection getConnection() {
Connection connection = null;

if (freeConnetions.size() > 0) {
connection = (Connection) freeConnetions.remove(0);
} else {
try {
Class.forName( "org.gjt.mm.mysql.Driver ");
connection = DriverManager.getConnection
( "jdbc:mysql://127.0.0.1/zl?characterEncoding=gb18030 ");
usingConnections.add(connection);
} catch (ClassNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} finally {
}
}
return connection;
}

//释放一个连接
public static void freeConnection(Connection con) {
usingConnections.remove(con);
freeConnetions.add(con);

}
}
------解决方案--------------------
这年头不自成小女子会死人啊?!!!!!!!!!!
------解决方案--------------------
我靠 这什么公司的题目啊
------解决方案--------------------
2题:(不知道对不对哈,大家别笑我哈)
package test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//实现从客户端输入的方法
class Input{
String str = null;
public void input_method(){
System.out.println( "请输入字符串(输入end后结束): ");
BufferedReader sb = new BufferedReader(new InputStreamReader(System.in));
try{
//接受从键盘输入的字符串
str = sb.readLine();
}catch(IOException e){
System.out.println( "IOException ");
}
//判断是否输入的是 "end "字符串
if(str.equalsIgnoreCase( "end ")){
System.exit(1);
}
//在控制台打印你输入的字符串
else{
System.out.println( "------ "+str+ "------ ");
Input ips = new Input();
ips.input_method();

}

}
}
public class Demo {

public static void main(String[] args) {
Input ips = new Input();
//调用Input类中的方法
ips.input_method();

}
}

------解决方案--------------------
研究下。。。
------解决方案--------------------