Original Dbconfig.txt source code is as follows:
Pool=false
Datasource=java:comp/env/carddata
connurl=jdbc:microsoft:sqlserver://10.0.0.222:1433; User=sa;databasename=cardtest;
Drivername=com.microsoft.jdbc.sqlserver.sqlserverdriver
The original Datatable.java source code is as follows, but in order to invoke convenience, I added the Get method.:
Package pub;
Import Java.sql.ResultSet;
Import Java.sql.ResultSetMetaData;
public class datatable{
Private Java.util.ArrayList fdatalist;
Private Java.util.ArrayList fcolumnlist;
private int fcolumncount;
private int frowcount;
public int getColumnCount () {
return fcolumncount;
}
public int GetRowCount () {
return frowcount;
}
Public DataTable () {
Fdatalist=new java.util.ArrayList ();
Fcolumnlist=new java.util.ArrayList ();
}
public void SetData (ResultSet rs) {
try{
Fdatalist.clear ();
Fcolumnlist.clear ();
ResultSetMetaData Irsm=rs.getmetadata ();
Fcolumncount=irsm.getcolumncount ();
for (int i=0;i<fcolumncount;i++) {
Fcolumnlist.add (Irsm.getcolumnname (i+1). toLowerCase ());
}
Rs.beforefirst ();
while (Rs.next ()) {
DataRow dr=new DataRow ();
for (int i=0;i<fcolumncount;i++) {
String x=rs.getstring (i+1);
if (x==null) x= "";
if (X.equals ("null")) x= "";
Dr.additem (x);
}
Fdatalist.add (DR);
}
Frowcount=fdatalist.size ();
}catch (Exception e) {
}
}
public void Close () {
Fdatalist.clear ();
Fcolumnlist.clear ();
}
Public String getitemforname (int row,string colname) {
try{
if (row>-1 && row<frowcount) {
DataRow dr= (DataRow) fdatalist.get (row);
int Colindex=fcolumnlist.indexof (Colname.tolowercase ());
if (colindex>-1) {
Return Dr.getitem (Colindex);
}
else{
Return "";
}
}
else{
Return "";
}
}
catch (Exception e) {
Return "";
}
}
Public String getitemforindex (int row,int colindex) {
try{
if (row>-1 && row<frowcount) {
DataRow dr= (DataRow) fdatalist.get (row);
Return Dr.getitem (Colindex);
}
else{
Return "";
}
}
catch (Exception e) {
Return "";
}
}
}
The original database connection Conn.java source code is as follows:
Package pub;
Import java.sql.*;
Import java.io.*;
Import java.util.*;
Import Javax.naming.InitialContext;
Import Javax.naming.Context;
Import Javax.sql.DataSource;
public class Conn {
Private Boolean ispool=true;
Private String strdrivername= "";
Private String strconnurl= "";
Private String strdatasource= "";
Private String ferrormsg;
Public String GetLastError ()
{
return ferrormsg;
}
Public String test () {
&