JSP Message Board Source code 4
Last Update:2017-02-28
Source: Internet
Author: User
js| source code One of the Opdb.java
============================================
Package Ymbean;
Import java.sql.*;
Import java.util.*;
Import java.text.*;
Import Com.chinazjj.sql.dsql;
Import Com.chinazjj.util.dutil;
The contents of the other packages Dsql,dutil I will not post, the two functions used in this document are very simple
Single
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);
The 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 "
" =====================================
Remove the strange:
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;
}
Convert/N conversion to carriage return
public string ADDBR (string Content) {
String Makecontent=new string ();
StringTokenizer strtoken=new StringTokenizer (Content, "
");
while (Strtoken.hasmoretokens ()) {
Makecontent=makecontent+ "
"+strtoken.nexttoken ();
}
return makecontent;
}
Will
Convert to a carriage return/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+");
}
================== Zhangjiajie Citizen Virtual Community Management ============================
======
public string Getdeptsuper (string vp)//Moderator
{
String vst= "Unknown";
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)//Fetch name
{
String vst= "Unknown";
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)//Community User Email
{
String vst= "Unknown";
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)//Community user email and others
{
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)//Community user email and others
{
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