|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
你总不能说你写框架吧,那无疑会加大工作量,现在大多企业采取的是折中的办法,就是改别人写好的框架,可要改框架,前提是你对这个框架足够的了解,这就更难了。js|oracle
importjava.io.Reader;
importjava.sql.*;
importjavax.servlet.ServletRequest;
importjavax.servlet.http.HttpServletRequest;
importoracle.jdbc.driver.OracleResultSet;
importoracle.sql.CLOB;
publicclassDb_sql
{
/**
*机关函数,newDb_sql的时分实行,挪用connect()毗连ORACLE数据库
*/
publicDb_sql(Strings,Strings1,Strings2,Strings3,Strings4)
throwsException
{
isClosed=false;
host=s.trim();
port=s1.trim();
sid=s2.trim();
user=s3.trim();
password=s4.trim();
connMgr=DBConnectionManager.getInstance();
connect();
}
/**
*毗连ORACLE数据库
*/
publicbooleanconnect()
throwsException
{
Strings="jdbc:oracle:thin:@"+host+":"+port+":"+sid;
conn=connMgr.getConnection(user,s,user,password);
returntrue;
}
/**
*是不是主动COMMIT
*/
publicvoidsetAutoCommit(booleanflag)
throwsSQLException
{
bAutoCommit=flag;
conn.setAutoCommit(flag);
}
/**
*没有设置成主动COMMIT,挪用该办法才会COMMIT
*/
publicvoidcommit()
throwsSQLException
{
if(!bAutoCommit)
conn.commit();
}
/**
*没有设置成主动COMMIT,挪用该办法才会ROLLBACK
*/
publicvoidrollback()
throwsSQLException
{
if(!bAutoCommit)
conn.rollback();
}
/**
*实行SQL,前往实行了局TRUE/FALSE
*/
publicResultSetquery(Strings)
throwsException
{
if(stmt==null)
stmt=conn.createStatement();
if(result!=null)
{
result.close();
result=null;
}
result=stmt.executeQuery(s);
returnresult;
}
publicvoidqueryLarge(Strings,Strings1)
throwsException
{
stmt.execute(s);
ResultSetresultset=stmt.getResultSet();
if(resultset.next())
{
CLOBclob=((OracleResultSet)resultset).getCLOB(1);
clob.putChars(1L,s1.toCharArray());
}
resultset.close();
}
/**
*把了局集里的指针下移一名
*/
publicbooleannext()
throwsSQLException
{
returnresult.next();
}
/**
*获得以后纪录的INT范例字段值,前后往空格
*/
publicintgetInt(Strings)
throwsSQLException
{
returnresult.getInt(s.trim());
}
/**
*获得以后纪录的STRING范例字段值,前后往空格
*/
publicStringgetString(Strings)
throwsSQLException
{
returnresult.getString(s.trim());
}
/**
*获得以后纪录的SHORT范例字段值,前后往空格
*/
publicshortgetShort(Strings)
throwsSQLException
{
returnresult.getShort(s.trim());
}
/**
*获得以后纪录的LONG范例字段值,前后往空格
*/
publiclonggetLong(Strings)
throwsSQLException
{
returnresult.getLong(s.trim());
}
/**
*获得以后纪录的DATE范例字段值,前后往空格
*/
publicDategetDate(Strings)
throwsSQLException
{
returnresult.getDate(s.trim());
}
/**
*获得以后纪录的TIME范例字段值,前后往空格
*/
publicTimegetTime(Strings)
throwsSQLException
{
returnresult.getTime(s.trim());
}
/**
*获得以后纪录的FLOAT范例字段值,前后往空格
*/
publicfloatgetFloat(Strings)
throwsSQLException
{
returnresult.getFloat(s.trim());
}
/**
*获得以后纪录的DOUBLE范例字段值,前后往空格
*/
publicdoublegetDouble(Strings)
throwsSQLException
{
returnresult.getDouble(s.trim());
}
/**
*获得以后纪录的BOOLEAN范例字段值,前后往空格
*/
publicbooleangetBoolean(Strings)
throwsSQLException
{
returnresult.getBoolean(s.trim());
}
/**
*获得以后纪录的CLOB范例字段值
*/
publicStringgetText(Strings)
throwsSQLException
{
Strings1="";
charac[]=newchar[200];
CLOBclob=(CLOB)result.getObject(s);
if(clob==null)
returnnull;
Readerreader=clob.getCharacterStream();
inti;
try
{
while((i=reader.read(ac,0,200))!=-1)
s1=s1+newString(ac,0,i);
}
catch(Exceptionexception1)
{
thrownewSQLException(exception1.getMessage());
}
finally
{
try
{
reader.close();
}
catch(Exception_ex){}
}
returns1;
}
/**
*封闭数据库毗连,实行COMMIT,RELEASE举措
*/
publicbooleanclose()
throwsSQLException
{
if(result!=null)
{
result.close();
result=null;
}
if(stmt!=null)
{
stmt.close();
stmt=null;
}
conn.setAutoCommit(true);
connMgr.freeConnection(user,conn);
connMgr.release(user);
isClosed=true;
returntrue;
}
/**
*没有挪用close()时,实行close()
*/
protectedvoidfinalize()
throwsSQLException
{
if(!isClosed)
close();
}
/**
*获得HTTP参数值,一切失掉的值都做了
*String(request.getParameter(s.trim()).trim().getBytes("ISO8859_1"),"GB2312")处置
*/
publicstaticStringgetParameter(HttpServletRequesthttpservletrequest,Strings)
{
try
{
if(httpservletrequest.getParameter(s.trim())!=null)
returnnewString(httpservletrequest.getParameter(s.trim()).trim().getBytes("ISO8859_1"),"GB2312");
else
returnnull;
}
catch(Exception_ex)
{
returnhttpservletrequest.getParameter(s.trim());
}
}
privateStringhost;
privateStringport;
privateStringdatabase;
privateStringuser;
privateStringpassword;
privateStringsid;
privatebooleanbAutoCommit;
publicResultSetresult;
publicStatementstmt;
publicintaffectedRows;
publicConnectionconn;
privatebooleanisClosed;
privateDBConnectionManagerconnMgr;
}
从一个编程语言的普及程度来将,一个好的IDE是至关中要的,而现在的java的IDE虽然已经很好了,但是和.net比起来还是稍微差一些的,这是个客观事实。java要想普及的更好。DE是必须加以改进的。 |
|