⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 secondlist1.java

📁 实现功能:(1)管理员由1.浏览帖子2.添加主贴3.添加复帖4.更改 5.删除6.搜索帖子的权限 (2)注册会员有1.浏览帖子2.添加主贴3添加复帖4.搜索帖子的权限 (3)游客需注册
💻 JAVA
字号:
import java.sql.*;
import java.io.*;
import java.util.*;
//myAccount 作者账号 subMessageType 跟帖所属主帖的编号 content 帖子内容 title 主题名 
//forumNumber 本帖号 ptime 发表时间
public class SecondList1{
	public static void gentie(String myAccount,int mySubMessageType){
		try{
		Connection conn=getConnection();
		Statement stat=conn.createStatement();
		String printorder=new String("select nickName,content,dataTime from messagetable where messagetable.subMessageType="
		                  +mySubMessageType+" or messagetable.forumNumber="+mySubMessageType);
		ResultSet ztr=stat.executeQuery(printorder);
		System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * ");
	    while(ztr.next()){
	    	System.out.println("  "+ztr.getString(1)+"\t"+ztr.getString(2)+"\t"+ztr.getString(3));
	    }
	    System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * ");
		System.out.println("跟帖内容:");
		Scanner scan=new Scanner(System.in);
		String content=scan.next();
		ResultSet nameresult=stat.executeQuery("select nickName from usertable"
		                  +" where account='"+LoadForum.userA()+"'");
		nameresult.next();
		String authorname=nameresult.getString("nickName");
		GregorianCalendar newtime=new GregorianCalendar();
		String nowtime=newtime.getTime().toString();

		String numGet=new String("select max(forumNumber) from messagetable");
		ResultSet rng=stat.executeQuery(numGet);
		rng.next();
		int newnum=rng.getInt(1);
		newnum=newnum+1;
		String insertorder=new String("insert into messagetable values ("+newnum
		              +",'"+LoadForum.userA()+"','"+LoadForum.userN()+"',null,'"+content+"',1,"+mySubMessageType+
		              ",'"+nowtime+"')");
		stat.execute(insertorder);
		System.out.println("跟帖成功!\n");
		ztr.close();
		nameresult.close();
		stat.close();
		conn.close();
		LunTanDetails.firstList();
		}catch(Exception e){
			System.out.print(e);
		}
	}
	public static Connection getConnection()
      throws SQLException, IOException
   {  
      Properties props = new Properties();
      FileInputStream in = new FileInputStream("database3.properties");
      props.load(in);
      in.close();
      String drivers = props.getProperty("jdbc.drivers");
      if (drivers != null)
         System.setProperty("jdbc.drivers", drivers);
      String url = props.getProperty("jdbc.url");
      String username = props.getProperty("jdbc.username");
      String password = props.getProperty("jdbc.password");

      return DriverManager.getConnection(url, username, password);
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -