欢迎光临
我们一直在努力

jsp留言板源代码4-JSP教程,数据库相关

建站超值云服务器,限时71元/月

其中的opdb.java

============================================

package ymbean;

import java.sql.*;

import java.util.*;

import java.text.*;

import com.chinazjj.sql.dsql;

import com.chinazjj.util.dutil;

//其他的包dsql,dutil中的内容我就不再贴了,在本文件中用到的两个函数都很简



public class opdb {

private string inquire_value="",inquire_item="",disptype="",inqtyp

e="";

private string inquire_num="",inquire_addr="",inquire_name="";

private dutil ldutil=new dutil();

public opdb() {

}

public void setinquire_item(string name) { inquire_item= name

;}

public void setinquire_value( string name ) { inquire_value = ldut

il.chinesetounicode(name);}

public void setdisptype(string name) { disptype=name;}

public void setinqtype(string name) { inqtype=name;}

public void setinquire_num( string name ) { inquire_num = ldutil.c

hinesetounicode(name);}

public void setinquire_addr( string name ) { inquire_addr = ldutil

.chinesetounicode(name);}

public void setinquire_name( string name ) { inquire_name = ldutil

.chinesetounicode(name);}

public string getinquire_dndata()

{

return "";

}

public resultset executequery(string sql)

{

resultset rs = null;

statement lstmt = null;

try {

lstmt = connectdb();

rs = lstmt.executequery(sql);

system.out.println("executequery: "+sql);

} catch(sqlexception ex) { system.err.println("executequery: " +

ex.getmessage());}

return rs;

}

public statement getstmt()

{

statement lstmt = null;

lstmt = connectdb();

return lstmt;

}

public string executeupdate(string sql)

{

resultset rs = null;

statement lstmt = null;

try {

lstmt = connectdb();

lstmt.executeupdate(sql);

system.out.println("executeupdate: "+sql);

lstmt.executeupdate("commit");

}

catch(sqlexception ex) { system.err.println("executequery: " + e

x.getmessage());

return(ex.getmessage());

}

return("executeupdate ok");

}

public statement connectdb()

{

statement lstmt=null;

connection conn=null;

final string connect_string="jdbc:oracle:thin:scott/tiger@192.168.

0.1:1521:clubdb";

final string driver_string="oracle.jdbc.driver.oracledriver";

dsql mysql=new dsql();

lstmt=mysql.dconnectdb(driver_string,connect_string);

return lstmt;

}

public statement connectdb(string connect_string)

{

statement lstmt=null;

connection conn=null;

final string driver_string="oracle.jdbc.driver.oracledriver";

dsql mysql=new dsql();

lstmt=mysql.dconnectdb(driver_string,connect_string);

return lstmt;

}

//=========other function ===================================

public string getcurrentdate(string ldateform)

{

return(new simpledateformat(ldateform).format(new java.util.date(

)));

}

//========"/n" to "

" =====================================

//去掉奇怪的:

public string removecomment(string content){

string makecontent=new string();

stringtokenizer strtoken=new stringtokenizer(content,"

");

string temptoken=null;

while(strtoken.hasmoretokens()){

temptoken=strtoken.nexttoken();

if(temptoken.indexof(":")!=0)

makecontent=makecontent+temptoken+"

";

}

return makecontent;

}

//将/n转换成为回车

public string addbr(string content){

string makecontent=new string();

stringtokenizer strtoken=new stringtokenizer(content,"

");

while(strtoken.hasmoretokens()){

makecontent=makecontent+"

"+strtoken.nexttoken();

}

return makecontent;

}

//将

转换成为回车/n

public string addcr(string content){

string makecontent=new string();

stringtokenizer strtoken=new stringtokenizer(content,"

");

while(strtoken.hasmoretokens()){

makecontent=makecontent+"

"+strtoken.nexttoken();

}

return makecontent;

}

//====================================================================

=====

public boolean getidentify(string name1,string pwd1)

{

try

{

string sql="select * from club_users where username=" + name1 + "

and password=" + pwd1 + "";

resultset rs = executequery(sql);

if(rs.next()) { rs.close(); return(true);}

else { rs.close();return(false);}

}catch (exception e) { return(false);}

}

public void counts(string pagename)

{

executeupdate("update call_count set counts=counts + 1 where pagenam

e="+pagename+"");

}

//==================张家界市民虚拟社区管理============================

======

public string getdeptsuper(string vp) //取版主

{

string vst="未知";

try{

string sql="select administrator from club_cvcdept where deptno=

"+vp+"";

resultset rs = executequery(sql);

if(rs.next()) vst=rs.getstring(1);

rs.close();

} catch (exception e) {}

return vst;

}

public string getdeptname(string vp) //取版名

{

string vst="未知";

try{

string sql="select deptnote from club_cvcdept where deptno="+vp

+"";

resultset rs = executequery(sql);

if(rs.next()) vst=rs.getstring(1);

rs.close();

} catch (exception e) {}

return vst;

}

public string getuseremail(string vp) //取社区用户email

{

string vst="未知";

try{

string sql="select email from club_users where username="+vp+"

";

resultset rs = executequery(sql);

if(rs.next()) vst=rs.getstring(1);

rs.close();

} catch (exception e) {}

return vst;

}

public object getavalue(string vp) //取社区用户email及其他

{

object vst=null;

try{

string sql=vp;

resultset rs = executequery(sql);

if(rs.next()) vst=rs.getobject(1);

rs.close();

} catch (exception e) {}

return vst;

}

public string getsvalue(string vp) //取社区用户email及其他

{

string vst="";

try{

string sql=vp;

resultset rs = executequery(sql);

if(rs.next()) vst=rs.getstring(1);

rs.close();

} catch (exception e) {}

return vst;

}

}//end opdb.java

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » jsp留言板源代码4-JSP教程,数据库相关
分享到: 更多 (0)