|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
JAVA学习必须明确这是一项投资,对于大多数的人来说,学习JAVA是为了就业,还有就是刚走向工作位置的朋友想尽快赶上工作的节奏。js|源代码个中的opDb.java
============================================
packageymbean;
importjava.sql.*;
importjava.util.*;
importjava.text.*;
importcom.chinazjj.sql.dsql;
importcom.chinazjj.util.dutil;
//其他的包dsql,dutil中的内容我就不再贴了,在本文件顶用到的两个函数都很简
单
publicclassopDb{
privateStringinquire_value="",inquire_item="",disptype="",inqtyp
e="";
privateStringinquire_num="",inquire_addr="",inquire_name="";
privatedutilldutil=newdutil();
publicopDb(){
}
publicvoidsetinquire_item(Stringname){inquire_item=name
;}
publicvoidsetinquire_value(Stringname){inquire_value=ldut
il.chineseToUnicode(name);}
publicvoidsetdisptype(Stringname){disptype=name;}
publicvoidsetinqtype(Stringname){inqtype=name;}
publicvoidsetinquire_num(Stringname){inquire_num=ldutil.c
hineseToUnicode(name);}
publicvoidsetinquire_addr(Stringname){inquire_addr=ldutil
.chineseToUnicode(name);}
publicvoidsetinquire_name(Stringname){inquire_name=ldutil
.chineseToUnicode(name);}
publicStringgetinquire_dndata()
{
return"";
}
publicResultSetexecuteQuery(Stringsql)
{
ResultSetrs=null;
Statementlstmt=null;
try{
lstmt=connectdb();
rs=lstmt.executeQuery(sql);
System.out.println("executeQuery:"+sql);
}catch(SQLExceptionex){System.err.println("executeQuery:"+
ex.getMessage());}
returnrs;
}
publicStatementgetStmt()
{
Statementlstmt=null;
lstmt=connectdb();
returnlstmt;
}
publicStringexecuteUpdate(Stringsql)
{
ResultSetrs=null;
Statementlstmt=null;
try{
lstmt=connectdb();
lstmt.executeUpdate(sql);
System.out.println("executeUpdate:"+sql);
lstmt.executeUpdate("commit");
}
catch(SQLExceptionex){System.err.println("executeQuery:"+e
x.getMessage());
return(ex.getMessage());
}
return("executeUpdateok");
}
publicStatementconnectdb()
{
Statementlstmt=null;
Connectionconn=null;
finalStringconnect_string="jdbc:oracle:thin:scott/tiger@192.168.
0.1:1521:clubdb";
finalStringdriver_string="oracle.jdbc.driver.OracleDriver";
dsqlmysql=newdsql();
lstmt=mysql.dconnectdb(driver_string,connect_string);
returnlstmt;
}
publicStatementconnectdb(Stringconnect_string)
{
Statementlstmt=null;
Connectionconn=null;
finalStringdriver_string="oracle.jdbc.driver.OracleDriver";
dsqlmysql=newdsql();
lstmt=mysql.dconnectdb(driver_string,connect_string);
returnlstmt;
}
//=========otherfunction===================================
publicStringgetCurrentDate(Stringldateform)
{
return(newSimpleDateFormat(ldateform).format(newjava.util.Date(
)));
}
//========"/n"to"
"=====================================
//往失落奇异的:
publicStringremoveComment(StringContent){
StringmakeContent=newString();
StringTokenizerstrToken=newStringTokenizer(Content,"
");
StringtempToken=null;
while(strToken.hasMoreTokens()){
tempToken=strToken.nextToken();
if(tempToken.indexOf(":")!=0)
makeContent=makeContent+tempToken+"
";
}
returnmakeContent;
}
//将/n转换成为回车
publicStringaddBr(StringContent){
StringmakeContent=newString();
StringTokenizerstrToken=newStringTokenizer(Content,"
");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"
"+strToken.nextToken();
}
returnmakeContent;
}
//将
转换成为回车/n
publicStringaddCr(StringContent){
StringmakeContent=newString();
StringTokenizerstrToken=newStringTokenizer(Content,"
");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"
"+strToken.nextToken();
}
returnmakeContent;
}
//====================================================================
=====
publicbooleangetIdentify(Stringname1,Stringpwd1)
{
try
{
Stringsql="select*fromclub_userswhereusername="+name1+"
andpassword="+pwd1+"";
ResultSetrs=executeQuery(sql);
if(rs.next()){rs.close();return(true);}
else{rs.close();return(false);}
}catch(Exceptione){return(false);}
}
publicvoidcounts(Stringpagename)
{
executeUpdate("updatecall_countsetcounts=counts+1wherepagenam
e="+pagename+"");
}
//==================张家界市平易近假造社区办理============================
======
publicStringgetDeptSuper(Stringvp)//取版主
{
Stringvst="未知";
try{
Stringsql="selectadministratorfromclub_cvcdeptwheredeptno=
"+vp+"";
ResultSetrs=executeQuery(sql);
if(rs.next())vst=rs.getString(1);
rs.close();
}catch(Exceptione){}
returnvst;
}
publicStringgetDeptName(Stringvp)//取版名
{
Stringvst="未知";
try{
Stringsql="selectdeptnotefromclub_cvcdeptwheredeptno="+vp
+"";
ResultSetrs=executeQuery(sql);
if(rs.next())vst=rs.getString(1);
rs.close();
}catch(Exceptione){}
returnvst;
}
publicStringgetUserEmail(Stringvp)//取社区用户email
{
Stringvst="未知";
try{
Stringsql="selectemailfromclub_userswhereusername="+vp+"
";
ResultSetrs=executeQuery(sql);
if(rs.next())vst=rs.getString(1);
rs.close();
}catch(Exceptione){}
returnvst;
}
publicObjectgetaValue(Stringvp)//取社区用户email及其他
{
Objectvst=null;
try{
Stringsql=vp;
ResultSetrs=executeQuery(sql);
if(rs.next())vst=rs.getObject(1);
rs.close();
}catch(Exceptione){}
returnvst;
}
publicStringgetsValue(Stringvp)//取社区用户email及其他
{
Stringvst="";
try{
Stringsql=vp;
ResultSetrs=executeQuery(sql);
if(rs.next())vst=rs.getString(1);
rs.close();
}catch(Exceptione){}
returnvst;
}
}//endopDb.java
IDE是好。java中的IDE更是百花齐放,你用jbuilder能说jbuilder赶不上vs吗?用eclipse,netbeans也很舒服啊。我就不明白“稍微差一些”那一些是从哪里差来的。 |
|