• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

jsp留言板源代码四: 给jsp初学者.

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
作 者: precom (皮蛋)
其中的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/[email protected].

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 "<br>" =====================================
//去掉奇怪的:
public String removeComment(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"\n");
String tempToken=null;

while(strToken.hasMoreTokens()){
tempToken=strToken.nextToken();
if(tempToken.indexOf(":")!=0)
makeContent=makeContent+tempToken+"\n";
}
return makeContent;
}

//将/n转换成为回车<br>
public String addBr(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"\n");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"<br>"+strToken.nextToken();
}
return makeContent;
}

//将<br>转换成为回车/n
public String addCr(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"<br>");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"\n"+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人参与评论

请发表评论

全部评论

专题导读
上一篇:
JSP教程(二)发布时间:2022-02-05
下一篇:
jsp留言板源代码三: 给jsp初学者.发布时间:2022-02-05
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap