<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
bean的代码如下:
[code:1]
/**
Instruction:
A bean to convert the "ResultSet" into a Table for html after SQL-selecting. Uses && provides TFW-Standard-Interface.
return 0: Every thing goes on well.
return 1: Exception somewhere.
return 2: Exception while input or output.
return 3: Exception caused by no class or no file found.
return 4: Exception with SQL.
New version modified much, still need to do futher test.
Guide:
"deal(ResultSet rs)".
package AA.BB...NN;Use this while package in pack "AA.BB...NN". Attention, the pack must be placed in one of the "CLASSPATH"s.
public class RS_deal_3
{
//>>Put out.
private static int stat=0;
private static String text="";
private static String str_out="";
private static Exception excp_rtn=null;
//<<Put out.
//>>Get in.
private static int mode=0;
private static char LG='E';
private static int GUI=0;
//<<Get in.
public static int rs_deal(ResultSet rs)
{
String string_1="[Start public static String deal()]";
String string_2="[Ended public static String deal()]";
System.out.println(string_1);
System.out.println(" <Version: 0.9.1+ Alpha 2004-10-17-02>\n -- Provide TFW-Standard-Interface.\n -- Set NULL after useing.\n -- Connection-Pool testing ...");
public static String notice()
{
String string_1="[Start public static String notice()]";
String string_2="[Ended public static String notice()]";
System.out.println(string_1);
if(stat==0)
{
text="Every thing goes on well.";
}
else if(stat==2)
{
text="Exception while input or output.";
}
else if(stat==3)
{
text="Exception caused by no class or no file found.";
}
else if(stat==4)
{
text="Exception with SQL.";
}
else
{
text="Exception somewhere.";
}
public static String result()
{
String string_1="[Start public static ResultSet result()]";
String string_2="[Ended public static ResultSet result()]";
System.out.println(string_1);
System.out.println(string_2);
return str_out;
}
public static Exception exception()
{
String string_1="[Start public static Exception exception()]";
String string_2="[Ended public static Exception exception()]";
System.out.println(string_1);
System.out.println("Exception caught: "+excp_rtn);
System.out.println(string_2);
return excp_rtn;
}
}
[/code:1]
一个使用连接池的上级bean调用这个bean时在“/opt/prog/m/Tomcat/log/catalina.out”里生成的相关部分记录为:
[code:1]
[Start public static String deal()]
<Version: 0.9.1+ Alpha 2004-10-17-02>
-- Provide TFW-Standard-Interface.
-- Set NULL after useing.
-- Connection-Pool testing ...
001 ... OK
Number of colums in this table is: 3
002 ... OK
002 ... OK
002 ... OK
003 ... OK
004 ... OK
<tr><td>uid</td><td>truename</td><td>nikname</td></tr>
005 ... OK
[Ended public static String deal()]
[Start public static String notice()]
[Ended public static String notice()]
[Start public static ResultSet result()]
[Ended public static ResultSet result()]
[Start public static Exception exception()]
Exception caught: Connection is closed. Operation is not permitted.
[Ended public static Exception exception()]
STATU:
4
NOTICE:
Exception with SQL.
EXCEPTION:
Connection is closed. Operation is not permitted.
[Ended public static int bridge()]
[Start public static String result()]
[Ended public static String result()]
[Start public Exception exception()]
Exception caught: Connection is closed. Operation is not permitted.
[Ended public Exception exception()]
[/code:1]
而一个不使用连接池的上级bean同样也调用这个bean却一切正常,在“/opt/prog/m/Tomcat/log/catalina.out”里生成的相关部分记录为:
[code:1]
[Start public static String deal()]
<Version: 0.9.1+ Alpha 2004-10-17-02>
-- Provide TFW-Standard-Interface.
-- Set NULL after useing.
-- Connection-Pool testing ...
001 ... OK
Number of colums in this table is: 3
002 ... OK
002 ... OK
002 ... OK
003 ... OK
004 ... OK
<tr><td>uid</td><td>gid</td><td>passwd</td></tr>
005 ... OK
006 ... OK
006 ... OK
006 ... OK
006 ... OK
006 ... OK
007 ... OK
[Ended public static String deal()]
[Start public static String notice()]
[Ended public static String notice()]
[Start public static ResultSet result()]
[Ended public static ResultSet result()]
[Start public static Exception exception()]
Exception caught: null
[Ended public static Exception exception()]
[/code:1]